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; namespace LYFZ.Software.MainBusiness.MarketingAllPerson.SetSmallForm { public partial class AddMinTeamSmallForm : LYFZ.Software.UI.MarketingAllPerson.SetSmallForm.AddMinTeamSmallForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpTeamMinTaskSet tstsbll = new BLL.BLL_ErpTeamMinTaskSet(); public AddMinTeamSmallForm() { this.Load += AddMinTeamSmallForm_Load; this.Shown += AddMinTeamSmallForm_Shown; this.cmbtreevActivityName.ComboBoxTree_NodeMouseClick += cmbtreevActivityName_ComboBoxTree_NodeMouseClick; this.cmbtreevMaxTeamName.ComboBoxTree_NodeMouseClick += cmbtreevMaxTeamName_ComboBoxTree_NodeMouseClick; this.btnActivityNameSet.Click += btnActivityNameSet_Click; this.btnMaxTeamNameSet.Click += btnMaxTeamNameSet_Click; this.btnMinTeamNameSet.Click += btnMinTeamNameSet_Click; this.btnNew.Click += btnNew_Click; this.btnSaveed.Click += btnSaveed_Click; this.btnDelete.Click += btnDelete_Click; this.btnClose.Click += btnClose_Click; this.dgvData.CellMouseClick += dgvData_CellMouseClick; this.txtBaodiTask.KeyPress += txtBaodiTask_KeyPress; this.txtTargetTask.KeyPress += txtTargetTask_KeyPress; this.txtSprintTask.KeyPress += txtSprintTask_KeyPress; } /// /// 是否保存 /// public bool IsSaveed = false; /// /// 窗体加载事件 /// /// /// void AddMinTeamSmallForm_Load(object sender, EventArgs e) { this.GetTeamMinTask(); } /// /// 窗体加载事件 /// /// /// void AddMinTeamSmallForm_Shown(object sender, EventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMinName(this.cmbtreevMinTeamName); } /// /// 获取小组名称列表 /// /// void GetTeamMinTask(string StrActivityNumber = "", string StrMaxTeamNumber = "") { if (!string.IsNullOrEmpty(StrActivityNumber)) { StrActivityNumber = "Tmit_TasNumber = '" + StrActivityNumber + "'"; } if (!string.IsNullOrEmpty(StrActivityNumber) && !string.IsNullOrEmpty(StrMaxTeamNumber)) { StrActivityNumber += " And Tmit_TmxnNumber = '" + StrMaxTeamNumber + "'"; } else if (!string.IsNullOrEmpty(StrMaxTeamNumber)) { StrActivityNumber = "Tmit_TmxnNumber = '" + StrMaxTeamNumber + "'"; } string StrTableName = "tb_ErpTeamMinTaskSet Left Join tb_ErpTeamActiveSet on Tas_Number = Tmit_TasNumber Left Join tb_ErpTeamMaxNameSet on Tmxn_Number = Tmit_TmxnNumber Left Join tb_ErpTeamMinNameSet on Tmin_Number = Tmit_TminNumber"; string StrColumnName = "tb_ErpTeamMinTaskSet.ID,Tmit_TasNumber AS 活动名称编号,Tmit_TmxnNumber AS 大队名称编号,Tmit_TminNumber AS 小组名称编号,Tas_Name AS 活动名称,Tmxn_Name AS 大队名称,Tmin_Name AS 小组名称,Tmit_BaodiTask AS 保底任务,Tmit_TargetTask AS 目标任务,Tmit_SprintTask AS 冲刺任务"; DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: StrActivityNumber, ShowColumnName: StrColumnName, filedOrder: "tb_ErpTeamMinTaskSet.ID DESC").Tables[0]; this.dgvData.DataSource(dt, strHideField: "ID,活动名称编号,大队名称编号,小组名称编号"); this.dgvData.FillLastColumn(true); } /// /// 获取大队任务 /// void GetMaxTeamTask() { this.lblMinTeamBaodiTask.Text = "0"; this.lblMinTeamTargetTask.Text = "0"; this.lblMinTeamSprintTask.Text = "0"; this.lblAssignBaodiTask.Text = "0"; this.lblAssignTargetTask.Text = "0"; this.lblAssignSprintTask.Text = "0"; if (!string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim()) && this.cmbtreevActivityName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevActivityName.Tag.ToString().Trim()) && !string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()) && this.cmbtreevMaxTeamName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Tag.ToString().Trim())) { DataTable dt = orbll.GetView_Custom("tb_ErpTeamMaxTaskSet", StrWhere: "Tmxt_TasNumber = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "' And Tmxt_TmxnNumber = '" + this.cmbtreevMaxTeamName.Tag.ToString().Trim() + "'", ShowColumnName: "Tmxt_BaodiTask,Tmxt_TargetTask,Tmxt_SprintTask").Tables[0]; DataTable dt2 = orbll.GetView_Custom("tb_ErpTeamMinTaskSet", StrWhere: "Tmit_TasNumber = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "' And Tmit_TmxnNumber = '" + this.cmbtreevMaxTeamName.Tag.ToString().Trim() + "'", ShowColumnName: "Sum(Tmit_BaodiTask) AS Tmit_BaodiTask,Sum(Tmit_TargetTask) AS Tmit_TargetTask,Sum(Tmit_SprintTask) AS Tmit_SprintTask", GroupBy: "Tmit_TasNumber,Tmit_TmxnNumber").Tables[0]; if (dt.Rows.Count > 0) { this.lblMinTeamBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tmxt_BaodiTask"].ToString().Trim()); this.lblMinTeamTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tmxt_TargetTask"].ToString().Trim()); this.lblMinTeamSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tmxt_SprintTask"].ToString().Trim()); } if (dt2.Rows.Count > 0) { this.lblAssignBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmit_BaodiTask"].ToString().Trim()); this.lblAssignTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmit_TargetTask"].ToString().Trim()); this.lblAssignSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmit_SprintTask"].ToString().Trim()); } } } /// /// 活动名称选择加载大队 /// /// /// void cmbtreevActivityName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxTaskName(this.cmbtreevMaxTeamName, this.cmbtreevActivityName.Tag.ToString().Trim()); this.GetTeamMinTask(this.cmbtreevActivityName.Tag.ToString().Trim()); this.GetMaxTeamTask(); } /// /// 大队名称选择加载小组 /// /// /// void cmbtreevMaxTeamName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (!string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()) && this.cmbtreevMaxTeamName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Tag.ToString().Trim())) { this.GetTeamMinTask(this.cmbtreevActivityName.Tag.ToString().Trim(), this.cmbtreevMaxTeamName.Tag.ToString().Trim()); } this.GetMaxTeamTask(); } /// /// 活动设置 /// /// /// void btnActivityNameSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.MarketingAllPerson.SetSmallForm.AddNewActiveSmallForm frm = new AddNewActiveSmallForm(); frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual; frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y); frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height); frm.ShowDialog(); if (frm.IsSaveed) { this.cmbtreevActivityName.SetTextAndTag_ValueNull(); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName); } } /// /// 大队设置 /// /// /// void btnMaxTeamNameSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.MarketingAllPerson.SetSmallForm.AddMaxTeamSmallForm frm = new AddMaxTeamSmallForm(); frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual; frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y); frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height); frm.ShowDialog(); if (frm.IsSaveed) { this.cmbtreevMaxTeamName.SetTextAndTag_ValueNull(); if (string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim())) { this.cmbtreevMaxTeamName.Nodes.Clear(); } else { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxTaskName(this.cmbtreevMaxTeamName, this.cmbtreevActivityName.Tag.ToString().Trim()); } } } /// /// 小组设置 /// /// /// void btnMinTeamNameSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.MarketingAllPerson.SuperSmallForm.MinTeamNameSetSuperSmallForm frm = new SuperSmallForm.MinTeamNameSetSuperSmallForm(); frm.ShowDialog(); if (frm.IsSaveed) { this.cmbtreevMinTeamName.SetTextAndTag_ValueNull(); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMinName(this.cmbtreevMinTeamName); } } /// /// 新建 /// /// /// void btnNew_Click(object sender, EventArgs e) { this.IntClickID = 0; this.cmbtreevActivityName.SetTextAndTag_ValueNull(); this.cmbtreevMaxTeamName.SetTextAndTag_ValueNull(); this.cmbtreevMinTeamName.SetTextAndTag_ValueNull(); this.cmbtreevMaxTeamName.Nodes.Clear(); this.txtBaodiTask.Text = ""; this.txtTargetTask.Text = ""; this.txtSprintTask.Text = ""; this.btnSaveed.Text = " 保 存"; } /// /// 保存 /// /// /// void btnSaveed_Click(object sender, EventArgs e) { if (this.cmbtreevActivityName.Tag == null) { MessageBoxCustom.Show("活动名称不能为空!"); return; } if (this.cmbtreevMaxTeamName.Tag == null) { MessageBoxCustom.Show("大队名称不能为空!"); return; } if (this.cmbtreevMinTeamName.Tag == null) { MessageBoxCustom.Show("小组名称不能为空!"); return; } if (string.IsNullOrEmpty(this.txtBaodiTask.Text.Trim())) { MessageBoxCustom.Show("保底任务不能为空!"); return; } if (string.IsNullOrEmpty(this.txtTargetTask.Text.Trim())) { MessageBoxCustom.Show("目标任务不能为空!"); return; } if (string.IsNullOrEmpty(this.txtSprintTask.Text.Trim())) { MessageBoxCustom.Show("冲刺任务不能为空!"); return; } if (Convert.ToDecimal(this.txtBaodiTask.Text.Trim()) > Convert.ToDecimal(this.txtTargetTask.Text.Trim())) { MessageBoxCustom.Show("目标任务不能小于保底任务!"); return; } if (Convert.ToDecimal(this.txtTargetTask.Text.Trim()) > Convert.ToDecimal(this.txtSprintTask.Text.Trim())) { MessageBoxCustom.Show("冲刺任务不能小于目标任务!"); return; } DateTime StrTime = SDateTime.Now; string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; LYFZ.Model.Model_ErpTeamMinTaskSet model = null; if (this.IntClickID <= 0) { DataTable dt = orbll.GetView_Custom("tb_ErpTeamMinTaskSet", StrWhere: "Tmit_TasNumber = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "' And Tmit_TmxtNumber = '" + this.cmbtreevMaxTeamName.Tag.ToString().Trim() + "' And Tmit_TminNumber = '" + this.cmbtreevMinTeamName.Tag.ToString().Trim() + "'", ShowColumnName: "ID").Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows.Count > 1) { MessageBoxCustom.Show("数据结构混乱,无法操作!"); return; } this.IntClickID = Convert.ToInt32(dt.Rows[0]["ID"]); } } if (this.IntClickID <= 0) { if ((Convert.ToDecimal(this.txtBaodiTask.Text.Trim()) + Convert.ToDecimal(this.lblAssignBaodiTask.Text.Trim())) > Convert.ToDecimal(this.lblMinTeamBaodiTask.Text.Trim())) { MessageBoxCustom.Show("大队的所有小组总保底任务不能大于大队保底任务!"); return; } if ((Convert.ToDecimal(this.txtTargetTask.Text.Trim()) + Convert.ToDecimal(this.lblAssignTargetTask.Text.Trim())) > Convert.ToDecimal(this.lblMinTeamTargetTask.Text.Trim())) { MessageBoxCustom.Show("大队的所有小组总目标任务不能大于大队目标任务!"); return; } if ((Convert.ToDecimal(this.txtSprintTask.Text.Trim()) + Convert.ToDecimal(this.lblAssignSprintTask.Text.Trim())) > Convert.ToDecimal(this.lblMinTeamSprintTask.Text.Trim())) { MessageBoxCustom.Show("大队的所有小组总冲刺任务不能大于大队冲刺任务!"); return; } model = new Model.Model_ErpTeamMinTaskSet(); model.Tmit_Number = "MIT_" + LYFZ.WinAPI.CustomPublicMethod.GenerateId().ToString().Trim(); model.Tmit_TasNumber = this.cmbtreevActivityName.Tag.ToString().Trim(); model.Tmit_TmxnNumber = this.cmbtreevMaxTeamName.Tag.ToString().Trim(); model.Tmit_TmxtNumber = this.cmbtreevMaxTeamName.StrGetName.Trim(); model.Tmit_TminNumber = this.cmbtreevMinTeamName.Tag.ToString().Trim(); model.Tmit_BaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim()); model.Tmit_TargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim()); model.Tmit_SprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim()); model.Tmit_CreateDateTime = StrTime; model.Tmit_CreateName = StrUserID; if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (tstsbll.Add(model)) { this.IsSaveed = true; MessageBoxCustom.Show("添加成功!"); this.btnNew_Click(this, null); } else { MessageBoxCustom.Show("添加失败!"); return; } } else { decimal deBaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim()); decimal deTargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim()); decimal deSprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim()); string StrTableName = "Sum(Tmit_BaodiTask) AS Tmit_BaodiTask,Sum(Tmit_TargetTask) AS Tmit_TargetTask,Sum(Tmit_SprintTask) AS Tmit_SprintTask"; string StrWhere = "Tmit_TasNumber = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "' And Tmit_TmxnNumber = '" + this.cmbtreevMaxTeamName.Tag.ToString().Trim() + "' And ID != '" + this.IntClickID + "'"; DataTable dt = orbll.GetView_Custom("tb_ErpTeamMinTaskSet", StrWhere: StrWhere, ShowColumnName: StrTableName, GroupBy: "Tmit_TasNumber,Tmit_TmxnNumber").Tables[0]; if (dt.Rows.Count > 0) { deBaodiTask += Convert.ToDecimal(dt.Rows[0]["Tmit_BaodiTask"]); deTargetTask += Convert.ToDecimal(dt.Rows[0]["Tmit_TargetTask"]); deSprintTask += Convert.ToDecimal(dt.Rows[0]["Tmit_SprintTask"]); } if (deBaodiTask > Convert.ToDecimal(this.lblMinTeamBaodiTask.Text.Trim())) { MessageBoxCustom.Show("大队的所有小组总保底任务不能大于大队保底任务!"); return; } if (deTargetTask > Convert.ToDecimal(this.lblMinTeamTargetTask.Text.Trim())) { MessageBoxCustom.Show("大队的所有小组总目标任务不能大于大队目标任务!"); return; } if (deSprintTask > Convert.ToDecimal(this.lblMinTeamSprintTask.Text.Trim())) { MessageBoxCustom.Show("大队的所有小组总冲刺任务不能大于大队冲刺任务!"); return; } model = tstsbll.GetModel(this.IntClickID); model.Tmit_BaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim()); model.Tmit_TargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim()); model.Tmit_SprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim()); model.Tmit_UpdateDateTime = StrTime; model.Tmit_UpdateName = StrUserID; if (MessageBoxCustom.Show("您确定要修改吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (tstsbll.Update(model)) { this.IsSaveed = true; MessageBoxCustom.Show("修改成功!"); } else { MessageBoxCustom.Show("修改失败!"); return; } } this.AddMinTeamSmallForm_Load(this, null); this.GetMaxTeamTask(); } /// /// 删除 /// /// /// void btnDelete_Click(object sender, EventArgs e) { if (this.IntClickID > 0) { DataTable dt = orbll.GetView_Custom("tb_ErpTeamMinTaskSet", StrWhere: "ID = '" + this.IntClickID + "'", ShowColumnName: "Tmit_TminNumber").Tables[0]; if (dt.Rows.Count > 0) { dt = orbll.GetView_Custom("tb_ErpTeamPersonSet", StrWhere: "Tps_TmitNumber = '" + dt.Rows[0]["Tmit_TminNumber"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0]; if (dt.Rows.Count > 0) { MessageBoxCustom.Show("此小组名称已设置了组成员,不能删除!"); return; } } if (MessageBoxCustom.Show("您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (tstsbll.Delete(this.IntClickID)) { this.IsSaveed = true; MessageBoxCustom.Show("删除成功!"); this.btnNew_Click(this, null); } else { MessageBoxCustom.Show("删除失败!"); } } } else { MessageBoxCustom.Show("请选择你要删除的小组!"); } } /// /// 关闭 /// /// /// void btnClose_Click(object sender, EventArgs e) { this.Close(); } int IntClickID = 0; /// /// 列表点击事件 /// /// /// void dgvData_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex >= 0 && e.RowIndex >= 0) { if (this.dgvData.Rows.Count > 0) { this.IntClickID = Convert.ToInt32(this.dgvData.Rows[e.RowIndex].Cells["ID"].Value); this.cmbtreevActivityName.TagFindText(this.dgvData.Rows[e.RowIndex].Cells["活动名称编号"].Value.ToString().Trim()); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxTaskName(this.cmbtreevMaxTeamName, this.cmbtreevActivityName.Tag.ToString().Trim()); this.cmbtreevMaxTeamName.TagFindText(this.dgvData.Rows[e.RowIndex].Cells["大队名称编号"].Value.ToString().Trim()); this.GetMaxTeamTask(); this.cmbtreevMinTeamName.TagFindText(this.dgvData.Rows[e.RowIndex].Cells["小组名称编号"].Value.ToString().Trim()); this.txtBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(this.dgvData.Rows[e.RowIndex].Cells["保底任务"].Value); this.txtTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(this.dgvData.Rows[e.RowIndex].Cells["目标任务"].Value); this.txtSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(this.dgvData.Rows[e.RowIndex].Cells["冲刺任务"].Value); this.btnSaveed.Text = " 修 改"; } } } /// /// 保底限制输入 /// /// /// void txtBaodiTask_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b') { e.Handled = true; } } /// /// 目标限制输入 /// /// /// void txtTargetTask_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b') { e.Handled = true; } } /// /// 冲刺限制输入 /// /// /// void txtSprintTask_KeyPress(object sender, KeyPressEventArgs e) { if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar)) { e.Handled = true; } if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b') { e.Handled = true; } } } }