123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- 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;
- }
- /// <summary>
- /// 是否保存
- /// </summary>
- public bool IsSaveed = false;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- /// <summary>
- /// 设置活动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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); }
- }
- /// <summary>
- /// 设置大队名称
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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); }
- }
- /// <summary>
- /// 新建
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 = " 保 存";
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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("请选择你要删除的大队!"); }
- }
- /// <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 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;
- /// <summary>
- /// 列表点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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 = " 修 改";
- }
- }
- }
- /// <summary>
- /// 保底限制输入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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; }
- }
- /// <summary>
- /// 目标限制输入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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; }
- }
- /// <summary>
- /// 冲刺限制输入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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; }
- }
- }
- }
|