AddMaxTeamSmallForm.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.MarketingAllPerson.SetSmallForm
  10. {
  11. public partial class AddMaxTeamSmallForm : LYFZ.Software.UI.MarketingAllPerson.SetSmallForm.AddMaxTeamSmallForm
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  14. LYFZ.BLL.BLL_ErpTeamMaxTaskSet tmtsbll = new BLL.BLL_ErpTeamMaxTaskSet();
  15. public AddMaxTeamSmallForm()
  16. {
  17. this.Load += AddMaxTeamSmallForm_Load;
  18. this.Shown += AddMaxTeamSmallForm_Shown;
  19. this.btnActivityNameSet.Click += btnActivityNameSet_Click;
  20. this.btnMaxTeamNameSet.Click += btnMaxTeamNameSet_Click;
  21. this.btnNew.Click += btnNew_Click;
  22. this.btnSaveed.Click += btnSaveed_Click;
  23. this.btnDelete.Click += btnDelete_Click;
  24. this.btnClose.Click += btnClose_Click;
  25. this.cmbtreevActivityName.ComboBoxTree_NodeMouseClick += cmbtreevActivityName_ComboBoxTree_NodeMouseClick;
  26. this.dgvData.CellMouseClick += dgvData_CellMouseClick;
  27. this.txtBaodiTask.KeyPress += txtBaodiTask_KeyPress;
  28. this.txtTargetTask.KeyPress += txtTargetTask_KeyPress;
  29. this.txtSprintTask.KeyPress += txtSprintTask_KeyPress;
  30. }
  31. /// <summary>
  32. /// 是否保存
  33. /// </summary>
  34. public bool IsSaveed = false;
  35. /// <summary>
  36. /// 窗体加载事件
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="e"></param>
  40. void AddMaxTeamSmallForm_Load(object sender, EventArgs e)
  41. {
  42. string StrTableName = "tb_ErpTeamMaxTaskSet Left Join tb_ErpTeamActiveSet on Tas_Number = Tmxt_TasNumber Left Join tb_ErpTeamMaxNameSet on Tmxn_Number = Tmxt_TmxnNumber";
  43. 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 冲刺任务";
  44. DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: "", ShowColumnName: StrColumnName, filedOrder: "tb_ErpTeamMaxTaskSet.ID DESC").Tables[0];
  45. this.dgvData.DataSource(dt, strHideField: "ID,活动名称编号,大队名称编号");
  46. this.dgvData.Columns["活动名称"].Width = 200;
  47. this.dgvData.Columns["大队名称"].Width = 200;
  48. this.dgvData.FillLastColumn(true);
  49. }
  50. /// <summary>
  51. /// 窗体加载事件
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. void AddMaxTeamSmallForm_Shown(object sender, EventArgs e)
  56. {
  57. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName);
  58. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxName(this.cmbtreevMaxTeamName);
  59. }
  60. /// <summary>
  61. /// 设置活动
  62. /// </summary>
  63. /// <param name="sender"></param>
  64. /// <param name="e"></param>
  65. void btnActivityNameSet_Click(object sender, EventArgs e)
  66. {
  67. LYFZ.Software.MainBusiness.MarketingAllPerson.SetSmallForm.AddNewActiveSmallForm frm = new AddNewActiveSmallForm();
  68. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  69. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  70. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  71. frm.ShowDialog();
  72. if (frm.IsSaveed)
  73. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamActivityName(this.cmbtreevActivityName); }
  74. }
  75. /// <summary>
  76. /// 设置大队名称
  77. /// </summary>
  78. /// <param name="sender"></param>
  79. /// <param name="e"></param>
  80. void btnMaxTeamNameSet_Click(object sender, EventArgs e)
  81. {
  82. LYFZ.Software.MainBusiness.MarketingAllPerson.SuperSmallForm.MaxTeamNameSetSuperSmallForm frm = new SuperSmallForm.MaxTeamNameSetSuperSmallForm();
  83. frm.ShowDialog();
  84. if (frm.IsSaveed)
  85. { LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_TeamMaxName(this.cmbtreevMaxTeamName); }
  86. }
  87. /// <summary>
  88. /// 新建
  89. /// </summary>
  90. /// <param name="sender"></param>
  91. /// <param name="e"></param>
  92. void btnNew_Click(object sender, EventArgs e)
  93. {
  94. this.IntClickID = 0;
  95. this.cmbtreevActivityName.SetTextAndTag_ValueNull();
  96. this.cmbtreevMaxTeamName.SetTextAndTag_ValueNull();
  97. this.lblMinTeamBaodiTask.Text = "0";
  98. this.lblMinTeamTargetTask.Text = "0";
  99. this.lblMinTeamSprintTask.Text = "0";
  100. this.lblAssignBaodiTask.Text = "0";
  101. this.lblAssignTargetTask.Text = "0";
  102. this.lblAssignSprintTask.Text = "0";
  103. this.txtBaodiTask.Text = "";
  104. this.txtTargetTask.Text = "";
  105. this.txtSprintTask.Text = "";
  106. this.btnSaveed.Text = " 保 存";
  107. }
  108. /// <summary>
  109. /// 保存
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. void btnSaveed_Click(object sender, EventArgs e)
  114. {
  115. if (string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim()))
  116. { MessageBoxCustom.Show("活动名称不能为空!"); return; }
  117. if (string.IsNullOrEmpty(this.cmbtreevMaxTeamName.Text.Trim()))
  118. { MessageBoxCustom.Show("大队名称不能为空!"); return; }
  119. if (string.IsNullOrEmpty(this.txtBaodiTask.Text.Trim()))
  120. { MessageBoxCustom.Show("保底任务不能为空!"); return; }
  121. if (string.IsNullOrEmpty(this.txtTargetTask.Text.Trim()))
  122. { MessageBoxCustom.Show("目标任务不能为空!"); return; }
  123. if (string.IsNullOrEmpty(this.txtSprintTask.Text.Trim()))
  124. { MessageBoxCustom.Show("冲刺任务不能为空!"); return; }
  125. if (Convert.ToDecimal(this.txtBaodiTask.Text.Trim()) > Convert.ToDecimal(this.txtTargetTask.Text.Trim()))
  126. { MessageBoxCustom.Show("目标任务不能小于保底任务!"); return; }
  127. if (Convert.ToDecimal(this.txtTargetTask.Text.Trim()) > Convert.ToDecimal(this.txtSprintTask.Text.Trim()))
  128. { MessageBoxCustom.Show("冲刺任务不能小于目标任务!"); return; }
  129. DateTime StrTime = SDateTime.Now;
  130. string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  131. LYFZ.Model.Model_ErpTeamMaxTaskSet model = null;
  132. if (this.IntClickID <= 0)
  133. {
  134. 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];
  135. if (dt.Rows.Count > 0)
  136. {
  137. if (dt.Rows.Count > 1)
  138. { MessageBoxCustom.Show("数据结构混乱,无法操作!"); return; }
  139. if (MessageBoxCustom.Show("大队已设置过,是否要修改?", "", MessageBoxButtons.YesNo) == DialogResult.No)
  140. { return; }
  141. this.IntClickID = Convert.ToInt32(dt.Rows[0]["ID"]);
  142. }
  143. }
  144. if (this.IntClickID <= 0)
  145. {
  146. if ((Convert.ToDecimal(this.txtBaodiTask.Text.Trim()) + Convert.ToDecimal(this.lblAssignBaodiTask.Text.Trim())) > Convert.ToDecimal(this.lblMinTeamBaodiTask.Text.Trim()))
  147. { MessageBoxCustom.Show("活动的所有大队总保底任务不能大于活动保底任务!"); return; }
  148. if ((Convert.ToDecimal(this.txtTargetTask.Text.Trim()) + Convert.ToDecimal(this.lblAssignTargetTask.Text.Trim())) > Convert.ToDecimal(this.lblMinTeamTargetTask.Text.Trim()))
  149. { MessageBoxCustom.Show("活动的所有大队总目标任务不能大于活动目标任务!"); return; }
  150. if ((Convert.ToDecimal(this.txtSprintTask.Text.Trim()) + Convert.ToDecimal(this.lblAssignSprintTask.Text.Trim())) > Convert.ToDecimal(this.lblMinTeamSprintTask.Text.Trim()))
  151. { MessageBoxCustom.Show("活动的所有大队总冲刺任务不能大于活动冲刺任务!"); return; }
  152. model = new Model.Model_ErpTeamMaxTaskSet();
  153. model.Tmxt_Number = "MXT_" + LYFZ.WinAPI.CustomPublicMethod.GenerateId().ToString().Trim();
  154. model.Tmxt_TasNumber = this.cmbtreevActivityName.Tag.ToString().Trim();
  155. model.Tmxt_TmxnNumber = this.cmbtreevMaxTeamName.Tag.ToString().Trim();
  156. model.Tmxt_BaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim());
  157. model.Tmxt_TargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim());
  158. model.Tmxt_SprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim());
  159. model.Tmxt_CreateDateTime = StrTime;
  160. model.Tmxt_CreateName = StrUserID;
  161. if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  162. { return; }
  163. if (tmtsbll.Add(model))
  164. {
  165. this.IsSaveed = true;
  166. MessageBoxCustom.Show("添加成功!");
  167. this.btnNew_Click(this, null);
  168. }
  169. else
  170. { MessageBoxCustom.Show("添加失败!"); return; }
  171. }
  172. else
  173. {
  174. decimal deBaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim());
  175. decimal deTargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim());
  176. decimal deSprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim());
  177. 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];
  178. if (dt.Rows.Count > 0)
  179. {
  180. deBaodiTask += Convert.ToDecimal(dt.Rows[0]["Tmxt_BaodiTask"]);
  181. deTargetTask += Convert.ToDecimal(dt.Rows[0]["Tmxt_TargetTask"]);
  182. deSprintTask += Convert.ToDecimal(dt.Rows[0]["Tmxt_SprintTask"]);
  183. }
  184. if (deBaodiTask > Convert.ToDecimal(this.lblMinTeamBaodiTask.Text.Trim()))
  185. { MessageBoxCustom.Show("活动的所有大队总保底任务不能大于活动保底任务!"); return; }
  186. if (deTargetTask > Convert.ToDecimal(this.lblMinTeamTargetTask.Text.Trim()))
  187. { MessageBoxCustom.Show("活动的所有大队总目标任务不能大于活动目标任务!"); return; }
  188. if (deSprintTask > Convert.ToDecimal(this.lblMinTeamSprintTask.Text.Trim()))
  189. { MessageBoxCustom.Show("活动的所有大队总冲刺任务不能大于活动冲刺任务!"); return; }
  190. model = tmtsbll.GetModel(this.IntClickID);
  191. model.Tmxt_BaodiTask = Convert.ToDecimal(this.txtBaodiTask.Text.Trim());
  192. model.Tmxt_TargetTask = Convert.ToDecimal(this.txtTargetTask.Text.Trim());
  193. model.Tmxt_SprintTask = Convert.ToDecimal(this.txtSprintTask.Text.Trim());
  194. model.Tmxt_UpdateDateTime = StrTime;
  195. model.Tmxt_UpdateName = StrUserID;
  196. if (MessageBoxCustom.Show("您确定要修改吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  197. { return; }
  198. if (tmtsbll.Update(model))
  199. {
  200. this.IsSaveed = true;
  201. MessageBoxCustom.Show("修改成功!");
  202. }
  203. else
  204. { MessageBoxCustom.Show("修改失败!"); return; }
  205. }
  206. this.AddMaxTeamSmallForm_Load(this, null);
  207. this.cmbtreevActivityName_ComboBoxTree_NodeMouseClick(this, null);
  208. }
  209. /// <summary>
  210. /// 删除
  211. /// </summary>
  212. /// <param name="sender"></param>
  213. /// <param name="e"></param>
  214. void btnDelete_Click(object sender, EventArgs e)
  215. {
  216. if (this.IntClickID > 0)
  217. {
  218. DataTable dt = orbll.GetView_Custom("tb_ErpTeamMaxTaskSet", StrWhere: "ID = '" + this.IntClickID + "'", ShowColumnName: "Tmxt_Number").Tables[0];
  219. if (dt.Rows.Count > 0)
  220. {
  221. dt = orbll.GetView_Custom("tb_ErpTeamMinTaskSet", StrWhere: "Tmit_TmxtNumber = '" + dt.Rows[0]["Tmxt_Number"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0];
  222. if (dt.Rows.Count > 0)
  223. { MessageBoxCustom.Show("此大队名称已设置了小组,不能删除!"); return; }
  224. }
  225. if (MessageBoxCustom.Show("您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  226. {
  227. if (tmtsbll.Delete(this.IntClickID))
  228. {
  229. this.IsSaveed = true;
  230. MessageBoxCustom.Show("删除成功!");
  231. this.AddMaxTeamSmallForm_Load(this, null);
  232. this.btnNew_Click(this, null);
  233. }
  234. else
  235. { MessageBoxCustom.Show("删除失败!"); }
  236. }
  237. }
  238. else
  239. { MessageBoxCustom.Show("请选择你要删除的大队!"); }
  240. }
  241. /// <summary>
  242. /// 关闭
  243. /// </summary>
  244. /// <param name="sender"></param>
  245. /// <param name="e"></param>
  246. void btnClose_Click(object sender, EventArgs e)
  247. {
  248. this.Close();
  249. }
  250. /// <summary>
  251. /// 选择活动
  252. /// </summary>
  253. /// <param name="sender"></param>
  254. /// <param name="e"></param>
  255. void cmbtreevActivityName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  256. {
  257. if (!string.IsNullOrEmpty(this.cmbtreevActivityName.Text.Trim()) && this.cmbtreevActivityName.Tag != null && !string.IsNullOrEmpty(this.cmbtreevActivityName.Tag.ToString().Trim()))
  258. {
  259. DataTable dt = orbll.GetView_Custom("tb_ErpTeamActiveSet", StrWhere: "Tas_Number = '" + this.cmbtreevActivityName.Tag.ToString().Trim() + "'", ShowColumnName: "Tas_BaodiTask,Tas_TargetTask,Tas_SprintTask").Tables[0];
  260. 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];
  261. if (dt.Rows.Count > 0)
  262. {
  263. this.lblMinTeamBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tas_BaodiTask"].ToString().Trim());
  264. this.lblMinTeamTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tas_TargetTask"].ToString().Trim());
  265. this.lblMinTeamSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt.Rows[0]["Tas_SprintTask"].ToString().Trim());
  266. }
  267. if (dt2.Rows.Count > 0)
  268. {
  269. this.lblAssignBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmxt_BaodiTask"].ToString().Trim());
  270. this.lblAssignTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmxt_TargetTask"].ToString().Trim());
  271. this.lblAssignSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(dt2.Rows[0]["Tmxt_SprintTask"].ToString().Trim());
  272. }
  273. }
  274. }
  275. int IntClickID = 0;
  276. /// <summary>
  277. /// 列表点击事件
  278. /// </summary>
  279. /// <param name="sender"></param>
  280. /// <param name="e"></param>
  281. void dgvData_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  282. {
  283. if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
  284. {
  285. if (this.dgvData.Rows.Count > 0)
  286. {
  287. this.IntClickID = Convert.ToInt32(this.dgvData.Rows[e.RowIndex].Cells["ID"].Value);
  288. this.cmbtreevActivityName.TagFindText(this.dgvData.Rows[e.RowIndex].Cells["活动名称编号"].Value.ToString().Trim());
  289. this.cmbtreevActivityName_ComboBoxTree_NodeMouseClick(this, null);
  290. this.cmbtreevMaxTeamName.TagFindText(this.dgvData.Rows[e.RowIndex].Cells["大队名称编号"].Value.ToString().Trim());
  291. this.txtBaodiTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(this.dgvData.Rows[e.RowIndex].Cells["保底任务"].Value);
  292. this.txtTargetTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(this.dgvData.Rows[e.RowIndex].Cells["目标任务"].Value);
  293. this.txtSprintTask.Text = LYFZ.BLL.OtherCommonModel.RemoveLastExcessZero(this.dgvData.Rows[e.RowIndex].Cells["冲刺任务"].Value);
  294. this.btnSaveed.Text = " 修 改";
  295. }
  296. }
  297. }
  298. /// <summary>
  299. /// 保底限制输入
  300. /// </summary>
  301. /// <param name="sender"></param>
  302. /// <param name="e"></param>
  303. void txtBaodiTask_KeyPress(object sender, KeyPressEventArgs e)
  304. {
  305. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  306. { e.Handled = true; }
  307. if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b')
  308. { e.Handled = true; }
  309. }
  310. /// <summary>
  311. /// 目标限制输入
  312. /// </summary>
  313. /// <param name="sender"></param>
  314. /// <param name="e"></param>
  315. void txtTargetTask_KeyPress(object sender, KeyPressEventArgs e)
  316. {
  317. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  318. { e.Handled = true; }
  319. if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b')
  320. { e.Handled = true; }
  321. }
  322. /// <summary>
  323. /// 冲刺限制输入
  324. /// </summary>
  325. /// <param name="sender"></param>
  326. /// <param name="e"></param>
  327. void txtSprintTask_KeyPress(object sender, KeyPressEventArgs e)
  328. {
  329. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  330. { e.Handled = true; }
  331. if (!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]") && e.KeyChar != ' ' && e.KeyChar != '\b')
  332. { e.Handled = true; }
  333. }
  334. }
  335. }