F_MST_1602.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. using Dongke.IBOSS.PRD.Basics.BaseControls;
  2. using Dongke.IBOSS.PRD.Basics.BaseResources;
  3. using Dongke.IBOSS.PRD.Client.CommonModule;
  4. using Dongke.IBOSS.PRD.WCF.DataModels;
  5. using Dongke.IBOSS.PRD.WCF.Proxys;
  6. using System;
  7. using System.Collections;
  8. using System.Windows.Forms;
  9. namespace Dongke.IBOSS.PRD.Client.SystemModule
  10. {
  11. public partial class F_MST_1602 : Form
  12. {
  13. #region 成员变量
  14. private string OrderCodeOne;
  15. // 编辑状态
  16. private Constant.FormMode _editStatus;
  17. //table1 还是 table2
  18. private int Orders;
  19. //保存详细订单数据
  20. ArrayList arrayList1 = new ArrayList();
  21. #endregion
  22. #region 构造函数
  23. public F_MST_1602()
  24. {
  25. InitializeComponent();
  26. }
  27. public F_MST_1602(Constant.FormMode frmStatus, ArrayList arrayList, int Order)
  28. {
  29. InitializeComponent();
  30. _editStatus = frmStatus;
  31. arrayList1 = arrayList;
  32. // 设置窗口标题,当为新建状态时显示新建用户,当为编辑状态时显示编辑用户
  33. if (frmStatus == Constant.FormMode.Add)
  34. {
  35. FromStatus = "Add";
  36. this.Text = "新建";
  37. }
  38. else if (frmStatus == Constant.FormMode.Edit)
  39. {
  40. FromStatus = "Edit";
  41. this.Text = "编辑";
  42. this.txtOrderCode.Enabled = true;
  43. Orders = Order;
  44. string OrderCode = arrayList[0].ToString();
  45. if (!string.IsNullOrEmpty(OrderCode))
  46. {
  47. this.txtNumbers.Visible = true;
  48. this.c_Label2.Visible = true;
  49. OrderCodeOne = OrderCode;
  50. ClientRequestEntity cre = new ClientRequestEntity();
  51. cre.NameSpace = "F_MST_1601";
  52. if (OrderCode == "2")
  53. {
  54. cre.Name = "GetOrderDetails";
  55. }
  56. else
  57. {
  58. cre.Name = "GetOrder";
  59. }
  60. cre.Properties["ORDERSCODE"] = OrderCode;
  61. cre.Properties["GOODSCODE"] = "";
  62. cre.Properties["ORDERSNAME"] = "";
  63. cre.Properties["VALUEFLAG"] = "";
  64. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  65. if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
  66. {
  67. if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
  68. {
  69. //订单号
  70. this.txtOrderCode.Text = OrderCode;
  71. ////订单名称
  72. this.txtOrderName.Text = sre.Data.Tables[0].Rows[0]["ORDERSNAME"].ToString();
  73. //数量
  74. this.txtNumbers.Text = sre.Data.Tables[0].Rows[0]["NUMBERS"].ToString();
  75. //有效标识
  76. if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "是")
  77. {
  78. this.ccbvalueflag.SelectedIndex = 0;
  79. }
  80. else if (sre.Data.Tables[0].Rows[0]["VALUEFLAG"].ToString() == "否")
  81. {
  82. this.ccbvalueflag.SelectedIndex = 1;
  83. }
  84. ////备注
  85. //this.txtRemarks.Text = sre.Data.Tables[0].Rows[0]["REMARKS"].ToString();
  86. if (Order == 2)
  87. {
  88. this.txtOrderName.Enabled = false;
  89. this.txtNumbers.Enabled = false;
  90. this.txtNumbers.Text = sre.Data.Tables[0].Rows[0]["NUMBERS"].ToString();
  91. this.txtNumbers.Text = sre.Data.Tables[0].Rows[0]["NUMBERS"].ToString();
  92. }
  93. else
  94. {
  95. txtCustomerCode.Visible = false;
  96. lblMAC.Visible = false;
  97. c_Label1.Visible = false;
  98. txtLayoutCode.Visible = false;
  99. }
  100. }
  101. else
  102. {
  103. // 提示未查找到数据
  104. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  105. MessageBoxButtons.OK, MessageBoxIcon.Information);
  106. }
  107. }
  108. }
  109. }
  110. // 工具栏按钮文本赋值
  111. this.btnSave.Text = ButtonText.BTN_SAVE;
  112. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  113. }
  114. #endregion
  115. #region 属性
  116. /// <summary>
  117. /// 页面状态
  118. /// </summary>
  119. public string FromStatus
  120. {
  121. get;
  122. set;
  123. }
  124. #endregion
  125. #region 事件
  126. private void c_Label3_Click(object sender, EventArgs e)
  127. {
  128. }
  129. //保存事件
  130. private void btnSave_Click(object sender, EventArgs e)
  131. {
  132. try
  133. {
  134. if (Orders == 2)
  135. {
  136. //客户编码
  137. if (string.IsNullOrEmpty(this.txtCustomerCode.Text.ToString()))
  138. {
  139. //必须输入
  140. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "客户编码"),
  141. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  142. this.txtCustomerCode.Focus();
  143. return;
  144. }
  145. //版面编码
  146. if (string.IsNullOrEmpty(this.txtLayoutCode.Text.ToString()))
  147. {
  148. //必须输入
  149. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "版面编码"),
  150. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  151. this.txtLayoutCode.Focus();
  152. return;
  153. }
  154. //订单名称
  155. if (string.IsNullOrEmpty(this.txtOrderName.Text.ToString()))
  156. {
  157. //必须输入
  158. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "订单名称"),
  159. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  160. this.txtOrderName.Focus();
  161. return;
  162. }
  163. //有效标识
  164. if (this.ccbvalueflag.SelectedItem == null)
  165. {
  166. //必须输入
  167. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "有效标识"),
  168. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  169. this.ccbvalueflag.Focus();
  170. return;
  171. }
  172. //订单号
  173. if (string.IsNullOrEmpty(this.txtOrderCode.Text.ToString()))
  174. {
  175. //必须输入
  176. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "订单号"),
  177. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  178. this.txtOrderCode.Focus();
  179. return;
  180. }
  181. //数量
  182. if (string.IsNullOrEmpty(this.txtNumbers.Text.ToString()))
  183. {
  184. //必须输入
  185. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "数量"),
  186. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
  187. this.txtNumbers.Focus();
  188. return;
  189. }
  190. }
  191. //int returnCustomerID = Constant.INT_IS_ZERO;
  192. //_CustomerEntity = this.SetCustomerEntity();
  193. if (_editStatus == Constant.FormMode.Add)
  194. {
  195. // 新建用户,返回新建的用户ID
  196. this.btnSave.Enabled = false;
  197. this.btnCancel.Enabled = false;
  198. this.AddOrderInfo();
  199. this.Clear();
  200. }
  201. if (_editStatus == Constant.FormMode.Edit)
  202. {
  203. this.btnSave.Enabled = false;
  204. this.btnCancel.Enabled = false;
  205. this.EditOrder();
  206. this.Close();
  207. }
  208. }
  209. catch (Exception ex)
  210. {
  211. // 对异常进行共通处理
  212. ExceptionManager.HandleEventException(this.ToString(),
  213. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  214. }
  215. }
  216. #endregion
  217. #region 私有方法
  218. //保存方法
  219. private void AddOrderInfo()
  220. {
  221. int valueflag = 1;
  222. ClientRequestEntity cre = new ClientRequestEntity();
  223. cre.NameSpace = "F_MST_1601";
  224. cre.Name = "AddOrderInfo";
  225. cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
  226. cre.Properties["ORDERSNAME"] = this.txtOrderName.Text;
  227. cre.Properties["ORDERSCODE"] = this.txtOrderCode.Text;
  228. cre.Properties["LAYOUTCODE"] = this.txtLayoutCode.Text;
  229. cre.Properties["NUMBERS"] = this.txtNumbers.Text;
  230. if (this.ccbvalueflag.SelectedIndex == 0)
  231. {
  232. valueflag = 1;
  233. }
  234. if (this.ccbvalueflag.SelectedIndex == 1)
  235. {
  236. valueflag = 0;
  237. }
  238. cre.Properties["VALUEFLAG"] = valueflag;
  239. cre.Properties["FromStatus"] = FromStatus.ToString();
  240. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  241. this.btnSave.Enabled = true;
  242. this.btnCancel.Enabled = true;
  243. if (sre.OtherStatus > 0)
  244. {
  245. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  246. return;
  247. }
  248. else if (Convert.ToInt32(sre.OtherStatus) == -1001)
  249. {
  250. MessageBox.Show(string.Format(Messages.MSG_CMN_W007,
  251. "存在相同订单"),
  252. "",
  253. MessageBoxButtons.OK,
  254. MessageBoxIcon.Warning);
  255. return;
  256. }
  257. }
  258. //编辑方法
  259. private void EditOrder()
  260. {
  261. if (Orders == 2)
  262. {
  263. int valueflag = 1;
  264. ClientRequestEntity cre = new ClientRequestEntity();
  265. cre.NameSpace = "F_MST_1601";
  266. cre.Name = "AddOrderInfo";
  267. if (this.ccbvalueflag.SelectedIndex == 0)
  268. {
  269. valueflag = 1;
  270. }
  271. if (this.ccbvalueflag.SelectedIndex == 1)
  272. {
  273. valueflag = 0;
  274. }
  275. cre.Properties["VALUEFLAG"] = valueflag;
  276. cre.Properties["FromStatus"] = FromStatus.ToString();
  277. cre.Properties["ORDERS"] = Orders;
  278. cre.Properties["ORDERSDETAILID"] = arrayList1[2].ToString();
  279. cre.Properties["ORDERSNAME"] = this.txtOrderName.Text;
  280. cre.Properties["ORDERSCODE"] = this.txtOrderCode.Text;
  281. cre.Properties["CUSTOMERCODE"] = this.txtCustomerCode.Text;
  282. cre.Properties["LAYOUTCODE"] = this.txtLayoutCode.Text;
  283. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  284. this.btnSave.Enabled = true;
  285. this.btnCancel.Enabled = true;
  286. if (sre.OtherStatus > 0)
  287. {
  288. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  289. return;
  290. }
  291. }
  292. else if (Orders == 1)
  293. {
  294. int valueflag = 1;
  295. ClientRequestEntity cre = new ClientRequestEntity();
  296. cre.NameSpace = "F_MST_1601";
  297. cre.Name = "AddOrderInfo";
  298. if (this.ccbvalueflag.SelectedIndex == 0)
  299. {
  300. valueflag = 1;
  301. }
  302. if (this.ccbvalueflag.SelectedIndex == 1)
  303. {
  304. valueflag = 0;
  305. }
  306. cre.Properties["VALUEFALG"] = valueflag;
  307. cre.Properties["FromStatus"] = FromStatus.ToString();
  308. cre.Properties["ORDERS"] = Orders;
  309. cre.Properties["ORDERSCODE"] = this.txtOrderCode.Text;
  310. cre.Properties["ORDERCODEONE"] = OrderCodeOne;
  311. cre.Properties["ORDERNAME"] = this.txtOrderName.Text;
  312. cre.Properties["NUMBERS"] = this.txtNumbers.Text;
  313. ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
  314. this.btnSave.Enabled = true;
  315. this.btnCancel.Enabled = true;
  316. if (sre.OtherStatus > 0)
  317. {
  318. DKMessageBox.ShowDialog(this, DKMessageCode.I_CMN_S_002);
  319. return;
  320. }
  321. }
  322. }
  323. private void Clear()
  324. {
  325. this.txtOrderCode.Clear();
  326. this.txtOrderName.Clear();
  327. this.txtLayoutCode.Clear();
  328. this.txtCustomerCode.Clear();
  329. this.txtNumbers.Clear();
  330. this.ccbvalueflag.SelectedText = "";
  331. }
  332. #endregion
  333. private void F_MST_1602_Load(object sender, EventArgs e)
  334. {
  335. }
  336. private void txtCustomerCode_TextChanged(object sender, EventArgs e)
  337. {
  338. }
  339. private void lblMAC_Click(object sender, EventArgs e)
  340. {
  341. }
  342. }
  343. }