14cf0b6bcbcc0ddc9d1db225880ff7bd32f8a6b5.svn-base 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 System.Collections;
  11. namespace Core.LZMes.Client.UIM
  12. {
  13. public partial class UIM010010 : FrmBase
  14. {
  15. public UIM010010()
  16. {
  17. InitializeComponent();
  18. }
  19. private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
  20. {
  21. }
  22. public override void ToolBar_Click(object sender, string ToolbarKey)
  23. {
  24. switch (ToolbarKey)
  25. {
  26. case "Query":
  27. this.DoQuery();
  28. break;
  29. case "Add":
  30. this.DoAdd();
  31. break;
  32. case "Update":
  33. this.DoUpdate();
  34. break;
  35. case "Delete":
  36. this.DoDelete();
  37. break;
  38. case "Save":
  39. break;
  40. case "Exit":
  41. this.Close();
  42. break;
  43. }
  44. }
  45. private void DoQuery()
  46. {
  47. try
  48. {
  49. int areaType = -1 == this.ultraComboEditor1.SelectedIndex ? 0 : int.Parse(this.ultraComboEditor1.SelectedItem.DataValue.ToString());
  50. this.dataSet1.Tables[0].Clear();
  51. CoreClientParam ccp = new CoreClientParam();
  52. //ccp.InvokeID = "C06010103";
  53. ccp.ServerName = "UIM.UIM010010";
  54. ccp.MethodName = "queryYardArea";
  55. ccp.ServerParams = new object[] { areaType };
  56. ccp.SourceDataTable = this.dataSet1.Tables[0];
  57. this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
  58. Console.WriteLine(this.dataSet1.Tables[0].ToString());
  59. }
  60. catch (Exception EX)
  61. {
  62. MessageBox.Show(EX.ToString());
  63. }
  64. }
  65. private void DoAdd()
  66. {
  67. try
  68. {
  69. if (-1 == this.ultraComboEditor2.SelectedIndex)
  70. {
  71. MessageBox.Show("请选择区域类型!");
  72. this.ultraComboEditor2.Focus();
  73. return;
  74. }
  75. if(null == this.textBox2.Text || "".Equals(this.textBox2.Text))
  76. {
  77. MessageBox.Show("请输入区域名称!");
  78. this.textBox2.Focus();
  79. return;
  80. }
  81. string areaName = this.textBox2.Text;//区域名称
  82. int areaType = int.Parse(this.ultraComboEditor2.SelectedItem.DataValue.ToString());//区域类型
  83. string hSail = this.checkBox1.Checked ? "1" : "0";//是否可以外卖
  84. string remark = this.textBox3.Text;//备注
  85. string regId = this.UserInfo.GetUserID();//操作人
  86. CoreClientParam ccp = new CoreClientParam();
  87. ccp.ServerName = "UIM.UIM010010";
  88. ccp.MethodName = "addArea";
  89. ccp.ServerParams = new object[] {areaType,areaName,hSail,remark,regId};
  90. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  91. if (0 != ccp.ReturnCode) return;
  92. DoQuery();
  93. }
  94. catch (Exception EX)
  95. {
  96. MessageBox.Show(EX.ToString());
  97. }
  98. }
  99. private void DoUpdate()
  100. {
  101. try
  102. {
  103. if (null == this.textBox2.Text || "".Equals(this.textBox2.Text))
  104. {
  105. MessageBox.Show("请输入区域名称!");
  106. this.textBox2.Focus();
  107. return;
  108. }
  109. long areaNo = long.Parse(this.ultraGrid1.ActiveRow.Cells["area_no"].Text);//区域编号
  110. string areaName = this.textBox2.Text;//区域名称
  111. int areaType = int.Parse(this.ultraComboEditor2.SelectedItem.DataValue.ToString());//区域类型
  112. string hSail = this.checkBox1.Checked ? "1" : "0";//是否可以外卖
  113. string remark = this.textBox3.Text;//备注
  114. string regId = this.UserInfo.GetUserID();//操作人
  115. CoreClientParam ccp = new CoreClientParam();
  116. ccp.ServerName = "UIM.UIM010010";
  117. ccp.MethodName = "updateArea";
  118. ccp.ServerParams = new object[] { areaNo, areaType, areaName, hSail, remark, regId };
  119. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  120. if (0 != ccp.ReturnCode) return;
  121. this.DoQuery();
  122. MessageBox.Show("修改成功!");
  123. }
  124. catch (Exception EX)
  125. {
  126. MessageBox.Show(EX.ToString());
  127. }
  128. }
  129. private void DoDelete()
  130. {
  131. try
  132. {
  133. long areaNo = -1;
  134. Infragistics.Win.UltraWinGrid.UltraGridRow row = this.ultraGrid1.ActiveRow;
  135. string delParam = "";
  136. if (row != null)
  137. {
  138. areaNo = long.Parse(row.Cells["area_no"].Text);
  139. delParam += areaNo + "|";
  140. if (hasYardInArea(areaNo))
  141. {
  142. MessageBox.Show("区域下存在垛位信息,请先删除对应垛位。");
  143. return;
  144. }
  145. }
  146. else
  147. {
  148. MessageBox.Show("请选择要删除的区域。");
  149. return;
  150. }
  151. if(MessageBox.Show(this,"是否确认删除?","删除",MessageBoxButtons.YesNo,MessageBoxIcon.Warning) == DialogResult.Yes)
  152. {
  153. if (!"".Equals(delParam))
  154. {
  155. CoreClientParam ccp = new CoreClientParam();
  156. ccp.ServerName = "UIM.UIM010010";
  157. ccp.MethodName = "delArea";
  158. ccp.ServerParams = new object[] { delParam };
  159. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  160. if (ccp.ReturnCode != 0) return;
  161. }
  162. this.ultraGrid1.DeleteSelectedRows(false);
  163. MessageBox.Show("删除成功!");
  164. DoQuery();
  165. }
  166. }
  167. catch (Exception EX)
  168. {
  169. MessageBox.Show(EX.ToString());
  170. }
  171. }
  172. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  173. {
  174. Infragistics.Win.UltraWinGrid.UltraGridRow uRow = this.ultraGrid1.ActiveRow;
  175. this.textBox2.Text = uRow.Cells["area_name"].Text;
  176. this.textBox3.Text = uRow.Cells["remark"].Text;
  177. this.ultraComboEditor2.Text = uRow.Cells["area_type"].Text;
  178. this.checkBox1.Checked = "是".Equals(uRow.Cells["h_sail"].Text) ? true : false;
  179. }
  180. //判断区域下是否存在垛位
  181. private bool hasYardInArea(long areaNo)
  182. {
  183. try
  184. {
  185. CoreClientParam ccp = new CoreClientParam();
  186. ccp.ServerName = "UIM.UIM010010";
  187. ccp.MethodName = "hasYardInArea";
  188. ccp.ServerParams = new object[] { areaNo };
  189. ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
  190. int count = int.Parse(ccp.ReturnObject.ToString());
  191. if (count < 1)
  192. {
  193. return false;
  194. }
  195. return true;
  196. }
  197. catch (Exception EX)
  198. {
  199. MessageBox.Show(EX.ToString());
  200. return true;
  201. }
  202. }
  203. private void UIM010010_Load(object sender, EventArgs e)
  204. {
  205. }
  206. private void ultraComboEditor1_ValueChanged(object sender, EventArgs e)
  207. {
  208. }
  209. }
  210. }