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 AddMaxTeamSmallForm : LYFZ.Software.UI.MarketingAllPerson.SetSmallForm.AddMaxTeamSmallForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpTeamMaxTaskSet tmtsbll = new BLL.BLL_ErpTeamMaxTaskSet(); public AddMaxTeamSmallForm() { this.Load += AddMaxTeamSmallForm_Load; this.Shown += AddMaxTeamSmallForm_Shown; this.btnActivityNameSet.Click += btnActivityNameSet_Click; this.btnMaxTeamNameSet.Click += btnMaxTeamNameSet_Click; this.btnNew.Click += btnNew_Click; this.btnSaveed.Click += btnSaveed_Click; this.btnDelete.Click += btnDelete_Click; this.btnClose.Click += btnClose_Click; this.cmbtreevActivityName.ComboBoxTree_NodeMouseClick += cmbtreevActivityName_ComboBoxTree_NodeMouseClick; 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 AddMaxTeamSmallForm_Load(object sender, EventArgs e) { string StrTableName = "tb_ErpTeamMaxTaskSet Left Join tb_ErpTeamActiveSet on Tas_Number = Tmxt_TasNumber Left Join tb_ErpTeamMaxNameSet on Tmxn_Number = Tmxt_TmxnNumber"; string StrColumnName = "tb_ErpTeamMaxTaskSet.ID,Tmxt_TasNumber AS 活动名称编号,Tmxt_TmxnNumber AS 大队名称编号,Tas_Name AS 活动名称,Tmxn_Name AS 大队名称,Tmxt_BaodiTask AS 保底任务,Tmxt_TargetTask AS 目标任务,Tmxt_SprintTask AS 冲刺任务"; DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "", ShowColumnName: StrColumnName, filedOrder: "tb_ErpTeamMaxTaskSet.ID DESC").Tables[0]; this.dgvData.DataSource(dt, strHideField: "ID,活动名称编号,大队名称编号"); this.dgvData.Columns["活动名称"].Width = 200; this.dgvData.Columns["大队名称"].Width = 200; this.dgvData.FillLastColumn(true); } /// /// 窗体加载事件 /// /// /// void AddMaxTeamSmallForm_Shown(object sender, EventArgs e) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxName(this.cmbtreevMaxTeamName); } /// /// 设置活动 /// /// /// 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) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName); } } /// /// 设置大队名称 /// /// /// void btnMaxTeamNameSet_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.MarketingAllPerson.SuperSmallForm.MaxTeamNameSetSuperSmallForm frm = new SuperSmallForm.MaxTeamNameSetSuperSmallForm(); frm.ShowDialog(); if (frm.IsSaveed) { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxName(this.cmbtreevMaxTeamName); } } /// /// 新建 /// /// /// void btnNew_Click(object sender, EventArgs e) { this.IntClickID = 0; this.cmbtreevActivityName.SetTextAndTag_ValueNull(); this.cmbtreevMaxTeamName.SetTextAndTag_ValueNull(); this.lblMinTeamBaodiTask.Text = "0"; this.lblMinTeamTargetTask.Text = "0"; this.lblMinTeamSprintTask.Text = "0"; this.lblAssignBaodiTask.Text = "0"; this.lblAssignTargetTask.Text = "0"; this.lblAssignSprintTask.Text = "0"; this.txtBaodiTask.Text = ""; this.txtTargetTask.Text = ""; this.txtSprintTask.Text = ""; this.btnSaveed.Text = " 保 存"; } /// /// 保存 /// /// /// void btnSaveed_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim())) { MessageBoxCustom.Show("活动名称不能为空!"); return; } if (string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim())) { 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_ErpTeamMaxTaskSet model = null; if (this.IntClickID <= 0) { DataTable dt = orbll.GetView_Custom("tb_ErpTeamMaxTaskSet", StrWhere: "Tmxt_TasNumber = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "' And Tmxt_TmxnNumber = '" + this.cmbtreevMaxTeamName.Tag.ToString().Trim() + "'", ShowColumnName: "ID").Tables[0]; if (dt.Rows.Count > 0) { if (dt.Rows.Count > 1) { MessageBoxCustom.Show("数据结构混乱,无法操作!"); return; } if (MessageBoxCustom.Show("大队已设置过,是否要修改?", "", MessageBoxButtons.YesNo) == DialogResult.No) { 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_ErpTeamMaxTaskSet(); model.Tmxt_Number = "MXT_" + LYFZ.WinAPI.CustomPublicMethod.GenerateId().ToString().Trim(); model.Tmxt_TasNumber = this.cmbtreevActivityName.Tag.ToString().Trim(); model.Tmxt_TmxnNumber = this.cmbtreevMaxTeamName.Tag.ToString().Trim(); model.Tmxt_BaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim()); model.Tmxt_TargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim()); model.Tmxt_SprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim()); model.Tmxt_CreateDateTime = StrTime; model.Tmxt_CreateName = StrUserID; if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (tmtsbll.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()); DataTable dt = orbll.GetView_Custom("tb_ErpTeamMaxTaskSet", StrWhere: "Tmxt_TasNumber = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "' And ID != '" + this.IntClickID + "'", ShowColumnName: "Sum(Tmxt_BaodiTask) AS Tmxt_BaodiTask,Sum(Tmxt_TargetTask) AS Tmxt_TargetTask,Sum(Tmxt_SprintTask) AS Tmxt_SprintTask", GroupBy: "Tmxt_TasNumber").Tables[0]; if (dt.Rows.Count > 0) { deBaodiTask += Convert.ToDecimal(dt.Rows[0]["Tmxt_BaodiTask"]); deTargetTask += Convert.ToDecimal(dt.Rows[0]["Tmxt_TargetTask"]); deSprintTask += Convert.ToDecimal(dt.Rows[0]["Tmxt_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 = tmtsbll.GetModel(this.IntClickID); model.Tmxt_BaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim()); model.Tmxt_TargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim()); model.Tmxt_SprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim()); model.Tmxt_UpdateDateTime = StrTime; model.Tmxt_UpdateName = StrUserID; if (MessageBoxCustom.Show("您确定要修改吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (tmtsbll.Update(model)) { this.IsSaveed = true; MessageBoxCustom.Show("修改成功!"); } else { MessageBoxCustom.Show("修改失败!"); return; } } this.AddMaxTeamSmallForm_Load(this, null); this.cmbtreevActivityName_ComboBoxTree_NodeMouseClick(this, null); } /// /// 删除 /// /// /// void btnDelete_Click(object sender, EventArgs e) { if (this.IntClickID > 0) { DataTable dt = orbll.GetView_Custom("tb_ErpTeamMaxTaskSet", StrWhere: "ID = '" + this.IntClickID + "'", ShowColumnName: "Tmxt_Number").Tables[0]; if (dt.Rows.Count > 0) { dt = orbll.GetView_Custom("tb_ErpTeamMinTaskSet", StrWhere: "Tmit_TmxtNumber = '" + dt.Rows[0]["Tmxt_Number"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0]; if (dt.Rows.Count > 0) { MessageBoxCustom.Show("此大队名称已设置了小组,不能删除!"); return; } } if (MessageBoxCustom.Show("您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { if (tmtsbll.Delete(this.IntClickID)) { this.IsSaveed = true; MessageBoxCustom.Show("删除成功!"); this.AddMaxTeamSmallForm_Load(this, null); this.btnNew_Click(this, null); } else { MessageBoxCustom.Show("删除失败!"); } } } else { MessageBoxCustom.Show("请选择你要删除的大队!"); } } /// /// 关闭 /// /// /// void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 选择活动 /// /// /// void cmbtreevActivityName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (!string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim()) && this.cmbtreevActivityName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevActivityName.Tag.ToString().Trim())) { DataTable dt = orbll.GetView_Custom("tb_ErpTeamActiveSet", StrWhere: "Tas_Number = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "'", ShowColumnName: "Tas_BaodiTask,Tas_TargetTask,Tas_SprintTask").Tables[0]; DataTable dt2 = orbll.GetView_Custom("tb_ErpTeamMaxTaskSet", StrWhere: "Tmxt_TasNumber = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "'", ShowColumnName: "Sum(Tmxt_BaodiTask) AS Tmxt_BaodiTask,Sum(Tmxt_TargetTask) AS Tmxt_TargetTask,Sum(Tmxt_SprintTask) AS Tmxt_SprintTask", GroupBy: "Tmxt_TasNumber").Tables[0]; if (dt.Rows.Count > 0) { this.lblMinTeamBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tas_BaodiTask"].ToString().Trim()); this.lblMinTeamTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tas_TargetTask"].ToString().Trim()); this.lblMinTeamSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tas_SprintTask"].ToString().Trim()); } if (dt2.Rows.Count > 0) { this.lblAssignBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmxt_BaodiTask"].ToString().Trim()); this.lblAssignTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmxt_TargetTask"].ToString().Trim()); this.lblAssignSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmxt_SprintTask"].ToString().Trim()); } } } 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()); this.cmbtreevActivityName_ComboBoxTree_NodeMouseClick(this, null); this.cmbtreevMaxTeamName.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; } } } }