OrderExtractIntoItemEx.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Collections;
  10. namespace LYFZ.ComponentLibrary
  11. {
  12. public partial class OrderExtractIntoItemEx : UserControl
  13. {
  14. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  15. LYFZ.BLL.BLL_ErpOrderDigital dbll = new LYFZ.BLL.BLL_ErpOrderDigital();
  16. LYFZ.BLL.BLL_ErpPieceCommissionRecords pcrsbll = new BLL.BLL_ErpPieceCommissionRecords();
  17. public OrderExtractIntoItemEx(object objValue)
  18. {
  19. InitializeComponent();
  20. this.cmbtreevItemName.ComboBoxTree_NodeMouseClick += cmbtreevItemName_ComboBoxTree_NodeMouseClick;
  21. this.labelEx1.ForeColor = UIBlueThemeResources.TitleTextColor;
  22. Hashtable htData = (Hashtable)objValue;
  23. this.StrOrdNumber = htData["StrOrdNumber"].ToString();
  24. this.StrOrdViceNumber = htData["StrOrdViceNumber"].ToString();
  25. this.StrType = htData["StrType"].ToString();
  26. this.StrUsrID = htData["StrUsrID"].ToString();
  27. this.btnAdd.Click += btnAdd_Click;
  28. this.btnDelete.Click += btnDelete_Click;
  29. this.txtQuantity.KeyPress += txtQuantity_KeyPress;
  30. this.GetData();
  31. this.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbtreevDeductPercentagePeople, (DataTable)htData["tblDepartment"], (DataTable)htData["tblUser"]);
  32. this.BindComboBoxTreeView_SystemCategory("BEBBBABBEBAIHGDCB", this.cmbtreevItemName);
  33. this.cmbtreevDeductPercentagePeople.Nodes[0].ExpandAll();
  34. if (string.IsNullOrEmpty(processName) || processName != "精修")
  35. {
  36. DataTable dt = orbll.GetView_Custom("tb_ErpOrderDigital", StrWhere: "Ordv_ViceNumber = '" + this.StrOrdViceNumber + "'", ShowColumnName: "Ordv_IntoBottomQuantity,Ordv_IntoBottomQuantityPackage,Ordv_IntoBottomAddPickQuantity").Tables[0];
  37. if (dt.Rows.Count > 0)
  38. {
  39. IntoBottomQuantity = Convert.ToInt32(dt.Rows[0]["Ordv_IntoBottomQuantity"]);
  40. if (IntoBottomQuantity >= 0)
  41. {
  42. IntoBottomQuantity += Convert.ToInt32(dt.Rows[0]["Ordv_IntoBottomQuantityPackage"]);
  43. IntoBottomQuantity += Convert.ToInt32(dt.Rows[0]["Ordv_IntoBottomAddPickQuantity"]);
  44. }
  45. }
  46. }
  47. }
  48. public string processName
  49. {
  50. get;
  51. set;
  52. }
  53. string _strUsrID;
  54. /// <summary>
  55. /// 当前登录者ID
  56. /// </summary>
  57. public string StrUsrID
  58. {
  59. get { return _strUsrID; }
  60. set { _strUsrID = value; }
  61. }
  62. string _strOrdNumber;
  63. /// <summary>
  64. /// 订单号
  65. /// </summary>
  66. string StrOrdNumber
  67. {
  68. get { return _strOrdNumber; }
  69. set { _strOrdNumber = value; }
  70. }
  71. string _strOrdViceNumber;
  72. /// <summary>
  73. /// 订单号
  74. /// </summary>
  75. string StrOrdViceNumber
  76. {
  77. get { return _strOrdViceNumber; }
  78. set { _strOrdViceNumber = value; }
  79. }
  80. string _strType;
  81. /// <summary>
  82. /// 计件提成类型
  83. /// </summary>
  84. string StrType
  85. {
  86. get { return _strType; }
  87. set { _strType = value; }
  88. }
  89. int _IntoBottomQuantity = 0;
  90. /// <summary>
  91. /// 入底数量
  92. /// </summary>
  93. public int IntoBottomQuantity
  94. {
  95. get { return _IntoBottomQuantity; }
  96. set { _IntoBottomQuantity = value; }
  97. }
  98. string _StrSightsName;
  99. public string StrSightsName
  100. {
  101. get
  102. {
  103. return _StrSightsName;
  104. }
  105. set
  106. {
  107. _StrSightsName = value;
  108. }
  109. }
  110. public List<Helper.CommandInfo> Getdgvclist()
  111. {
  112. DataTable tbl = GetDataTablePieceCommissionRecords();
  113. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  114. for (int i = 0; i < tbl.Rows.Count; i++)
  115. {
  116. bool isFind = false;
  117. for (int j = 0; j < this.dgvData.Rows.Count; j++)
  118. {
  119. if (this.dgvData.Rows[j].Cells["ID"].Value.ToString().Trim() != "")
  120. {
  121. if (this.dgvData.Rows[j].Cells["ID"].Value.ToString().Trim() == tbl.Rows[i]["ID"].ToString().Trim())
  122. { isFind = true; break; }
  123. }
  124. }
  125. if (!isFind)
  126. { clist.Add(pcrsbll.GetDeleteCommandInfo("ID", "=", tbl.Rows[i]["ID"])); }
  127. }
  128. if (this.dgvData.Rows.Count > 0)
  129. {
  130. LYFZ.Model.Model_ErpPieceCommissionRecords model = null;
  131. DateTime StrTime = SDateTime.Now;
  132. for (int j = 0; j < this.dgvData.Rows.Count; j++)
  133. {
  134. if (this.dgvData.Rows[j].Cells["ID"].Value.ToString().Trim() == "")
  135. {
  136. model = new Model.Model_ErpPieceCommissionRecords();
  137. model.Pcr_DividedShop = LYFZ.BLL.OrderPayment_Member.StrInfoID;
  138. model.Pcr_OrderNumber = this.StrOrdNumber;
  139. model.Pcr_DigitalDivision = this.dgvData.Rows[j].Cells["提成人编号"].Value.ToString().Trim();
  140. model.Pcr_Date = Convert.ToDateTime(this.dgvData.Rows[j].Cells["日期"].Value);
  141. model.Pcr_CompletionContents = this.dgvData.Rows[j].Cells["项目编号"].Value.ToString().Trim();
  142. model.Pcr_Quantity = Convert.ToInt32(this.dgvData.Rows[j].Cells["数量"].Value);
  143. model.Pcr_Type = Convert.ToInt32(this.StrType);
  144. model.Pcr_MarkKey = "";
  145. model.Pcr_CreateTime = StrTime;
  146. model.Pcr_EntryPeople = StrUsrID;
  147. model.Pcr_OrderSource = "订单";
  148. model.Pcr_OrderDigNumber = this.StrOrdViceNumber;
  149. clist.Add(pcrsbll.GetAddCommandInfo(model));
  150. }
  151. }
  152. }
  153. return clist;
  154. }
  155. /// <summary>
  156. /// 更新实际计件提成数量
  157. /// </summary>
  158. /// <param name="dirType"></param>
  159. public void SetServicePhotographCount(LYFZ.Model.Model_ErpOrder.DirectoryType dirType)
  160. {
  161. pcrsbll.SetServicePhotographCount(dirType,this.StrOrdNumber,this.StrOrdViceNumber,this.StrSightsName,this.StrType);
  162. }
  163. /// <summary>
  164. /// 绑定
  165. /// </summary>
  166. /// <returns></returns>
  167. DataTable GetDataTablePieceCommissionRecords()
  168. { return orbll.GetView_Custom("tb_ErpPieceCommissionRecords Left Join tb_ErpSystemCategory on Sc_ClassCode = Pcr_CompletionContents Left Join tb_ErpUser on User_EmployeeID = Pcr_DigitalDivision", StrWhere: "Pcr_OrderNumber = '" + StrOrdNumber + "' and Pcr_Type = '" + StrType + "'", filedOrder: "Pcr_Date DESC", ShowColumnName: "tb_ErpPieceCommissionRecords.ID, Pcr_CompletionContents AS 项目编号, Sc_ClassName AS 项目名称,Pcr_Quantity AS 数量,Pcr_DigitalDivision AS 提成人编号, User_Name AS 提成人, Pcr_Date AS 日期").Tables[0]; }
  169. /// <summary>
  170. /// 获取数据并绑定
  171. /// </summary>
  172. void GetData()
  173. {
  174. DataTable tbl = GetDataTablePieceCommissionRecords();
  175. this.dgvData.DataColumns(tbl.Columns, "ID,提成人编号,项目编号");
  176. DataGridViewCell cell = null;
  177. for (int i = 0; i < tbl.Rows.Count; i++)
  178. {
  179. DataGridViewRow dgvr = new DataGridViewRow();
  180. cell = new DataGridViewTextBoxCell();
  181. cell.Value = tbl.Rows[i]["ID"].ToString().Trim();
  182. dgvr.Cells.Add(cell);
  183. cell = new DataGridViewTextBoxCell();
  184. cell.Value = tbl.Rows[i]["项目编号"].ToString().Trim();
  185. dgvr.Cells.Add(cell);
  186. cell = new DataGridViewTextBoxCell();
  187. cell.Value = tbl.Rows[i]["项目名称"].ToString().Trim();
  188. dgvr.Cells.Add(cell);
  189. cell = new DataGridViewTextBoxCell();
  190. cell.Value = Convert.ToInt32(tbl.Rows[i]["数量"]);
  191. dgvr.Cells.Add(cell);
  192. cell = new DataGridViewTextBoxCell();
  193. cell.Value = tbl.Rows[i]["提成人编号"].ToString().Trim();
  194. dgvr.Cells.Add(cell);
  195. cell = new DataGridViewTextBoxCell();
  196. cell.Value = tbl.Rows[i]["提成人"].ToString().Trim();
  197. dgvr.Cells.Add(cell);
  198. cell = new DataGridViewTextBoxCell();
  199. cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(tbl.Rows[i]["日期"], "yyyy-MM-dd HH:mm:ss");
  200. dgvr.Cells.Add(cell);
  201. this.dgvData.Rows.Add(dgvr);
  202. }
  203. this.dgvData.Columns["项目名称"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
  204. this.dgvData.Columns["数量"].Width = 60;
  205. this.dgvData.Columns["提成人"].Width = 80;
  206. this.dgvData.Columns["日期"].Width = 125;
  207. }
  208. /// <summary>
  209. /// 添加
  210. /// </summary>
  211. /// <param name="sender"></param>
  212. /// <param name="e"></param>
  213. void btnAdd_Click(object sender, EventArgs e)
  214. {
  215. if (string.IsNullOrEmpty(this.cmbtreevItemName.Text.Trim()))
  216. { MessageBoxCustom.Show("项目不能为空!"); return; }
  217. if (string.IsNullOrEmpty(this.txtQuantity.Text.Trim()))
  218. { MessageBoxCustom.Show("数量不能为空!"); return; }
  219. if (string.IsNullOrEmpty(this.cmbtreevDeductPercentagePeople.Text.Trim()))
  220. { MessageBoxCustom.Show("提成人不能为空!"); return; }
  221. if (string.IsNullOrEmpty(this.dtpDate.DateValue.Trim()))
  222. { MessageBoxCustom.Show("日期不能为空!"); return; }
  223. if (this.cmbtreevItemName.Tag.ToString().Trim() == "BAAGAAI")
  224. {
  225. if (this.IntoBottomQuantity >= 0 && this.txtQuantity.Text.Trim().Length > 0)
  226. {
  227. if (this.IntoBottomQuantity < Convert.ToInt32(this.txtQuantity.Text))
  228. { MessageBoxCustom.Show("精修张数不能大于入底数量,入底数量为:" + this.IntoBottomQuantity); return; }
  229. }
  230. }
  231. DataGridViewRow dgvr = new DataGridViewRow();
  232. dgvr.DefaultCellStyle.ForeColor = Color.Red;
  233. DataGridViewCell cell = null;
  234. cell = new DataGridViewTextBoxCell();
  235. cell.Value = "";
  236. dgvr.Cells.Add(cell);
  237. cell = new DataGridViewTextBoxCell();
  238. cell.Value = this.cmbtreevItemName.Tag.ToString().Trim();
  239. dgvr.Cells.Add(cell);
  240. cell = new DataGridViewTextBoxCell();
  241. cell.Value = this.cmbtreevItemName.Text.Trim();
  242. dgvr.Cells.Add(cell);
  243. cell = new DataGridViewTextBoxCell();
  244. cell.Value = this.txtQuantity.Text.Trim();
  245. dgvr.Cells.Add(cell);
  246. cell = new DataGridViewTextBoxCell();
  247. cell.Value = this.cmbtreevDeductPercentagePeople.Tag.ToString().Trim();
  248. dgvr.Cells.Add(cell);
  249. cell = new DataGridViewTextBoxCell();
  250. cell.Value = this.cmbtreevDeductPercentagePeople.Text.Trim();
  251. dgvr.Cells.Add(cell);
  252. cell = new DataGridViewTextBoxCell();
  253. cell.Value = LYFZ.Command.Command_Validate.DateTimeToString(this.dtpDate.DateTimeValue, "yyyy-MM-dd HH:mm:ss");
  254. dgvr.Cells.Add(cell);
  255. this.dgvData.Rows.Add(dgvr);
  256. this.cmbtreevItemName.SetTextAndTag_ValueNull();
  257. }
  258. /// <summary>
  259. /// 删除
  260. /// </summary>
  261. /// <param name="sender"></param>
  262. /// <param name="e"></param>
  263. void btnDelete_Click(object sender, EventArgs e)
  264. {
  265. if (this.dgvData.Rows.Count > 0)
  266. {
  267. if (MessageBoxCustom.Show("删除后则不能恢复回来!您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  268. { return; }
  269. this.dgvData.Rows.Remove(this.dgvData.CurrentRow);
  270. }
  271. }
  272. /// <summary>
  273. /// 限制输入
  274. /// </summary>
  275. /// <param name="sender"></param>
  276. /// <param name="e"></param>
  277. void txtQuantity_KeyPress(object sender, KeyPressEventArgs e)
  278. {
  279. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  280. { e.Handled = true; }
  281. }
  282. /// <summary>
  283. /// 选择工作内容选择事件
  284. /// </summary>
  285. /// <param name="sender"></param>
  286. /// <param name="e"></param>
  287. void cmbtreevItemName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  288. {
  289. //if (this.cmbtreevItemName.Tag.ToString().Trim() == "BAAGAAI")
  290. //{
  291. // if (this.IntoBottomQuantity > 0 && this.txtQuantity.Text.Trim().Length>0)
  292. // {
  293. // if (this.IntoBottomQuantity < Convert.ToInt32(this.txtQuantity.Text))
  294. // {
  295. // MessageBoxCustom.Show("");
  296. // }
  297. // }
  298. //}
  299. }
  300. #region 部门与人员绑定
  301. /// <summary>
  302. /// 部门、员工绑定
  303. /// </summary>
  304. /// <param name="cmbtreev">控件</param>
  305. /// <param name="IsFirstNodeNull">第一节点是否为空</param>
  306. void BindComboBoxTreeView_DepartmentAndEmployee(LYFZ.ComponentLibrary.ComboBoxTreeViewEx cmbtreev, DataTable tbl, DataTable tbl_user, bool IsFirstNodeNull = false)
  307. {
  308. TreeNode root = null;
  309. cmbtreev.Nodes.Clear();
  310. for (int i = 0; i < tbl.Rows.Count; i++)
  311. {
  312. if (i == 0)
  313. {
  314. if (IsFirstNodeNull)
  315. {
  316. root = new TreeNode(" ");
  317. root.Tag = "";
  318. root.Name = "";
  319. cmbtreev.Nodes.Add(root);
  320. }
  321. }
  322. DataRow[] dtRow = tbl_user.Select("User_Department='" + tbl.Rows[i]["ID"].ToString().Trim() + "'");
  323. if (dtRow.Length <= 0)
  324. { continue; }
  325. root = new TreeNode(tbl.Rows[i]["Dt_Name"].ToString());
  326. root.Tag = tbl.Rows[i]["ID"].ToString().Trim();
  327. root.Name = "Department";
  328. CreateTreeViewDepartmentUser(root, tbl.Rows[i]["ID"].ToString(), tbl_user);
  329. cmbtreev.TreeView.Nodes.Add(root);
  330. }
  331. }
  332. /// <summary>
  333. /// 绑定第二级人员
  334. /// </summary>
  335. /// <param name="nodes">TreeView的节点集合</param>
  336. /// <param name="dataSource">数据源</param>
  337. /// <param name="parentid"></param>
  338. void CreateTreeViewDepartmentUser(TreeNode nodes, string ClassCode, DataTable tbl_user)
  339. {
  340. if (ClassCode != "")
  341. {
  342. DataRow[] dtRow = tbl_user.Select("User_Department='" + ClassCode + "' and User_Status = '在职'");
  343. if (dtRow.Length > 0)
  344. {
  345. TreeNode node;
  346. for (int i = 0; i < dtRow.Length; i++)
  347. {
  348. node = new TreeNode();
  349. node.Text = dtRow[i]["User_Name"].ToString();
  350. node.Tag = dtRow[i]["User_EmployeeID"].ToString();
  351. node.Name = "User";
  352. nodes.Nodes.Add(node);
  353. if(this.StrUsrID== node.Tag.ToString())
  354. {
  355. nodes.Expand();
  356. this.cmbtreevDeductPercentagePeople.SelectedNode = node;
  357. this.cmbtreevDeductPercentagePeople.Text = node.Text;
  358. this.cmbtreevDeductPercentagePeople.Tag = node.Tag;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. #endregion
  365. #region 系统类别设置绑定
  366. /// <summary>
  367. /// 系统设置的绑定数据
  368. /// </summary>
  369. /// <param name="StrParentCode">系统类别中的Sc_ClassCode值</param>
  370. /// <param name="cmbtreev">当前下拉树</param>
  371. /// <param name="IsFirstNodeNull">第一节点是否为空</param>
  372. void BindComboBoxTreeView_SystemCategory(string StrParentCode, LYFZ.ComponentLibrary.ComboBoxTreeViewEx cmbtreev, bool IsFirstNodeNull = false)
  373. {
  374. DataTable tbl = new BLL.BLL_ErpSystemCategory().GetCategory("ID,Sc_ClassCode,Sc_ClassName,Sc_ClassParentID", "").Tables[0];
  375. cmbtreev.Nodes.Clear();
  376. DataRow[] dtRow = tbl.Select("Sc_ClassCode = '" + StrParentCode + "'");
  377. if (dtRow.Length > 0)
  378. {
  379. DataRow[] dtRow2 = tbl.Select("Sc_ClassParentID = '" + dtRow[0]["ID"].ToString().Trim() + "'");
  380. TreeNode root = null;
  381. for (int i = 0; i < dtRow2.Length; i++)
  382. {
  383. if (i == 0)
  384. {
  385. if (IsFirstNodeNull)
  386. {
  387. root = new TreeNode(" ");
  388. root.Tag = "";
  389. root.Name = "";
  390. cmbtreev.Nodes.Add(root);
  391. }
  392. }
  393. root = new TreeNode();
  394. root.Text = dtRow2[i]["Sc_ClassName"].ToString();
  395. root.Tag = dtRow2[i]["Sc_ClassCode"].ToString();
  396. root.Name = dtRow2[i]["ID"].ToString();
  397. CreateTreeViewSystemCategory(root, dtRow2[i]["ID"].ToString(), tbl);
  398. cmbtreev.TreeView.Nodes.Add(root);
  399. }
  400. }
  401. }
  402. /// <summary>
  403. /// 第二级绑定
  404. /// </summary>
  405. /// <param name="nodes">父节点</param>
  406. /// <param name="ClassParentID">父节点的ID</param>
  407. /// <param name="tbl">当前数据源</param>
  408. private static void CreateTreeViewSystemCategory(TreeNode nodes, string ClassParentID, DataTable tbl)
  409. {
  410. DataRow[] dtRow = tbl.Select("Sc_ClassParentID='" + ClassParentID + "'");
  411. if (dtRow.Length > 0)
  412. {
  413. TreeNode node;
  414. for (int i = 0; i < dtRow.Length; i++)
  415. {
  416. node = new TreeNode();
  417. node.Text = dtRow[i]["Sc_ClassName"].ToString();
  418. node.Tag = dtRow[i]["Sc_ClassCode"].ToString();
  419. node.Name = dtRow[i]["ID"].ToString();
  420. nodes.Nodes.Add(node);
  421. CreateTreeViewSystemCategory(node, dtRow[i]["ID"].ToString(), tbl);
  422. }
  423. }
  424. }
  425. #endregion
  426. }
  427. }