frmBasePrdcrDept.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. using CoreFS.CA06;
  10. using Core.Mes.Client.Comm.Control;
  11. using System.Collections;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Core.StlMes.Client.SaleComm;
  14. using Core.Mes.Client.Comm.Tool;
  15. using Core.Mes.Client.Comm.Server;
  16. namespace Core.StlMes.Client.SaleOrder
  17. {
  18. public partial class frmBasePrdcrDept : FrmBase
  19. {
  20. public frmBasePrdcrDept()
  21. {
  22. InitializeComponent();
  23. }
  24. private int _num = 1;
  25. string pdeptno = "";
  26. public override void ToolBar_Click(object sender, string ToolbarKey)
  27. {
  28. switch (ToolbarKey)
  29. {
  30. case "doQuery":
  31. this.Query();
  32. break;
  33. case "doAdd":
  34. this.Save();
  35. break;
  36. case "doDelete":
  37. this.doDelete();
  38. break;
  39. case "doClose":
  40. this.Close();
  41. break;
  42. }
  43. }
  44. public void doDelete()
  45. {
  46. ArrayList parent = new ArrayList();
  47. ArrayList child = new ArrayList();
  48. ultraGrid1.UpdateData();
  49. int flag = 0;
  50. foreach (UltraGridRow row in ultraGrid1.Rows)
  51. {
  52. if (row.Cells["XZ"].Value.ToString().ToUpper() == "TRUE")
  53. {
  54. parent.Add(row.Cells["PDEPT_NO"].Value.ToString());
  55. flag += 1;
  56. }
  57. foreach (UltraGridRow crow in row.ChildBands[0].Rows)
  58. {
  59. if (crow.Cells["XZ"].Value.ToString().ToUpper() == "TRUE")
  60. {
  61. ArrayList list = new ArrayList();
  62. list.Add(crow.Cells["PDEPT_NO"].Value.ToString());
  63. list.Add(crow.Cells["PDEPT_NO_SQE"].Value.ToString());
  64. child.Add(list);
  65. flag += 1;
  66. }
  67. }
  68. }
  69. if (flag == 0)
  70. {
  71. MessageUtil.ShowWarning("请选择您要删除的记录");
  72. return;
  73. }
  74. if (MessageBox.Show("数据删除将无法恢复!是否要进行删除操作?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  75. {
  76. return;
  77. }
  78. int count = ServerHelper.SetData("com.steering.pss.sale.base.CoreBasePrdcrDept.delete", new object[] { parent, child }, this.ob);
  79. if (count > 0)
  80. {
  81. MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  82. Query();
  83. }
  84. }
  85. public void Save()
  86. {
  87. ultraGrid1.UpdateData();
  88. ArrayList addList = new ArrayList();
  89. ArrayList updateList = new ArrayList();
  90. ArrayList addListc = new ArrayList();
  91. ArrayList updateListc = new ArrayList();
  92. int flag = 0;
  93. foreach (UltraGridRow row in ultraGrid1.Rows)
  94. {
  95. if (row.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") //勾选了主表
  96. {
  97. ArrayList list = new ArrayList();
  98. if (row.Cells["PDEPT_NO"].Value.ToString().Contains("A")) //新增
  99. {
  100. if (row.Cells["PDEPT_NAME"].Value.ToString() == "")
  101. {
  102. MessageUtil.ShowWarning("请输入监制单位!");
  103. return;
  104. }
  105. list.Add(row.Cells["PDEPT_NO"].Value.ToString());
  106. list.Add(row.Cells["PDEPT_NAME"].Value.ToString());
  107. list.Add(row.Cells["PHONE"].Value.ToString());
  108. list.Add(row.Cells["PDEPT_FILE"].Value.ToString());
  109. list.Add(row.Cells["MEMO"].Value.ToString());
  110. addList.Add(list);
  111. }
  112. else //修改 以D开头的编号
  113. {
  114. if (row.Cells["PDEPT_NAME"].Value.ToString() == "")
  115. {
  116. MessageUtil.ShowWarning("请输入监制单位!");
  117. return;
  118. }
  119. list.Add(row.Cells["PDEPT_NO"].Value.ToString());
  120. list.Add(row.Cells["PDEPT_NAME"].Value.ToString());
  121. list.Add(row.Cells["PHONE"].Value.ToString());
  122. list.Add(row.Cells["PDEPT_FILE"].Value.ToString());
  123. list.Add(row.Cells["MEMO"].Value.ToString());
  124. updateList.Add(list);
  125. }
  126. flag += 1;
  127. }
  128. foreach (UltraGridRow crow in row.ChildBands[0].Rows)
  129. {
  130. if (crow.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") //勾选了子表
  131. {
  132. ArrayList list = new ArrayList();
  133. if (crow.Cells["PDEPT_NO"].Value.ToString().Contains("A") && row.Cells["XZ"].Value.ToString().ToUpper() == "TRUE") //新增
  134. {
  135. if (crow.Cells["NAME_"].Value.ToString() == "")
  136. {
  137. MessageUtil.ShowWarning("请输入监制人姓名!");
  138. return;
  139. }
  140. if (crow.Cells["PHONE"].Value.ToString() == "")
  141. {
  142. MessageUtil.ShowWarning("请输入监制人电话号码!");
  143. return;
  144. }
  145. list.Add(crow.Cells["PDEPT_NO"].Value.ToString());
  146. list.Add(row.Cells["PDEPT_NAME"].Value.ToString());
  147. list.Add(crow.Cells["NAME_"].Value.ToString());
  148. list.Add(crow.Cells["SEX_"].Value.ToString());
  149. list.Add(crow.Cells["AGE_"].Value.ToString());
  150. list.Add(crow.Cells["PHONE"].Value.ToString());
  151. list.Add(crow.Cells["MEMO"].Value.ToString());
  152. addListc.Add(list);
  153. }
  154. else //修改 以D开头的编号
  155. {
  156. if (crow.Cells["PDEPT_NO_SQE"].Value.ToString() == "") //新增
  157. {
  158. if (crow.Cells["NAME_"].Value.ToString() == "")
  159. {
  160. MessageUtil.ShowWarning("请输入监制人姓名!");
  161. return;
  162. }
  163. if (crow.Cells["PHONE"].Value.ToString() == "")
  164. {
  165. MessageUtil.ShowWarning("请输入监制人电话号码!");
  166. return;
  167. }
  168. list.Add(crow.Cells["PDEPT_NO"].Value.ToString());
  169. list.Add(row.Cells["PDEPT_NAME"].Value.ToString());
  170. list.Add(crow.Cells["NAME_"].Value.ToString());
  171. list.Add(crow.Cells["SEX_"].Value.ToString());
  172. list.Add(crow.Cells["AGE_"].Value.ToString());
  173. list.Add(crow.Cells["PHONE"].Value.ToString());
  174. list.Add(crow.Cells["MEMO"].Value.ToString());
  175. addListc.Add(list);
  176. }
  177. else
  178. {
  179. if (crow.Cells["NAME_"].Value.ToString() == "")
  180. {
  181. MessageUtil.ShowWarning("请输入监制人姓名!");
  182. return;
  183. }
  184. if (crow.Cells["PHONE"].Value.ToString() == "")
  185. {
  186. MessageUtil.ShowWarning("请输入监制人电话号码!");
  187. return;
  188. }
  189. //list.Add(row.Cells["PDEPT_NO"].Value.ToString());
  190. list.Add(crow.Cells["PDEPT_NO_SQE"].Value.ToString());
  191. list.Add(row.Cells["PDEPT_NAME"].Value.ToString());
  192. list.Add(crow.Cells["NAME_"].Value.ToString());
  193. list.Add(crow.Cells["SEX_"].Value.ToString());
  194. list.Add(crow.Cells["AGE_"].Value.ToString());
  195. list.Add(crow.Cells["PHONE"].Value.ToString());
  196. list.Add(crow.Cells["MEMO"].Value.ToString());
  197. updateListc.Add(list);
  198. }
  199. }
  200. flag += 1;
  201. }
  202. }
  203. }
  204. if (flag == 0)
  205. {
  206. MessageUtil.ShowWarning("请选择您要保存的记录!");
  207. return;
  208. }
  209. int count = ServerHelper.SetData("com.steering.pss.sale.base.CoreBasePrdcrDept.save", new object[] { addList, addListc, updateList, updateListc, UserInfo.GetUserName() }, this.ob);
  210. if (count > 0)
  211. {
  212. MessageUtil.ShowTips("保存成功!");
  213. Query();
  214. }
  215. }
  216. public void Query()
  217. {
  218. DataTable dt = Globals.GetData("com.steering.pss.sale.base.CoreBasePrdcrDept.baseDeptMainQuery", new Object[] { }, this.ob);
  219. GridHelper.CopyDataToDatatable(ref dt, ref this.DeptMain, true);
  220. DataTable ds = Globals.GetData("com.steering.pss.sale.base.CoreBasePrdcrDept.baseDeptTailQuery", new Object[] { }, this.ob);
  221. GridHelper.CopyDataToDatatable(ref ds, ref this.DeptTail, true);
  222. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  223. {
  224. ultraGrid1.Rows[i].Cells["PHONE"].Activation = Activation.ActivateOnly;
  225. ultraGrid1.Rows[i].Cells["PDEPT_FILE"].Activation = Activation.ActivateOnly;
  226. ultraGrid1.Rows[i].Cells["MEMO"].Activation = Activation.ActivateOnly;
  227. ultraGrid1.Rows[i].Cells["PDEPT_NAME"].Activation = Activation.ActivateOnly;
  228. }
  229. }
  230. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  231. {
  232. ultraGrid1.UpdateData();
  233. if (e.Cell.Column.Key.Equals("XZ"))
  234. {
  235. if (e.Cell.Row.HasParent())
  236. {
  237. if (Convert.ToBoolean(e.Cell.Value))
  238. {
  239. e.Cell.Row.Cells["NAME_"].Activation = Activation.AllowEdit;
  240. e.Cell.Row.Cells["SEX_"].Activation = Activation.AllowEdit;
  241. e.Cell.Row.Cells["AGE_"].Activation = Activation.AllowEdit;
  242. e.Cell.Row.Cells["PHONE"].Activation = Activation.AllowEdit;
  243. e.Cell.Row.Cells["MEMO"].Activation = Activation.AllowEdit;
  244. e.Cell.Row.Cells["PDEPT_NO"].Activation = Activation.AllowEdit;
  245. }
  246. else
  247. {
  248. e.Cell.Row.Cells["NAME_"].Activation = Activation.ActivateOnly;
  249. e.Cell.Row.Cells["SEX_"].Activation = Activation.ActivateOnly;
  250. e.Cell.Row.Cells["AGE_"].Activation = Activation.ActivateOnly;
  251. e.Cell.Row.Cells["PHONE"].Activation = Activation.ActivateOnly;
  252. e.Cell.Row.Cells["MEMO"].Activation = Activation.ActivateOnly;
  253. e.Cell.Row.Cells["PDEPT_NO"].Activation = Activation.ActivateOnly;
  254. }
  255. }
  256. else
  257. {
  258. if (Convert.ToBoolean(e.Cell.Value))
  259. {
  260. e.Cell.Row.Cells["PHONE"].Activation = Activation.AllowEdit;
  261. e.Cell.Row.Cells["PDEPT_FILE"].Activation = Activation.AllowEdit;
  262. e.Cell.Row.Cells["MEMO"].Activation = Activation.AllowEdit;
  263. e.Cell.Row.Cells["PDEPT_NAME"].Activation = Activation.AllowEdit;
  264. }
  265. else
  266. {
  267. e.Cell.Row.Cells["PHONE"].Activation = Activation.ActivateOnly;
  268. e.Cell.Row.Cells["PDEPT_FILE"].Activation = Activation.ActivateOnly;
  269. e.Cell.Row.Cells["MEMO"].Activation = Activation.ActivateOnly;
  270. e.Cell.Row.Cells["PDEPT_NAME"].Activation = Activation.ActivateOnly;
  271. }
  272. }
  273. }
  274. }
  275. private void txtPrdcrFile_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  276. {
  277. if (e.Button.Key == "DownLoad")//下载
  278. {
  279. frmOrderDeptinfo stu = new frmOrderDeptinfo();
  280. stu.oPbc = this.ob;
  281. stu.index = ultraGrid1.ActiveRow.Cells["PDEPT_NO"].Text;
  282. stu.ShowDialog();
  283. }
  284. else//上传
  285. {
  286. string sFileName = "Image/pss/sale/order/ORD_PK/ORD_LN_PK/Dept/" + ultraGrid1.ActiveRow.Cells["PDEPT_NO"].Text;
  287. this.txtPrdcrFile.Text = sFileName;
  288. FlileUploadcomm.FlileUpload(sFileName);
  289. }
  290. }
  291. private void frmBasePrdcrDept_Load(object sender, EventArgs e)
  292. {
  293. ClsBaseInfo.SetComboItemHeight(ultraComboSex);
  294. }
  295. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  296. {
  297. UltraGridRow ugr = ultraGrid1.ActiveRow;
  298. if (ugr.HasParent())
  299. {
  300. if (ugr.Cells["XZ"].Value.ToString().ToUpper() == "TRUE")
  301. {
  302. ugr.Cells["SEX_"].Activation = Activation.AllowEdit;
  303. ugr.Cells["NAME_"].Activation = Activation.AllowEdit;
  304. ugr.Cells["AGE_"].Activation = Activation.AllowEdit;
  305. ugr.Cells["PHONE"].Activation = Activation.AllowEdit;
  306. ugr.Cells["MEMO"].Activation = Activation.AllowEdit;
  307. }
  308. else
  309. {
  310. ugr.Cells["SEX_"].Activation = Activation.ActivateOnly;
  311. ugr.Cells["NAME_"].Activation = Activation.ActivateOnly;
  312. ugr.Cells["AGE_"].Activation = Activation.ActivateOnly;
  313. ugr.Cells["PHONE"].Activation = Activation.ActivateOnly;
  314. ugr.Cells["MEMO"].Activation = Activation.ActivateOnly;
  315. }
  316. }
  317. }
  318. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  319. {
  320. ultraGrid1.UpdateData();
  321. string pdeptnoStr = "";
  322. if (!e.Row.HasChild() && !e.Row.HasParent())
  323. {
  324. if (!pdeptno.Equals(""))
  325. {
  326. int number = int.Parse(pdeptno.Substring(1, 4));
  327. pdeptnoStr = "A" + string.Format("{0:0000}", number + 1);
  328. _num = number + 1;
  329. }
  330. else
  331. {
  332. pdeptnoStr = "A" + string.Format("{0:0000}", _num);
  333. _num = _num + 1;
  334. }
  335. e.Row.Cells["PDEPT_NO"].Value = pdeptnoStr;
  336. pdeptno = pdeptnoStr;
  337. }
  338. ultraGrid1.UpdateData();
  339. }
  340. }
  341. }