DressOpenOrdePreselectedSmallForm.cs 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. using LYFZ.Software.MainBusiness.Dresses.DressView;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace LYFZ.Software.MainBusiness.Dresses.SetSmallForm
  12. {
  13. public partial class DressOpenOrdePreselectedSmallForm : LYFZ.Software.UI.Dresses.SetSmallForm.DressOpenOrdePreselectedSmallForm
  14. {
  15. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  16. LYFZ.BLL.BLL_ErpDressFrom sfbll = new BLL.BLL_ErpDressFrom();
  17. LYFZ.BLL.BLL_ErpCustomer ctbll = new BLL.BLL_ErpCustomer();
  18. LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
  19. LYFZ.BLL.BLL_ErpDressSaleRentalOrder dsrobll = new BLL.BLL_ErpDressSaleRentalOrder();
  20. LYFZ.BLL.BLL_ErpDressSaleRentalDetail dsrdbll = new BLL.BLL_ErpDressSaleRentalDetail();
  21. List<UCDressCustomer> dressCustomerList = new List<UCDressCustomer>();
  22. public DressOpenOrdePreselectedSmallForm()
  23. {
  24. this.Load += DressOpenOrdePreselectedFormMain_Load;
  25. this.Shown += DressOpenOrdePreselectedFormMain_Shown;
  26. this.btn_AddCustomer.Click+=btn_AddCustomer_Click;
  27. this.btnNewOrder.Click += btnNewOrder_Click;
  28. this.btnTurnRent.Click += btnTurnRent_Click;
  29. this.btnTurnSale.Click += btnTurnSale_Click;
  30. this.btnSaveed.Click += btnSaveed_Click;
  31. this.btnCloseed.Click += btnCloseed_Click;
  32. this.btnDressDelete.Click += btnDressDelete_Click;
  33. this.btnDressToolbox.Click += btnDressToolbox_Click;
  34. this.FormClosing += DressOpenOrderFormMain_FormClosing;
  35. this.FormClosed += DressOpenOrderFormMain_FormClosed;
  36. }
  37. private void btn_AddCustomer_Click(object sender, EventArgs e)
  38. {
  39. UCDressCustomer ucdressCustomer = new UCDressCustomer();
  40. panel_CustomerItem.Controls.Add(ucdressCustomer);
  41. ucdressCustomer.Location = new Point(0, dressCustomerList.Count*120);
  42. ucdressCustomer.buttonForm1.Click += buttonForm1_Click;
  43. dressCustomerList.Add(ucdressCustomer);
  44. ucdressCustomer.StrOrderNumber = this.StrOrderNumber;
  45. ucdressCustomer.IsUpdateClientData = this.IsUpdateClientData;
  46. SetPanelItemHeight();
  47. }
  48. public void SetPanelItemHeight()
  49. {
  50. int height = 0;
  51. foreach(var item in dressCustomerList)
  52. {
  53. height += 120;
  54. }
  55. panel_CustomerItem.Size = new System.Drawing.Size(panel_CustomerItem.Size.Width, height);
  56. }
  57. void buttonForm1_Click(object sender, EventArgs e)
  58. {
  59. if(MessageBoxCustom.Show("确定删除当前联系人信息?","提示", MessageBoxButtons.YesNo)
  60. == System.Windows.Forms.DialogResult.Yes)
  61. {
  62. dressCustomerList.Remove((UCDressCustomer)(((Control)sender).Parent));
  63. panel_CustomerItem.Controls.Remove(((Control)sender).Parent);
  64. SetPanelItemHeight();
  65. }
  66. }
  67. public string AutoNumber = "";
  68. public string SysNumber = "";
  69. /// <summary>
  70. /// 订单号
  71. /// </summary>
  72. public string StrOrderNumber = "";
  73. /// <summary>
  74. /// 是否保存
  75. /// </summary>
  76. public bool IsSaveed = false;
  77. /// <summary>
  78. /// 相片集合
  79. /// </summary>
  80. ImageList mlistImage = new ImageList();
  81. /// <summary>
  82. /// 是否能修改客户资料
  83. /// </summary>
  84. bool IsUpdateClientData = true;
  85. /// <summary>
  86. /// 登录都编号
  87. /// </summary>
  88. string StrUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  89. /// <summary>
  90. /// 登录都姓名
  91. /// </summary>
  92. string StrUserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
  93. /// <summary>
  94. /// 用于排序的类
  95. /// </summary>
  96. LYFZ.ComponentLibrary.ListViewColumnSorter lvwColumnSorter;
  97. /// <summary>
  98. /// 窗体加载事件
  99. /// </summary>
  100. /// <param name="sender"></param>
  101. /// <param name="e"></param>
  102. void DressOpenOrdePreselectedFormMain_Load(object sender, EventArgs e)
  103. {
  104. this.listViewData.View = View.Details;
  105. this.listViewData.GridLines = true;
  106. panel_CustomerItem.Padding = new Padding(18, 0, 0, 0);
  107. string[] StrColumns = ("礼服编号,礼服名称,礼服尺寸,礼服数量,出租价格,出售价格").Split(',');
  108. for (int i = 0; i < StrColumns.Length; i++)
  109. {
  110. ColumnHeader ch = new ColumnHeader();
  111. ch.Text = StrColumns[i].Trim();
  112. ch.Width = (this.listViewData.Width - 23) / 6;
  113. if (StrColumns[i].Trim() == "出租价格" || StrColumns[i].Trim() == "出售价格")
  114. { ch.TextAlign = HorizontalAlignment.Right; }
  115. else if (StrColumns[i].Trim() == "礼服数量")
  116. { ch.TextAlign = HorizontalAlignment.Center; }
  117. else
  118. { ch.TextAlign = HorizontalAlignment.Left; }
  119. this.listViewData.Columns.Add(ch);
  120. }
  121. this.mlistImage.ImageSize = new Size(25, 25);
  122. this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
  123. this.listViewData.SmallImageList = mlistImage;
  124. lvwColumnSorter = new ComponentLibrary.ListViewColumnSorter();
  125. this.listViewData.ListViewItemSorter = lvwColumnSorter;
  126. UCDressCustomer ucdressCustomer = new UCDressCustomer();
  127. ucdressCustomer.BindShowAndHideDelete(false);
  128. panel_CustomerItem.Controls.Add(ucdressCustomer);
  129. dressCustomerList.Add(ucdressCustomer);
  130. ucdressCustomer.StrOrderNumber = this.StrOrderNumber;
  131. ucdressCustomer.IsUpdateClientData = this.IsUpdateClientData;
  132. SetPanelItemHeight();
  133. }
  134. /// <summary>
  135. /// 窗体加载事件
  136. /// </summary>
  137. /// <param name="sender"></param>
  138. /// <param name="e"></param>
  139. void DressOpenOrdePreselectedFormMain_Shown(object sender, EventArgs e)
  140. {
  141. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbtreevOrderPerson, IsFirstNodeNull: true, IsShowResign: false, IsShowAdmin: false);
  142. if (!string.IsNullOrEmpty(this.StrOrderNumber))
  143. {
  144. this.txtOrderNumber.Text = this.StrOrderNumber;
  145. this.OpenOrderData();
  146. }
  147. else
  148. {
  149. this.btnTurnRent.Visible = false;
  150. this.btnTurnSale.Visible = false;
  151. this.txtOrderNumber.Text = LYFZ.BLL.BLL_ErpOrder.GenerateNewDressNumber(LYFZ.EnumPublic.EnumDressOrderType.预选);
  152. this.txtEnterName.Text = this.StrUserName;
  153. this.txtCreateDateTime.Text = SDateTime.Now.ToString("yyyy-MM-dd");
  154. this.btnSaveed.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressManagement, CustomAttributes.OperatingAuthority.Dress_Rental);
  155. }
  156. this.TopMost = false;
  157. SysNumber = this.StrOrderNumber;
  158. if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.AutoDressOrderNumber)
  159. {
  160. txtOrderNumber.ReadOnly = false;
  161. }
  162. }
  163. /// <summary>
  164. /// 打开订单数据
  165. /// </summary>
  166. void OpenOrderData()
  167. {
  168. DataTable dtOrder = orbll.GetView_Custom("tb_ErpDressSaleRentalOrder Left Join tb_ErpUser on User_EmployeeID = Dsro_HandledName", StrWhere: "Dsro_Number = '" + this.StrOrderNumber + "'", ShowColumnName: "Dsro_Number,Dsro_CreateName,User_Name,Dsro_CreateDateTime,Dsro_Remark,Dsro_CustomerNumber,Dsro_AutoNumber").Tables[0];
  169. if (dtOrder.Rows.Count > 0)
  170. {
  171. //this.btnClientSelect.Visible = false;
  172. //this.txtClientName.Width = this.txtClientQQ.Width;
  173. this.cmbtreevOrderPerson.TagFindText(dtOrder.Rows[0]["Dsro_CreateName"]);
  174. this.txtEnterName.Text = dtOrder.Rows[0]["User_Name"].ToString().Trim();
  175. this.txtCreateDateTime.Text = LYFZ.Command.Command_Validate.DateTimeToString(dtOrder.Rows[0]["Dsro_CreateDateTime"]);
  176. this.txtRemark.Text = dtOrder.Rows[0]["Dsro_Remark"].ToString().Trim();
  177. this.txtOrderNumber.Text = dtOrder.Rows[0]["Dsro_AutoNumber"].ToString().Trim();
  178. this.txtOrderNumber.Tag = dtOrder.Rows[0]["Dsro_AutoNumber"].ToString().Trim();
  179. if (string.IsNullOrEmpty(this.txtOrderNumber.Text))
  180. {
  181. this.txtOrderNumber.Text = dtOrder.Rows[0]["Dsro_Number"].ToString().Trim();
  182. this.txtOrderNumber.Tag = dtOrder.Rows[0]["Dsro_Number"].ToString().Trim();
  183. }
  184. //this.GetClientData(dtOrder.Rows[0]["Dsro_CustomerNumber"].ToString().Trim());
  185. string[] customerList = dtOrder.Rows[0]["Dsro_CustomerNumber"].ToString().Trim().Split(',');
  186. if (customerList.Length>1)
  187. {
  188. for (int i = 1; i < customerList.Length;i++ )
  189. {
  190. UCDressCustomer ucdressCustomer = new UCDressCustomer();
  191. ucdressCustomer.Location = new Point(0, dressCustomerList.Count * 120);
  192. panel_CustomerItem.Controls.Add(ucdressCustomer);
  193. ucdressCustomer.buttonForm1.Click += buttonForm1_Click;
  194. dressCustomerList.Add(ucdressCustomer);
  195. ucdressCustomer.StrOrderNumber = this.StrOrderNumber;
  196. ucdressCustomer.IsUpdateClientData = this.IsUpdateClientData;
  197. SetPanelItemHeight();
  198. }
  199. }
  200. for (int i = 0; i < customerList.Length; i++)
  201. {
  202. dressCustomerList[i].GetClientData(customerList[i]);
  203. dressCustomerList[i].ReBindOrderNumber();
  204. }
  205. this.IsUpdateClientData = false;
  206. DataTable dt = orbll.GetView_Custom("tb_ErpDressSaleRentalDetail Left Join tb_ErpDressFrom on Dsfm_DressNumber = Dsrd_DressNumber", StrWhere: "Dsrd_Number = '" + this.StrOrderNumber + "'", ShowColumnName: "tb_ErpDressSaleRentalDetail.ID,Dsrd_DressNumber,Dsfm_DressCustomNumber,Dsrd_DressName,Dsfm_DressSize,Dsrd_CostPrice,Dsrd_RentPrice,Dsrd_SalePrice,Dsfm_DressPhotoNames").Tables[0];
  207. for (int i = 0; i < dt.Rows.Count; i++)
  208. {
  209. string[] StrArrayList = dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim().Split('|');
  210. if (!this.mlistImage.Images.Keys.Contains(dt.Rows[i]["Dsrd_DressNumber"].ToString().Trim()))
  211. {
  212. Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDressImage_Small(StrArrayList[0].Trim());
  213. try
  214. {
  215. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  216. { this.mlistImage.Images.Add(dt.Rows[i]["Dsrd_DressNumber"].ToString().Trim(), img); }));
  217. }
  218. catch
  219. { }
  220. }
  221. ListViewItem lvItem = new ListViewItem();
  222. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressOpenOrderRentSaleFormMain_ColumnHeaderModel modelColumn = new DressOpenOrderRentSaleFormMain_ColumnHeaderModel();
  223. modelColumn.StrDressNumber = dt.Rows[i]["Dsrd_DressNumber"].ToString().Trim();
  224. modelColumn.StrCostPrice = dt.Rows[i]["Dsrd_CostPrice"].ToString().Trim();
  225. modelColumn.StrDressPhotoNames = dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim();
  226. modelColumn.ID = Convert.ToInt32(dt.Rows[i]["ID"]);
  227. lvItem.Tag = modelColumn;
  228. lvItem.ImageKey = dt.Rows[i]["Dsrd_DressNumber"].ToString().Trim();
  229. lvItem.Text = dt.Rows[i]["Dsfm_DressCustomNumber"].ToString().Trim();
  230. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  231. ListSubItem.Name = "礼服名称";
  232. ListSubItem.Text = dt.Rows[i]["Dsrd_DressName"].ToString().Trim();
  233. lvItem.SubItems.Add(ListSubItem);
  234. ListSubItem = new ListViewItem.ListViewSubItem();
  235. ListSubItem.Name = "礼服尺寸";
  236. ListSubItem.Text = dt.Rows[i]["Dsfm_DressSize"].ToString().Trim();
  237. lvItem.SubItems.Add(ListSubItem);
  238. ListSubItem = new ListViewItem.ListViewSubItem();
  239. ListSubItem.Name = "礼服数量";
  240. ListSubItem.Text = "1";
  241. lvItem.SubItems.Add(ListSubItem);
  242. ListSubItem = new ListViewItem.ListViewSubItem();
  243. ListSubItem.Name = "出租价格";
  244. ListSubItem.Text = dt.Rows[i]["Dsrd_RentPrice"].ToString().Trim();
  245. lvItem.SubItems.Add(ListSubItem);
  246. ListSubItem = new ListViewItem.ListViewSubItem();
  247. ListSubItem.Name = "出售价格";
  248. ListSubItem.Text = dt.Rows[i]["Dsrd_SalePrice"].ToString().Trim();
  249. lvItem.SubItems.Add(ListSubItem);
  250. this.listViewData.Items.Add(lvItem);
  251. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData);
  252. }
  253. }
  254. }
  255. /// <summary>
  256. /// 新订单
  257. /// </summary>
  258. /// <param name="sender"></param>
  259. /// <param name="e"></param>
  260. void btnNewOrder_Click(object sender, EventArgs e)
  261. {
  262. if (MessageBoxCustom.Show("重置后将清空所有数据,您确定要重置新订单吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  263. {
  264. this.IsGoForm = true;
  265. this.Close();
  266. }
  267. }
  268. /// <summary>
  269. /// 转为出租订单
  270. /// </summary>
  271. /// <param name="sender"></param>
  272. /// <param name="e"></param>
  273. void btnTurnRent_Click(object sender, EventArgs e)
  274. {
  275. if (string.IsNullOrEmpty(this.StrOrderNumber))
  276. { MessageBoxCustom.Show("订单未保存,不能直接转为出租订单!"); return; }
  277. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressOpenOrderRentSaleSmallForm frm = new SetSmallForm.DressOpenOrderRentSaleSmallForm();
  278. frm.StrOrderNumber = this.StrOrderNumber;
  279. frm.LoadType = "出租";
  280. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  281. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  282. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  283. frm.BringToFront();
  284. frm.Show();
  285. this.isClose = false;
  286. this.Hide();
  287. }
  288. /// <summary>
  289. /// 转为出售订单
  290. /// </summary>
  291. /// <param name="sender"></param>
  292. /// <param name="e"></param>
  293. void btnTurnSale_Click(object sender, EventArgs e)
  294. {
  295. if (string.IsNullOrEmpty(this.StrOrderNumber))
  296. { MessageBoxCustom.Show("订单未保存,不能直接转为出售订单!"); return; }
  297. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressOpenOrderRentSaleSmallForm frm = new SetSmallForm.DressOpenOrderRentSaleSmallForm();
  298. frm.StrOrderNumber = this.StrOrderNumber;
  299. frm.LoadType = "出售";
  300. frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
  301. frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
  302. frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
  303. frm.BringToFront();
  304. frm.Show();
  305. this.isClose = false;
  306. this.Hide();
  307. }
  308. Hashtable htData_del = new Hashtable();
  309. /// <summary>
  310. /// 保存
  311. /// </summary>
  312. /// <param name="sender"></param>
  313. /// <param name="e"></param>
  314. void btnSaveed_Click(object sender, EventArgs e)
  315. {
  316. LYFZ.Model.Model_ErpDressSaleRentalOrder DressRentalModel = null;
  317. LYFZ.Model.Model_ErpDressSaleRentalDetail DressRentalDetailModel = null;
  318. #region 判断输入框不能为空
  319. if (string.IsNullOrEmpty(this.txtOrderNumber.Text.Trim()))
  320. { MessageBoxCustom.Show("单号不能为空!"); return; }
  321. if (string.IsNullOrEmpty(this.cmbtreevOrderPerson.Text.Trim()))
  322. { MessageBoxCustom.Show("销售人员不能为空!"); return; }
  323. foreach(var item in dressCustomerList)
  324. {
  325. LYFZ.Command.Result result = item.CheckCustomerData();
  326. if(!result.Status)
  327. {
  328. return ;
  329. }
  330. }
  331. #endregion
  332. DateTime StrTime = SDateTime.Now;
  333. List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
  334. string StrClientNumber = "";
  335. string StrClientName = "";
  336. string StrClientTelephone = "";
  337. #region 客户
  338. foreach (var item in dressCustomerList)
  339. {
  340. LYFZ.Command.Result result = item.SaveCustomerData(ref StrClientName, ref StrClientTelephone);
  341. if(result.Status)
  342. {
  343. if (!string.IsNullOrEmpty(StrClientNumber))
  344. {
  345. StrClientNumber += ",";
  346. }
  347. StrClientNumber += result.StatusMsg;
  348. clist.AddRange(((LYFZ.Command.Result<List<Helper.CommandInfo>>)result).clist);
  349. }
  350. else
  351. {
  352. return;
  353. }
  354. }
  355. #endregion
  356. /*#region 客户
  357. string StrClientNumber = "";
  358. if (this.txtClientName.Tag != null)
  359. { StrClientNumber = this.txtClientName.Tag.ToString().Trim(); }
  360. else
  361. {
  362. if (ctbll.Exists("Cus_Telephone", StrTelephone) == true)//判断手机存在
  363. { MessageBoxCustom.Show("客户手机已经存在"); return; }
  364. LYFZ.Model.Model_ErpCustomer model = new Model.Model_ErpCustomer();
  365. model.Cus_CustomerNumber = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMMddHHmmssfff") + "1";//获取新编号
  366. model.Cus_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  367. model.Cus_CustomizeNumber = "";
  368. model.Cus_Type = "订单客户";
  369. model.Cus_ServiceType = "Clothing";
  370. model.Cus_Name = this.txtClientName.Text.ToString().Trim();
  371. model.Cus_Telephone = this.txtClientTelephone.Text.ToString().Trim();
  372. model.Cus_QQ = this.txtClientQQ.Text.ToString().Trim();
  373. model.Cus_Address = this.txtClientAddress.Text.ToString().Trim();
  374. model.Cus_WorkUnit = this.txtClientWorkUnit.Text.ToString().Trim();
  375. model.Cus_Birthday = this.txtClientBirthday.StrValue.Trim();
  376. if (this.chkClientBirthdayLunar.Checked == true)
  377. { model.Cus_BirthdayLunar = "1"; }
  378. else
  379. { model.Cus_BirthdayLunar = "0"; }
  380. model.Cus_DayForMarriage = this.txtClientDayForMarriage.StrValue.ToString();
  381. if (this.chkClientDayForMarriageLunar.Checked == true)
  382. { model.Cus_DayForMarriageLunar = "1"; }
  383. else
  384. { model.Cus_DayForMarriageLunar = "0"; }
  385. model.Cus_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  386. model.Cus_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  387. clist.Add(ctbll.GetAddCommandInfo(model));
  388. StrClientNumber = model.Cus_CustomerNumber;
  389. }
  390. #endregion*/
  391. #region 检查自定义单号是否存在
  392. if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.AutoDressOrderNumber)
  393. {
  394. DataTable tbl = orbll.GetView_Custom("tb_ErpDressSaleRentalOrder", StrWhere: "Dsro_AutoNumber = '" + this.txtOrderNumber.Text + "'", ShowColumnName: "ID").Tables[0];
  395. if (string.IsNullOrEmpty(StrOrderNumber))
  396. {
  397. if (tbl.Rows.Count > 0)
  398. {
  399. MessageBoxCustom.Show("自定义单号重复!"); return;
  400. }
  401. }
  402. else
  403. {
  404. if (this.txtOrderNumber.Text == (this.txtOrderNumber.Tag == null ? "" : this.txtOrderNumber.Tag.ToString()))
  405. {
  406. if (tbl.Rows.Count > 1)
  407. {
  408. MessageBoxCustom.Show("自定义单号重复!"); return;
  409. }
  410. }
  411. else
  412. {
  413. if (tbl.Rows.Count > 0)
  414. {
  415. MessageBoxCustom.Show("自定义单号重复!"); return;
  416. }
  417. }
  418. }
  419. }
  420. #endregion
  421. #region 检测订单号是否有存在
  422. if (string.IsNullOrEmpty(SysNumber))
  423. {
  424. bool IsFind = true;
  425. while (IsFind)
  426. {
  427. if (string.IsNullOrEmpty(SysNumber))
  428. {
  429. SysNumber = LYFZ.BLL.BLL_ErpOrder.GenerateNewDressNumber(LYFZ.EnumPublic.EnumDressOrderType.出租);
  430. if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.AutoDressOrderNumber)
  431. {
  432. this.txtOrderNumber.Text = SysNumber;
  433. }
  434. }
  435. DataTable tbl = orbll.GetView_Custom("tb_ErpDressSaleRentalOrder", StrWhere: "Dsro_Number = '" + SysNumber + "'", ShowColumnName: "ID").Tables[0];
  436. if (tbl.Rows.Count <= 0)
  437. { IsFind = false; }
  438. else
  439. { //this.txtOrderNumber.Text
  440. SysNumber= LYFZ.BLL.BLL_ErpOrder.GenerateNewDressNumber(LYFZ.EnumPublic.EnumDressOrderType.出租);
  441. if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.AutoDressOrderNumber)
  442. {
  443. this.txtOrderNumber.Text = SysNumber;
  444. }
  445. }
  446. }
  447. }
  448. #endregion
  449. #region 礼服预选订单
  450. if (!string.IsNullOrEmpty(StrOrderNumber))
  451. {
  452. DressRentalModel = dsrobll.GetModel("Dsro_Number", this.StrOrderNumber);
  453. DressRentalModel.Dsro_UpdateDateTime = StrTime;
  454. DressRentalModel.Dsro_UpdateName = this.StrUserID;
  455. DressRentalModel.Dsro_CustomerNumber = StrClientNumber;
  456. }
  457. else
  458. {
  459. DressRentalModel = new Model.Model_ErpDressSaleRentalOrder();
  460. DressRentalModel.Dsro_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  461. DressRentalModel.Dsro_Number = SysNumber;
  462. DressRentalModel.Dsro_AutoNumber = this.txtOrderNumber.Text.Trim();
  463. DressRentalModel.Dsro_CustomerNumber = StrClientNumber;
  464. DressRentalModel.Dsro_CreateDateTime = StrTime;
  465. DressRentalModel.Dsro_CreateName = this.cmbtreevOrderPerson.Tag.ToString().Trim();
  466. DressRentalModel.Dsro_HandledName = this.StrUserID;
  467. }
  468. DressRentalModel.Dsro_CustomerName = StrClientName;
  469. DressRentalModel.Dsro_CustomerTelephone = StrClientTelephone;
  470. DressRentalModel.Dsro_Type = "2";
  471. DressRentalModel.Dsro_Amount = 0;
  472. DressRentalModel.Dsro_MortgageAmount = 0;
  473. DressRentalModel.Dsro_AutoNumber = this.txtOrderNumber.Text.Trim();
  474. DressRentalModel.Dsro_Remark = this.txtRemark.Text.Trim();
  475. if (!string.IsNullOrEmpty(StrOrderNumber))
  476. { clist.Add(dsrobll.GetUpdateCommandInfo((DressRentalModel))); }
  477. else
  478. { clist.Add(dsrobll.GetAddCommandInfo((DressRentalModel))); }
  479. #endregion
  480. #region 预选礼服详情表
  481. foreach (DictionaryEntry item in htData_del)
  482. {
  483. clist.Add(dsrdbll.GetDeleteCommandInfo("ID", "=", item.Key.ToString().Trim()));
  484. }
  485. for (int i = 0; i < this.listViewData.Items.Count; i++)
  486. {
  487. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressOpenOrderRentSaleFormMain_ColumnHeaderModel modelColumns = (DressOpenOrderRentSaleFormMain_ColumnHeaderModel)this.listViewData.Items[i].Tag;
  488. if (modelColumns.ID <= 0)
  489. {
  490. DressRentalDetailModel = new Model.Model_ErpDressSaleRentalDetail();
  491. DressRentalDetailModel.Dsrd_Number = DressRentalModel.Dsro_Number;
  492. DressRentalDetailModel.Dsrd_DressNumber = this.listViewData.Items[i].ImageKey.ToString().Trim();
  493. DressRentalDetailModel.Dsrd_DressName = this.listViewData.Items[i].SubItems["礼服名称"].Text.Trim();
  494. DressRentalDetailModel.Dsrd_SaleRentalQuantity = Convert.ToInt32(this.listViewData.Items[i].SubItems["礼服数量"].Text.Trim());
  495. DressRentalDetailModel.Dsrd_CostPrice = Convert.ToDecimal(modelColumns.StrCostPrice);
  496. DressRentalDetailModel.Dsrd_SalePrice = Convert.ToDecimal(this.listViewData.Items[i].SubItems["出售价格"].Text.Trim());
  497. DressRentalDetailModel.Dsrd_RentPrice = Convert.ToDecimal(this.listViewData.Items[i].SubItems["出租价格"].Text.Trim());
  498. DressRentalDetailModel.Dsrd_CreateDateTime = StrTime;
  499. DressRentalDetailModel.Dsrd_CreateName = StrUserID;
  500. DressRentalDetailModel.Dsrd_BackTime = Convert.ToDateTime(null);
  501. DressRentalDetailModel.Dsrd_BackRemark = "";
  502. DressRentalDetailModel.Dsrd_BackStatus = "3";
  503. clist.Add(dsrdbll.GetAddCommandInfo(DressRentalDetailModel));
  504. }
  505. }
  506. #endregion
  507. if (clist.Count > 0)
  508. {
  509. if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  510. { return; }
  511. if (LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist) > 0)
  512. {
  513. this.IsSaveed = true;
  514. this.StrOrderNumber = SysNumber;
  515. this.btnTurnRent.Visible = true;
  516. this.btnTurnSale.Visible = true;
  517. MessageBoxCustom.Show("保存成功!");
  518. for (int i = 0; i < this.listViewData.Items.Count; i++)
  519. { this.listViewData.Items[i].ForeColor = Color.Black; }
  520. }
  521. else
  522. { MessageBoxCustom.Show("保存失败!"); }
  523. }
  524. }
  525. /// <summary>
  526. /// 关闭
  527. /// </summary>
  528. /// <param name="sender"></param>
  529. /// <param name="e"></param>
  530. void btnCloseed_Click(object sender, EventArgs e)
  531. {
  532. isClose = false;
  533. if (!isClose)
  534. {
  535. if (MessageBoxCustom.Show("你确定要关闭吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  536. { return; }
  537. }
  538. this.Close();
  539. }
  540. /// <summary>
  541. /// 移除礼服
  542. /// </summary>
  543. /// <param name="sender"></param>
  544. /// <param name="e"></param>
  545. void btnDressDelete_Click(object sender, EventArgs e)
  546. {
  547. if (this.listViewData.Items.Count > 0)
  548. {
  549. if (MessageBoxCustom.Show("删除后无法找回,您确定要删除吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  550. { return; }
  551. List<ListViewItem> delItem = new List<ListViewItem>();
  552. for (int i = 0; i < this.listViewData.SelectedItems.Count; i++)
  553. {
  554. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressOpenOrderRentSaleFormMain_ColumnHeaderModel modelColumn = (DressOpenOrderRentSaleFormMain_ColumnHeaderModel)this.listViewData.SelectedItems[i].Tag;
  555. if (modelColumn.ID > 0)
  556. { this.htData_del[modelColumn.ID] = this.listViewData.SelectedItems[i].ImageKey.ToString().Trim(); }
  557. delItem.Add(this.listViewData.SelectedItems[i]);
  558. }
  559. for (int i = 0; i < delItem.Count; i++)
  560. { this.listViewData.Items.Remove(delItem[i]); }
  561. }
  562. }
  563. /// <summary>
  564. /// 礼服工具箱
  565. /// </summary>
  566. /// <param name="sender"></param>
  567. /// <param name="e"></param>
  568. void btnDressToolbox_Click(object sender, EventArgs e)
  569. {
  570. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.ToolboxDressSamllForm frm = new ToolboxDressSamllForm();
  571. frm.WindowState = FormWindowState.Maximized;
  572. frm.ShowDialog();
  573. if (frm.IsSaveed)
  574. {
  575. List<string> frmList = frm.listSelect;
  576. for (int i = 0; i < this.listViewData.Items.Count; i++)
  577. {
  578. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressOpenOrderRentSaleFormMain_ColumnHeaderModel modelColumn = (DressOpenOrderRentSaleFormMain_ColumnHeaderModel)this.listViewData.Items[i].Tag;
  579. if (frmList.Contains(modelColumn.StrDressNumber.Trim()))
  580. { frmList.Remove(modelColumn.StrDressNumber.Trim()); }
  581. }
  582. if (frmList.Count > 0)
  583. {
  584. string StrWhere = "";
  585. for (int i = 0; i < frmList.Count; i++)
  586. { StrWhere += "'" + frmList[i].Trim() + "',"; }
  587. StrWhere = "Dsfm_DressNumber in (" + StrWhere.TrimEnd(',') + ")";
  588. DataTable dt = orbll.GetView_Custom("tb_ErpDressFrom", StrWhere: StrWhere, ShowColumnName: "Dsfm_DressNumber,Dsfm_DressCustomNumber,Dsfm_DressName,Dsfm_DressSize,Dsfm_CostPrice,Dsfm_RentPrice,Dsfm_SalePrice,Dsfm_DressPhotoNames").Tables[0];
  589. if (dt.Rows.Count > 0)
  590. {
  591. for (int i = 0; i < dt.Rows.Count; i++)
  592. {
  593. string[] StrArrayList = dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim().Split('|');
  594. if (!this.mlistImage.Images.Keys.Contains(dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim()))
  595. {
  596. Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDressImage_Small(StrArrayList[0].Trim());
  597. try
  598. {
  599. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  600. { this.mlistImage.Images.Add(dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim(), img); }));
  601. }
  602. catch
  603. { }
  604. }
  605. ListViewItem lvItem = new ListViewItem();
  606. lvItem.ForeColor = Color.Red;
  607. LYFZ.Software.MainBusiness.Dresses.SetSmallForm.DressOpenOrderRentSaleFormMain_ColumnHeaderModel modelColumn = new DressOpenOrderRentSaleFormMain_ColumnHeaderModel();
  608. modelColumn.StrDressNumber = dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim();
  609. modelColumn.StrCostPrice = dt.Rows[i]["Dsfm_CostPrice"].ToString().Trim();
  610. modelColumn.StrDressPhotoNames = dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim();
  611. modelColumn.ID = 0;
  612. lvItem.Tag = modelColumn;
  613. lvItem.ImageKey = dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim();
  614. lvItem.Text = dt.Rows[i]["Dsfm_DressCustomNumber"].ToString().Trim();
  615. ListViewItem.ListViewSubItem ListSubItem = new ListViewItem.ListViewSubItem();
  616. ListSubItem.Name = "礼服名称";
  617. ListSubItem.Text = dt.Rows[i]["Dsfm_DressName"].ToString().Trim();
  618. lvItem.SubItems.Add(ListSubItem);
  619. ListSubItem = new ListViewItem.ListViewSubItem();
  620. ListSubItem.Name = "礼服尺寸";
  621. ListSubItem.Text = dt.Rows[i]["Dsfm_DressSize"].ToString().Trim();
  622. lvItem.SubItems.Add(ListSubItem);
  623. ListSubItem = new ListViewItem.ListViewSubItem();
  624. ListSubItem.Name = "礼服数量";
  625. ListSubItem.Text = "1";
  626. lvItem.SubItems.Add(ListSubItem);
  627. ListSubItem = new ListViewItem.ListViewSubItem();
  628. ListSubItem.Name = "出租价格";
  629. ListSubItem.Text = dt.Rows[i]["Dsfm_RentPrice"].ToString().Trim();
  630. lvItem.SubItems.Add(ListSubItem);
  631. ListSubItem = new ListViewItem.ListViewSubItem();
  632. ListSubItem.Name = "出售价格";
  633. ListSubItem.Text = dt.Rows[i]["Dsfm_SalePrice"].ToString().Trim();
  634. lvItem.SubItems.Add(ListSubItem);
  635. this.listViewData.Items.Add(lvItem);
  636. }
  637. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.ListViewDrawSingleOrDoubleRows(this.listViewData);
  638. }
  639. }
  640. }
  641. }
  642. /// <summary>
  643. /// 关闭窗体前判断是否提示
  644. /// </summary>
  645. private bool isClose = true;
  646. /// <summary>
  647. /// 关闭是否要跳转
  648. /// </summary>
  649. bool IsGoForm = false;
  650. /// <summary>
  651. /// 关闭窗体前事件
  652. /// </summary>
  653. /// <param name="sender"></param>
  654. /// <param name="e"></param>
  655. void DressOpenOrderFormMain_FormClosing(object sender, FormClosingEventArgs e)
  656. {
  657. if (!this.IsGoForm)
  658. {
  659. if (this.isClose)
  660. {
  661. if (MessageBoxCustom.Show("你确定要关闭吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.No)
  662. { e.Cancel = true; }
  663. }
  664. }
  665. }
  666. /// <summary>
  667. /// 关闭窗体后事件
  668. /// </summary>
  669. /// <param name="sender"></param>
  670. /// <param name="e"></param>
  671. void DressOpenOrderFormMain_FormClosed(object sender, FormClosedEventArgs e)
  672. {
  673. if (this.IsGoForm)
  674. {
  675. this.Hide();
  676. LYFZ.Software.MainBusiness.Dresses.DressOpenOrderFirstFormMain frm = new DressOpenOrderFirstFormMain();
  677. frm.StartPosition = FormStartPosition.CenterScreen;
  678. frm.TopMost = true;
  679. frm.Show();
  680. }
  681. }
  682. }
  683. }