123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- using LYFZ.DAL;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Collections;
- using System.IO;
- using LYFZ.ComponentLibrary;
- using LYFZ.Helper;
- namespace LYFZ.Software.MainBusiness.OAShopManagement
- {
- public class frmTaskAssigned : LYFZ.Software.UI.OAShopManagement.frmTaskAssigned
- {
- string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- LYFZ.BLL.BLL_ErpShopAssignmente ambll = new BLL.BLL_ErpShopAssignmente();
- /// <summary>
- /// 当前任务状态
- /// </summary>
- CompleteStatus currentCompleteStatus = CompleteStatus.新任务;
- /// <summary>
- /// 任务处理人角色类型
- /// </summary>
- TeskType currentTeskType = TeskType.办理人;
- ComponentLibrary.DataGridViewEx currentTaskView = null;
- public frmTaskAssigned(string Parameters)
- : this()
- {
- if (Parameters.Trim() == TeskType.发布人.ToString())
- {
- currentTeskType = TeskType.发布人;
- this.tbMain.TabPages.Remove(this.tpReceivingTask);
- }
- else
- {
- currentTeskType = TeskType.办理人;
- this.tbMain.TabPages.Remove(this.tpPublishingTasks);
- }
- }
- public frmTaskAssigned()
- {
- this.tbMain.SelectedIndexChanged += tbMain_SelectedIndexChanged;
- //发布任务
- this.btnAddTask.Click += btnAddTask_Click;
- //任务处理
- this.btnTaskSummary.Click += btnTaskSummary_Click;
- this.btnReply.Click += btnReply_Click;
- //删除任务
- this.btndel.Click += btndel_Click;
- //关闭
- this.btnClose.Click += btnClose_Click;
- this.dgvMyTaskView.CellDoubleClick += dgvMyTaskView_CellDoubleClick;
- this.dgvTaskView.CellDoubleClick += dgvTaskView_CellDoubleClick;
- this.ucPagerEx1.EventPaging += ucMyPagerEx_EventPaging;
- this.ucMyPagerEx.EventPaging += ucMyPagerEx_EventPaging;
- this.Load += frmTaskAssigned_Load;
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TasksAssigned, CustomAttributes.OperatingAuthority.Delete))
- {
- this.btndel.Enabled = true;
- }
- else
- {
- this.btndel.Enabled = false;
- }
- if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TasksAssigned, CustomAttributes.OperatingAuthority.Add))
- {
- this.btnAddTask.Enabled = true;
- }
- else
- {
- this.btnAddTask.Enabled = false;
- }
- this.btnReply.Enabled = false;
- this.rdoNewTask.Click += rdoRadioButton_Click;
- this.rdoExecutionIngTask.Click += rdoRadioButton_Click;
- this.rdoCompletedTask.Click += rdoRadioButton_Click;
- this.rdoterminationTask.Click += rdoRadioButton_Click;
- this.rdoMyNewTask.Click += rdoRadioButton_Click;
- this.rdoMyExecutionIngTask.Click += rdoRadioButton_Click;
- this.rdoMyCompletedTask.Click += rdoRadioButton_Click;
- this.rdoMyTerminationTask.Click += rdoRadioButton_Click;
- }
- void btnReply_Click(object sender, EventArgs e)
- {
- if (this.dgvTaskView.CurrentRow != null)
- {
- frmTeskView frm = new frmTeskView();
- frm.MyTeskType = this.currentTeskType;
- frm.TeskRow = this.dgvTaskView.Rows[this.dgvTaskView.CurrentRow.Index];
- if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- RefreshingBind();
- }
- }
- else
- {
- MessageBoxCustom.Show("请选中你要处理的任务!");
- }
- }
- void rdoRadioButton_Click(object sender, EventArgs e)
- {
- ComponentLibrary.RadioButtonEx rdoBtn = (ComponentLibrary.RadioButtonEx)sender;
- if (rdoBtn.Checked)
- {
- this.currentCompleteStatus = (CompleteStatus)Convert.ToInt32(rdoBtn.Tag);
- }
- if (this.currentTeskType == TeskType.发布人)
- {
- if (this.currentCompleteStatus == CompleteStatus.新任务 || this.currentCompleteStatus == CompleteStatus.执行中)
- {
- this.btnReply.Enabled = false;
- }
- else {
- this.btnReply.Enabled = true;
- }
- this.ucPagerEx1.Bind();
- }
- else {
- this.ucMyPagerEx.Bind();
- }
- }
- /// <summary>
- /// 接收任务/新任务双击列表事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvMyTaskView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
- {
- if (this.dgvMyTaskView.CurrentRow != null)
- {
- frmTeskView frm1 = new frmTeskView();
- frm1.MyTeskType = this.currentTeskType;
- frm1.TeskRow = this.dgvMyTaskView.Rows[this.dgvMyTaskView.CurrentRow.Index];
- if (frm1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- RefreshingBind();
- }
- }
- }
- }
- /// <summary>
- /// 加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void frmTaskAssigned_Load(object sender, EventArgs e)
- {
- BindData();
- }
- /// <summary>
- /// 新任务双击列表事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvTaskView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (this.dgvTaskView.Rows.Count > 0)
- {
- if (this.dgvTaskView.CurrentRow.Index >= 0 && this.dgvTaskView.CurrentCell.ColumnIndex >= 0)
- {
- if (this.dgvTaskView.CurrentRow != null)
- {
- if (this.currentCompleteStatus == CompleteStatus.新任务 || this.currentCompleteStatus == CompleteStatus.无法完成)
- {
- frmReleaseTask frm = new frmReleaseTask();
- frm.TaskRow = this.dgvTaskView.Rows[this.dgvTaskView.CurrentRow.Index];
- if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- RefreshingBind();
- }
- }
- else {
- MessageBoxCustom.Show("“执行中”和“已完成”的任务不可修改");
- }
- }
- }
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btndel_Click(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvTaskView.CurrentRow.Index >= 0 && this.dgvTaskView.CurrentCell.ColumnIndex >= 0)
- {
- if (this.dgvTaskView.CurrentRow != null)
- {
- if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- if (ambll.Delete(ambll.GetModel(Convert.ToInt32(dgvTaskView.CurrentRow.Cells["ID"].Value))))
- {
- MessageBoxCustom.Show("删除成功!");
- this.dgvTaskView.Rows.Remove(this.dgvTaskView.CurrentRow);
- }
- else
- {
- MessageBoxCustom.Show("删除失败!");
- }
- }
- }
- else
- {
- MessageBoxCustom.Show("请选中你要删除的数据!");
- }
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(ex.Message);
- }
- }
- /// <summary>
- /// 处理任务
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnTaskSummary_Click(object sender, EventArgs e)
- {
- if (this.dgvMyTaskView.CurrentRow != null)
- {
- frmTeskView frm = new frmTeskView();
- frm.MyTeskType = this.currentTeskType;
- frm.TeskRow = this.dgvMyTaskView.Rows[this.dgvMyTaskView.CurrentRow.Index];
- if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- RefreshingBind();
- }
- }
- else {
- MessageBoxCustom.Show("请选中你要处理的任务!");
- }
- }
- /// <summary>
- /// 发布
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAddTask_Click(object sender, EventArgs e)
- {
- frmReleaseTask frm = new frmReleaseTask();
- if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
- RefreshingBind();
- }
- }
-
- /// <summary>
- /// 绑定数据
- /// </summary>
- /// <param name="ucPager"></param>
- private void ucPagerExBind(UCPager.ucPagerEx ucPager)
- {
- if (currentTeskType == TeskType.发布人)
- {
- this.currentTaskView = this.dgvTaskView;
- }
- else {
- this.currentTaskView = this.dgvMyTaskView;
- }
- ucPager.PageCurrent = 1;
- ucPager.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
- ucPager.Bind();
- }
- /// <summary>
- /// 画分页1
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- private int ucMyPagerEx_EventPaging(UCPager.EventPagingArg e)
- {
-
- string filterName = "Agt_ManageName";
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- if (this.currentTeskType == TeskType.发布人)
- {
- filterName = "Agt_PublishName";
- pageData.PageIndex = this.ucPagerEx1.PageCurrent;
- pageData.PageSize = this.ucPagerEx1.PageSize;
- }
- else {
- filterName = "Agt_ManageName";
- pageData.PageIndex = this.ucMyPagerEx.PageCurrent;
- pageData.PageSize = this.ucMyPagerEx.PageSize;
- }
-
- pageData.TableName = "tb_ErpShopAssignmente";//表名
-
- pageData.QueryCondition = filterName + "='" + strUserID + "' and Agt_CompleteStatus = '" + ((int)this.currentCompleteStatus).ToString() + "'";//查询条件
- pageData.QueryFieldName = "ID,Agt_Priority,Agt_PublishName,Agt_PublishTime,Agt_Content,Agt_ManageName,Agt_CompleteTime,Agt_CompleteStatus,Agt_Summary,Agt_Revert,Agt_TaskTopic,Agt_Deadlines";//查询字段
- pageData.OrderStr = "ID";
- pageData.OrderType = 1;
- DataTable dt = new DataTable();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = pageData.QueryDataTable().Tables[0];
- });
- try
- {
- this.currentTaskView.Rows.Clear();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataGridViewRow row1 = new DataGridViewRow();
- row1.CreateCells(this.currentTaskView);
- row1.Cells[0].Value = dt.Rows[i]["ID"].ToString();
- string Agt_TaskTopic = "无主题";
- if (dt.Rows[i]["Agt_TaskTopic"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Agt_TaskTopic"].ToString().Trim()))
- {
- Agt_TaskTopic = dt.Rows[i]["Agt_TaskTopic"].ToString();
- }
- row1.Cells[1].Value = Agt_TaskTopic;
- row1.Cells[2].Value = dt.Rows[i]["Agt_Content"].ToString();
- row1.Cells[3].Value = ((Priority)Convert.ToInt32(dt.Rows[i]["Agt_Priority"])).ToString();
- row1.Cells[4].Value = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dt.Rows[i]["Agt_PublishName"].ToString())["User_Name"].ToString().Trim();
- row1.Cells[5].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Agt_PublishTime"], "yyyy-MM-dd HH:mm");
- string Agt_ManageName = "";
- DataRow dtRow = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(dt.Rows[i]["Agt_ManageName"].ToString());
- if (dtRow != null)
- {
- Agt_ManageName = dtRow["User_Name"].ToString().Trim();
- }
- row1.Cells[6].Value = Agt_ManageName;
- row1.Cells[6].Tag = dt.Rows[i]["Agt_ManageName"].ToString();
- row1.Cells[7].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Agt_Deadlines"], "yyyy-MM-dd HH:mm");
- row1.Cells[8].Value = ((CompleteStatus)Convert.ToInt32(dt.Rows[i]["Agt_CompleteStatus"])).ToString();
- row1.Cells[9].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Agt_CompleteTime"], "yyyy-MM-dd HH:mm");
- row1.Cells[10].Value = dt.Rows[i]["Agt_Summary"].ToString();//任务总结
- row1.Cells[11].Value = dt.Rows[i]["Agt_Revert"].ToString();//发布人回复
- this.currentTaskView.Rows.Add(row1);
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show("绑定数据时出错:" + ex.Message);
- }
- try
- {
- e.CurrentPager.TbDataSource = dt;
- }
- catch { }
- this.currentTaskView.ClearSelection();
- return pageData.TotalCount;
- }
- void RefreshingBind()
- {
- if (this.currentTeskType == TeskType.发布人)
- {
- ucPagerExBind(this.ucPagerEx1);
- }
- else {
- ucPagerExBind(this.ucMyPagerEx);
- }
- }
- // private delegate void UpdateControl();
- /// <summary>
- /// 选项卡
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void tbMain_SelectedIndexChanged(object sender, EventArgs e)
- {
-
- switch (this.tbMain.SelectedIndex)
- {
- case 0:
- this.currentTeskType = TeskType.发布人;
- break;
- case 1:
- this.currentTeskType = TeskType.办理人;
-
- break;
- }
- BindData();
- }
- void BindData()
- {
- bool b;
- if (this.currentTeskType == TeskType.发布人)
- {
- b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理发布任务);
- if (!b)
- {
- this.Close();
- return;
- }
- ucPagerExBind(this.ucPagerEx1);
- }
- else {
- b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理我的任务);
- if (!b)
- {
- this.Close();
- return;
- }
- ucPagerExBind(this.ucMyPagerEx);
- }
-
- }
- public enum CompleteStatus
- {
- 新任务 = 0,
- 执行中 = 1,
- 已完成 = 2,
- 无法完成 = 3
- }
- public enum Priority
- {
- 高 = 0,
- 中 = 1,
- 低 = 2
- }
-
-
- }
- }
|