FrmUoms.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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;using Pur.Entity;
  10. using Pur.Entity.configureEntity;
  11. using Core.Mes.Client.Comm.Control;
  12. using com.hnshituo.pur.vo;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Pur.Pop_upWindow;
  15. namespace Pur.configure
  16. {
  17. public partial class FrmUoms : FrmPmsBase
  18. {
  19. public FrmUoms()
  20. {
  21. InitializeComponent();
  22. }
  23. public override void ToolBar_Click(object sender, string ToolbarKey)
  24. {
  25. switch (ToolbarKey)
  26. {
  27. case "doQuery":
  28. try
  29. {
  30. this.Cursor = Cursors.WaitCursor;
  31. get_PurUoms();
  32. }
  33. finally
  34. {
  35. this.Cursor = Cursors.Default;
  36. }
  37. break;
  38. case "doAdd":
  39. add_PurUoms();
  40. break;
  41. case "doModify":
  42. upd_PurUoms();
  43. break;
  44. case "doDelete":
  45. del_PurUoms();
  46. break;
  47. case "Close":
  48. this.Close();
  49. break;
  50. }
  51. }
  52. /// <summary>
  53. /// 查询采购单位
  54. /// </summary>
  55. /// <param name="configureMEntity"></param>
  56. public void get_PurUoms()
  57. {
  58. PurUomsEntity UomsEntity = new PurUomsEntity();
  59. UomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE_QUERY.Text.Trim();//库存单位编码
  60. UomsEntity.UomCode = txt_UOM_CODE_QUERY.Text.Trim();//采购单位编码
  61. UomsEntity.WeightUnit = txt_WEIGHT_UNIT_QUERY.Text.Trim();//库存单位
  62. UomsEntity.UomName = txt_UOM_NAME_QUERY.Text.Trim();//采购单位名称
  63. UomsEntity.Validflag = "1";
  64. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.UomsService", "get_PurUoms", new object[] { UomsEntity });
  65. //按创建时间降序
  66. if (dt.Rows.Count > 0)
  67. {
  68. dt.DefaultView.Sort = "CREATETIME DESC";
  69. dt = dt.DefaultView.ToTable();
  70. }
  71. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);//绑定物料分类表
  72. }
  73. /// <summary>
  74. /// 增加采购单位
  75. /// </summary>
  76. /// <param name="configureMEntity"></param>
  77. public void add_PurUoms()
  78. {
  79. PurUomsEntity UomsEntity = new PurUomsEntity();
  80. UomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
  81. UomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位
  82. UomsEntity.Validflag = "1";
  83. int num = this.execute<int>("com.hnshituo.pur.configure.service.UomsService", "count", new object[] { UomsEntity });
  84. if (num>0)
  85. {
  86. MessageUtil.ShowTips("添加失败:因为已存在相同的采购单位和库存单位");
  87. return;
  88. }
  89. if (MessageUtil.ShowYesNoAndQuestion("是否确定添加?") == DialogResult.No && ValidInput())
  90. {
  91. return;
  92. }
  93. UomsEntity.UomConefficient = txt_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_UOM_CONEFFICIENT.Text);//转换系数
  94. UomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
  95. //UomsEntity.UomCode = txt_UOM_CODE.Text;//txt_UOM_CODE.Text;//采购单位编码
  96. UomsEntity.UomCode = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber", new object[] { "PUR_Uoms", "Uom_Code", txt_WEIGHT_UNIT_CODE.Text + "-", "2" });
  97. UomsEntity.CreateName = UserInfo.GetUserName();
  98. UomsEntity.CreateUserid = UserInfo.GetUserID();
  99. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.UomsService", "doInsert", new object[] { UomsEntity});
  100. if (crt.Resultcode != 0)
  101. {
  102. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  103. return;
  104. }
  105. MessageUtil.ShowTips("添加成功!");
  106. get_PurUoms();//查询采购单位
  107. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "UomCode", UomsEntity.UomCode);//激活当前行
  108. }
  109. /// <summary>
  110. /// 修改采购单位
  111. /// </summary>
  112. /// <param name="configureMEntity"></param>
  113. public void upd_PurUoms()
  114. {
  115. if (MessageUtil.ShowYesNoAndQuestion("是否确定修改?") == DialogResult.No && ValidInput())
  116. {
  117. return;
  118. }
  119. if (ultraGrid1.ActiveRow != null)
  120. {
  121. PurUomsEntity UomsEntity = new PurUomsEntity();
  122. UomsEntity.UomConefficient = txt_UOM_CONEFFICIENT.Text.Trim() == "" ? 0 : double.Parse(txt_UOM_CONEFFICIENT.Text);//转换系数
  123. UomsEntity.WeightUnitCode = txt_WEIGHT_UNIT_CODE.Text;//库存单位编码
  124. UomsEntity.UomCode = ultraGrid1.ActiveRow.Cells["UOMCODE"].Value.ToString();//采购单位编码
  125. UomsEntity.WeightUnit = txt_WEIGHT_UNIT.Text;//库存单位
  126. UomsEntity.UomName = txt_UOM_NAME.Text;//采购单位名称
  127. UomsEntity.UpdateName = UserInfo.GetUserName();
  128. UomsEntity.UpdateUserid = UserInfo.GetUserID();
  129. UomsEntity.Validflag = "1";
  130. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.UomsService", "doUpdate", new object[] { UomsEntity});
  131. if (crt.Resultcode != 0)
  132. {
  133. MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
  134. return;
  135. }
  136. MessageUtil.ShowTips("修改成功!");
  137. get_PurUoms();//查询采购单位
  138. ConfigureClassCommon.doActiveSelRow(ultraGrid1, "UomCode", UomsEntity.UomCode);//激活当前行
  139. }
  140. else
  141. {
  142. MessageUtil.ShowTips("请选择一条采购单位");
  143. return;
  144. }
  145. }
  146. /// <summary>
  147. /// 删除采购单位
  148. /// </summary>
  149. /// <param name="configureMEntity"></param>
  150. public void del_PurUoms()
  151. {
  152. if (MessageUtil.ShowYesNoAndQuestion("是否确定删除?") == DialogResult.No)
  153. {
  154. return;
  155. }
  156. if (ultraGrid1.ActiveRow != null)
  157. {
  158. PurUomsEntity UomsEntity = new PurUomsEntity();
  159. UomsEntity.UomCode = ultraGrid1.ActiveRow.Cells["UOMCODE"].Value.ToString();//采购单位编码
  160. UomsEntity.DeleteTime = System.DateTime.Now;
  161. UomsEntity.DeleteName = UserInfo.GetUserName();
  162. UomsEntity.DeleteUserid = UserInfo.GetUserID();
  163. UomsEntity.Validflag = "0";
  164. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.UomsService", "doUpdate", new object[] { UomsEntity});
  165. if (crt.Resultcode != 0)
  166. {
  167. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  168. return;
  169. }
  170. MessageUtil.ShowTips("删除成功!");
  171. get_PurUoms();//查询采购单位
  172. }
  173. else
  174. {
  175. MessageUtil.ShowTips("请选择一条采购单位");
  176. return;
  177. }
  178. }
  179. /// <summary>
  180. /// 验证必填项
  181. /// </summary>
  182. /// <returns></returns>
  183. private bool ValidInput()
  184. {
  185. if (string.IsNullOrEmpty(txt_UOM_NAME.Text.Trim()))
  186. {
  187. MessageBox.Show("请输入采购单位名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  188. return false;
  189. }
  190. //if (string.IsNullOrEmpty(txt_UOM_CODE.Text.Trim()))
  191. //{
  192. // MessageBox.Show("请输入采购单位编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  193. // return false;
  194. //}
  195. if (string.IsNullOrEmpty(txt_WEIGHT_UNIT.Text.Trim()))
  196. {
  197. MessageBox.Show("请输入采购单位名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  198. return false;
  199. }
  200. if (string.IsNullOrEmpty(txt_WEIGHT_UNIT_CODE.Text.Trim()))
  201. {
  202. MessageBox.Show("请输入采购单位编号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  203. return false;
  204. }
  205. if (string.IsNullOrEmpty(txt_UOM_CONEFFICIENT.Text.Trim()))
  206. {
  207. MessageBox.Show("请输入转换系数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  208. return false;
  209. }
  210. else if (!StringUtil.IsNumber(txt_UOM_CONEFFICIENT.Text.Trim()))
  211. {
  212. MessageBox.Show("转换系数必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  213. return false;
  214. }
  215. return true;
  216. }
  217. /// <summary>
  218. /// 激活grid列表
  219. /// </summary>
  220. /// <param name="sender"></param>
  221. /// <param name="e"></param>
  222. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  223. {
  224. txt_UOM_CONEFFICIENT.Text = ultraGrid1.ActiveRow.Cells["UOMCONEFFICIENT"].Value.ToString();
  225. txt_WEIGHT_UNIT_CODE.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNITCODE"].Value.ToString();
  226. txt_UOM_CODE.Text = ultraGrid1.ActiveRow.Cells["UOMCODE"].Value.ToString();
  227. txt_WEIGHT_UNIT.Text = ultraGrid1.ActiveRow.Cells["WEIGHTUNIT"].Value.ToString();
  228. txt_UOM_NAME.Text = ultraGrid1.ActiveRow.Cells["UOMNAME"].Value.ToString();
  229. }
  230. private void txt_WEIGHT_UNIT_CODE_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  231. {
  232. FrmPopItemWeight frm = new FrmPopItemWeight(this.ob);
  233. frm.ShowDialog();
  234. if (!String.IsNullOrEmpty(frm.QstrWeightCode))
  235. {
  236. txt_WEIGHT_UNIT_CODE.Text = frm.QstrWeightCode;
  237. txt_WEIGHT_UNIT.Text = frm.QstrWeightName;
  238. }
  239. }
  240. private void txt_UOM_NAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  241. {
  242. FrmPopItemWeight frm = new FrmPopItemWeight(this.ob);
  243. frm.ShowDialog();
  244. if (!String.IsNullOrEmpty(frm.QstrWeightCode))
  245. {
  246. txt_UOM_CODE.Text = frm.QstrWeightCode;
  247. txt_UOM_NAME.Text = frm.QstrWeightName;
  248. }
  249. }
  250. }
  251. }