FrmDressManagement.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace LYFZ.Software.MainBusiness.Dresses
  12. {
  13. public partial class FrmDressManagement : LYFZ.Software.UI.Dresses.FrmDressManagement
  14. {
  15. LYFZ.BLL.BLL_ErpOrder orbll = new LYFZ.BLL.BLL_ErpOrder();
  16. LYFZ.BLL.BLL_ErpDressFrom dfbll = new BLL.BLL_ErpDressFrom();
  17. LYFZ.BLL.BLL_ErpSystemConfigure sgbll = new BLL.BLL_ErpSystemConfigure();
  18. LYFZ.BLL.BLL_ErpDressSaleRentalDetail dsrfbll = new BLL.BLL_ErpDressSaleRentalDetail();
  19. public FrmDressManagement()
  20. {
  21. this.Load += FrmDressManagement_Load;
  22. this.listViewData.MouseClick += listViewData_MouseClick;
  23. }
  24. ImageList mlistImage = new ImageList();
  25. public string Type = "";
  26. public string TakeTimeClothes;
  27. public string Qd = "";
  28. /// <summary>
  29. /// 窗体加载事件
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="e"></param>
  33. void FrmDressManagement_Load(object sender, EventArgs e)
  34. {
  35. this.mlistImage.ImageSize = new Size(95, 100);
  36. this.mlistImage.ColorDepth = ColorDepth.Depth32Bit;
  37. this.listViewData.LargeImageList = this.mlistImage;
  38. }
  39. /// <summary>
  40. /// 窗体加载事件
  41. /// </summary>
  42. /// <param name="sender"></param>
  43. /// <param name="e"></param>
  44. protected override void FrmDressManagement_Shown(object sender, EventArgs e)
  45. {
  46. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_SystemCategory("BEAJBGADDCBAHFFA", this.cmbtreevDressType, IsFirstNodeNull: true, IsFirstNodeName: "全部");
  47. //获取回衣天数
  48. this.BindAlsoClothes();
  49. this.btnPreselection.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressManagement, CustomAttributes.OperatingAuthority.Dress_Preselection);
  50. // 礼服租售
  51. this.btnRental.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressManagement, CustomAttributes.OperatingAuthority.Dress_Rental);
  52. this.btnRentalManagement.Enabled = this.btnRental.Enabled;
  53. this.btnSaleManagement.Enabled = this.btnRental.Enabled;
  54. // 礼服送洗
  55. this.btnValet.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.DressManagement, CustomAttributes.OperatingAuthority.Dress_Valet);
  56. this.btnValetMangstar.Enabled = this.btnValet.Enabled;
  57. this.BindPic();
  58. if (Type == "Update")
  59. {
  60. this.btnDetermine.Visible = true;
  61. this.btnPreselection.Visible = false;
  62. this.btnRental.Visible = false;
  63. this.btnValet.Visible = false;
  64. this.btnRentalManagement.Visible = false;
  65. this.btnSaleManagement.Visible = false;
  66. this.btnValetMangstar.Visible = false;
  67. this.txtDayNumber.Visible = false;
  68. this.btnSaveDay.Visible = false;
  69. this.labelEx13.Visible = false;
  70. this.panelEx4.Visible = false;
  71. this.panelEx5.Visible = false;
  72. this.dtTakeDressTime.Text = this.TakeTimeClothes;
  73. MessageBoxCustom.Show("请选择取衣时间,查询礼服,已免礼服撞期!");
  74. }
  75. }
  76. /// <summary>
  77. /// 获取回衣天数
  78. /// </summary>
  79. public void BindAlsoClothes()
  80. {
  81. DataTable dt = sgbll.GetList("Sconfig_Code='AlsoClothesDay'").Tables[0];
  82. if (dt.Rows.Count > 0)
  83. { this.txtDayNumber.Text = dt.Rows[0]["Sconfig_Value"].ToString(); }
  84. else
  85. { this.txtDayNumber.Text = "0"; }
  86. }
  87. /// <summary>
  88. /// 绑定图片
  89. /// </summary>
  90. public void BindPic()
  91. {
  92. if (string.IsNullOrEmpty(this.dtTakeDressTime.DateValue.Trim()))
  93. { this.listViewData.CheckBoxes = false; }
  94. else
  95. { this.listViewData.CheckBoxes = true; }
  96. this.listViewData.Items.Clear();
  97. this.lblPreselected.Text = "";
  98. string StrWhere = "Dsfm_IsEnabled='1' and Dsfm_DressQuantity > 0";
  99. if (!string.IsNullOrEmpty(cmbtreevDressType.Text) && cmbtreevDressType.Text != "全部")
  100. { StrWhere += " and Dsfm_DressType='" + cmbtreevDressType.Tag.ToString() + "' "; }
  101. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  102. {
  103. DataTable dt = orbll.GetView_Custom("tb_ErpDressFrom", StrWhere: StrWhere, ShowColumnName: "Dsfm_DressNumber,Dsfm_DressCustomNumber,Dsfm_DressName,Dsfm_DressPhotoNames").Tables[0];
  104. if (dt.Rows.Count > 0)
  105. {
  106. DataTable dt_DressSaleRentalDetail = orbll.GetView_Custom("View_DressSaleRentalDetail", StrWhere: "Dsro_Type='0' and Dsrd_BackStatus='3'", ShowColumnName: "Dsrd_DressNumber,还衣天数取衣日期,还衣天数加还衣日期").Tables[0];
  107. #region 读取数据
  108. for (int i = 0; i < dt.Rows.Count; i++)
  109. {
  110. bool IsFind = false;
  111. if (!string.IsNullOrEmpty(this.dtTakeDressTime.DateValue))
  112. {
  113. DateTime TakeClothesTime = Convert.ToDateTime(this.dtTakeDressTime.DateValue);//选择取衣时间
  114. DataRow[] row_DSRD = dt_DressSaleRentalDetail.Select(" Dsrd_DressNumber='" + dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim() + "' ");
  115. for (int t = 0; t < row_DSRD.Length; t++)
  116. {
  117. DateTime StarTime = Convert.ToDateTime(row_DSRD[t]["还衣天数取衣日期"]);
  118. DateTime StarEnd = Convert.ToDateTime(row_DSRD[t]["还衣天数加还衣日期"]);
  119. if (TakeClothesTime >= StarTime && TakeClothesTime <= StarEnd)
  120. { IsFind = true; }
  121. }
  122. }
  123. if (!IsFind)
  124. {
  125. string[] StrArrayList = dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim().Split('|');
  126. if (!this.mlistImage.Images.Keys.Contains(dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim()))
  127. {
  128. Image img = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDressImage_Small(StrArrayList[0].Trim());
  129. try
  130. {
  131. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  132. { this.mlistImage.Images.Add(dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim(), img); }));
  133. }
  134. catch
  135. { }
  136. }
  137. ListViewItem lvi = new ListViewItem();
  138. lvi.ImageKey = dt.Rows[i]["Dsfm_DressNumber"].ToString().Trim();
  139. lvi.Tag = dt.Rows[i]["Dsfm_DressPhotoNames"].ToString().Trim();//图片名称
  140. lvi.Text = "编号:" + dt.Rows[i]["Dsfm_DressCustomNumber"].ToString().Trim() + "\r\n名称:" + dt.Rows[i]["Dsfm_DressName"].ToString().Trim();
  141. try
  142. {
  143. this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
  144. {
  145. this.listViewData.Items.Add(lvi);
  146. }));
  147. }
  148. catch
  149. { }
  150. }
  151. }
  152. #endregion
  153. }
  154. });
  155. }
  156. /// <summary>
  157. /// 图片单击事件
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. protected override void lstPic_Click(object sender, EventArgs e)
  162. {
  163. if (this.listViewData.SelectedItems.Count <= 0)
  164. { this.panelEx1.Visible = false; }
  165. else
  166. {
  167. DataTable dt = orbll.GetView_Custom("BView_DressManaged", StrWhere: "Dsfm_DressNumber='" + this.listViewData.SelectedItems[0].ImageKey.ToString().Trim() + "'", ShowColumnName: "Dsfm_DressCustomNumber AS 礼服编号,Dsfm_DressType AS 礼服类别,Dsfm_DressName AS 礼服名称,Dsfm_DressBrand AS 礼服品牌,Dsfm_DressSize AS 礼服尺寸,Dsfm_PlacedRegion AS 摆放区域,Dsfm_RentPrice AS 出租价格,Dsfm_SalePrice AS 出售价格,Dsfm_DressRemark AS 礼服备注").Tables[0];
  168. if (dt.Rows.Count > 0)
  169. {
  170. this.panelEx1.Visible = true;
  171. string StrText = "";
  172. string StrRemark = "";
  173. for (int i = 0; i < dt.Columns.Count; i++)
  174. {
  175. switch (dt.Columns[i].ColumnName.Trim())
  176. {
  177. case "礼服备注":
  178. StrText += dt.Columns[i].ColumnName.Trim() + ":";
  179. StrRemark = dt.Rows[0][i].ToString().Trim();
  180. break;
  181. default:
  182. StrText += dt.Columns[i].ColumnName.Trim() + ":" + dt.Rows[0][i].ToString().Trim() + "\r\n\r\n";
  183. break;
  184. }
  185. }
  186. this.lblDressDetails.Text = StrText;
  187. this.txtDressRemark.Text = StrRemark;
  188. this.txtDressRemark.Location = new Point(this.lblDressDetails.Location.X + 3, this.lblDressDetails.Location.Y + this.lblDressDetails.Height + 5);
  189. this.txtDressRemark.Height = this.panelEx1.Height - this.txtDressRemark.Location.Y - 5;
  190. }
  191. }
  192. }
  193. /// <summary>
  194. /// 图片单击事件
  195. /// </summary>
  196. /// <param name="sender"></param>
  197. /// <param name="e"></param>
  198. void listViewData_MouseClick(object sender, MouseEventArgs e)
  199. {
  200. this.lstPic_Click(this, null);
  201. }
  202. /// <summary>
  203. /// 选中事件
  204. /// </summary>
  205. /// <param name="sender"></param>
  206. /// <param name="e"></param>
  207. protected override void lstPic_ItemChecked(object sender, ItemCheckedEventArgs e)
  208. {
  209. string Check = "";
  210. if (this.listViewData.CheckedItems.Count > 0)
  211. {
  212. this.txtok.Text = "";
  213. this.txtok.Text = this.listViewData.CheckedItems[0].ImageKey.ToString().Trim();
  214. for (int i = 0; i < this.listViewData.CheckedItems.Count; i++)
  215. {
  216. Check += this.listViewData.CheckedItems[i].ImageKey.ToString().Trim() + ",";
  217. }
  218. this.txtok.Text = Check.TrimEnd(',');
  219. }
  220. else
  221. { this.txtok.Text = ""; }
  222. }
  223. /// <summary>
  224. /// 查看详情隐藏
  225. /// </summary>
  226. /// <param name="sender"></param>
  227. /// <param name="e"></param>
  228. protected override void lstPic_MouseUp(object sender, MouseEventArgs e)
  229. {
  230. if (this.listViewData.SelectedItems.Count <= 0)
  231. { this.panelEx1.Visible = false; }
  232. }
  233. /// <summary>
  234. /// 取消
  235. /// </summary>
  236. /// <param name="sender"></param>
  237. /// <param name="e"></param>
  238. protected override void toolCancel_Click(object sender, EventArgs e)
  239. {
  240. if (this.listViewData.SelectedItems.Count > 0)
  241. {
  242. for (int i = 0; i < this.listViewData.SelectedItems.Count; i++)
  243. {
  244. this.listViewData.SelectedItems[i].Checked = false;
  245. }
  246. }
  247. if (this.listViewData.CheckedItems.Count > 0)
  248. {
  249. string Check = "";
  250. for (int i = 0; i < this.listViewData.CheckedItems.Count; i++)
  251. {
  252. Check += this.listViewData.CheckedItems[i].ImageKey.ToString().Trim() + ",";
  253. }
  254. this.txtok.Text = Check.TrimEnd(',');
  255. }
  256. else
  257. { this.txtok.Text = ""; }
  258. }
  259. /// <summary>
  260. /// 选中
  261. /// </summary>
  262. /// <param name="sender"></param>
  263. /// <param name="e"></param>
  264. protected override void toolSelected_Click(object sender, EventArgs e)
  265. {
  266. if (this.listViewData.SelectedItems.Count > 0)
  267. {
  268. for (int i = 0; i < this.listViewData.SelectedItems.Count; i++)
  269. { this.listViewData.SelectedItems[i].Checked = true; }
  270. }
  271. if (this.listViewData.CheckedItems.Count > 0)
  272. {
  273. string Check = "";
  274. for (int i = 0; i < this.listViewData.CheckedItems.Count; i++)
  275. { Check += this.listViewData.CheckedItems[i].ImageKey.ToString().Trim() + ","; }
  276. this.txtok.Text = Check.TrimEnd(',');
  277. }
  278. else
  279. { this.txtok.Text = ""; }
  280. }
  281. /// <summary>
  282. /// 预选
  283. /// </summary>
  284. /// <param name="sender"></param>
  285. /// <param name="e"></param>
  286. protected override void btnPreselection_Click(object sender, EventArgs e)
  287. {
  288. LYFZ.Software.MainBusiness.Dresses.DressManagement.FrmPreselection set = new DressManagement.FrmPreselection();
  289. set.Dsfm_DressNumber = this.txtok.Text;
  290. if (set.ShowDialog() == DialogResult.OK)
  291. { this.BindPic(); }
  292. // 预选选择
  293. if (set.list.Count > 0)
  294. {
  295. if (this.listViewData.Items.Count > 0)
  296. {
  297. #region 清空数据
  298. for (int i = 0; i < this.listViewData.Items.Count; i++)
  299. {
  300. this.listViewData.Items[i].Checked = false;
  301. }
  302. #endregion
  303. #region 赋值
  304. for (int t = 0; t < set.list.Count; t++)
  305. {
  306. for (int i = 0; i < this.listViewData.Items.Count; i++)
  307. {
  308. if (set.list[t] == this.listViewData.Items[i].Tag.ToString())
  309. {
  310. this.listViewData.Items[i].Checked = true;
  311. }
  312. }
  313. }
  314. #endregion
  315. this.lblPreselected.Text = "";
  316. this.lblPreselected.Text = set.PreselectedNumber;
  317. this.cmbtreevDressType.Text = "";
  318. }
  319. }
  320. this.dtTakeDressTime.DateValue = "";
  321. }
  322. /// <summary>
  323. /// 出租/出售
  324. /// </summary>
  325. /// <param name="sender"></param>
  326. /// <param name="e"></param>
  327. protected override void btnRental_Click(object sender, EventArgs e)
  328. {
  329. if (string.IsNullOrEmpty(this.dtTakeDressTime.DateValue))
  330. {
  331. MessageBoxCustom.Show("取衣时间不能为空!");
  332. return;
  333. }
  334. LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental.FrmDressRental set = new DressManagement.Rental.FrmDressRental();
  335. set.Dsfm_DressNumber = this.txtok.Text;
  336. set.PreselectedNumber_OK = this.lblPreselected.Text;
  337. if (set.ShowDialog() == DialogResult.OK)
  338. { this.BindPic(); }
  339. }
  340. /// <summary>
  341. /// 送洗
  342. /// </summary>
  343. /// <param name="sender"></param>
  344. /// <param name="e"></param>
  345. protected override void btnValet_Click(object sender, EventArgs e)
  346. {
  347. if (string.IsNullOrEmpty(this.dtTakeDressTime.DateValue))
  348. {
  349. MessageBoxCustom.Show("取衣时间不能为空!");
  350. return;
  351. }
  352. LYFZ.Software.MainBusiness.Dresses.DressManagement.Valet.FrmDressValet set = new DressManagement.Valet.FrmDressValet();
  353. set.Dsfm_DressNumber = this.txtok.Text;
  354. if (set.ShowDialog() == DialogResult.OK)
  355. {
  356. this.BindPic();
  357. }
  358. }
  359. /// <summary>
  360. /// 输入框设置
  361. /// </summary>
  362. /// <param name="sender"></param>
  363. /// <param name="e"></param>
  364. protected override void txtDayNumber_KeyPress(object sender, KeyPressEventArgs e)
  365. {
  366. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  367. { e.Handled = true; }
  368. }
  369. /// <summary>
  370. /// 保存还衣天数
  371. /// </summary>
  372. /// <param name="sender"></param>
  373. /// <param name="e"></param>
  374. protected override void btnSaveDay_Click(object sender, EventArgs e)
  375. {
  376. LYFZ.Model.Model_ErpSystemConfigure Model = new Model.Model_ErpSystemConfigure();
  377. DataTable dt = sgbll.GetList("Sconfig_Code='AlsoClothesDay'").Tables[0];
  378. if ((dt.Rows.Count == 0))
  379. {
  380. #region 增加
  381. Model.Sconfig_Code = "AlsoClothesDay";
  382. Model.Sconfig_Name = "回衣天数";
  383. Model.Sconfig_Value = this.txtDayNumber.Text.Trim();
  384. Model.Sconfig_IsEnabled = true;
  385. Model.Sconfig_Remark = "礼服管理衣服还回天数设置";
  386. Model.Sconfig_Type = "";
  387. Model.Sconfig_Order = 1;
  388. Model.Sconfig_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  389. sgbll.Add(Model);
  390. #endregion
  391. }
  392. else
  393. {
  394. #region 修改
  395. sgbll.UpdateErpSystemConfigure("Sconfig_Value='" + this.txtDayNumber.Text.Trim() + "'", "AlsoClothesDay");
  396. #endregion
  397. }
  398. MessageBoxCustom.Show("保存成功!");
  399. this.BindAlsoClothes();
  400. }
  401. /// <summary>
  402. /// 查询
  403. /// </summary>
  404. /// <param name="sender"></param>
  405. /// <param name="e"></param>
  406. protected override void btnSlect_Click(object sender, EventArgs e)
  407. {
  408. this.BindPic();
  409. }
  410. /// <summary>
  411. /// 查看原图
  412. /// </summary>
  413. /// <param name="sender"></param>
  414. /// <param name="e"></param>
  415. protected override void toolpic_Click(object sender, EventArgs e)
  416. {
  417. if (this.listViewData.Items.Count > 0)
  418. {
  419. if (this.listViewData.SelectedItems.Count > 0)
  420. {
  421. string[] StrArrayList = this.listViewData.SelectedItems[0].Tag.ToString().Trim().Split('|');
  422. LYFZ.Software.MainBusiness.InitialSet.Product.FrmProductPic frm = new InitialSet.Product.FrmProductPic();
  423. frm.FrmImage = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDressImage_Small(StrArrayList[0].Trim());
  424. frm.ShowDialog();
  425. }
  426. }
  427. }
  428. /// <summary>
  429. /// 双击事件
  430. /// </summary>
  431. /// <param name="sender"></param>
  432. /// <param name="e"></param>
  433. protected override void lstPic_DoubleClick(object sender, EventArgs e)
  434. {
  435. this.toolpic_Click(this, null);
  436. }
  437. /// <summary>
  438. /// 出租管理
  439. /// </summary>
  440. /// <param name="sender"></param>
  441. /// <param name="e"></param>
  442. protected override void btnRentalManagement_Click(object sender, EventArgs e)
  443. {
  444. LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental.FrmRentalManagement set = new DressManagement.Rental.FrmRentalManagement();
  445. set.ShowDialog();
  446. }
  447. /// <summary>
  448. /// 出售管理
  449. /// </summary>
  450. /// <param name="sender"></param>
  451. /// <param name="e"></param>
  452. protected override void btnSaleManagement_Click(object sender, EventArgs e)
  453. {
  454. LYFZ.Software.MainBusiness.Dresses.DressManagement.Rental.FrmSaleManagement set = new DressManagement.Rental.FrmSaleManagement();
  455. set.ShowDialog();
  456. }
  457. /// <summary>
  458. /// 送洗管理
  459. /// </summary>
  460. /// <param name="sender"></param>
  461. /// <param name="e"></param>
  462. protected override void btnValetMangstar_Click(object sender, EventArgs e)
  463. {
  464. LYFZ.Software.MainBusiness.Dresses.DressManagement.Valet.FrmValetManagement set = new DressManagement.Valet.FrmValetManagement();
  465. set.ShowDialog();
  466. }
  467. /// <summary>
  468. /// 确定
  469. /// </summary>
  470. /// <param name="sender"></param>
  471. /// <param name="e"></param>
  472. protected override void btnDetermine_Click(object sender, EventArgs e)
  473. {
  474. LYFZ.Software.MainBusiness.Dresses.DressManagement.FrmPreselectedUpdate set = new DressManagement.FrmPreselectedUpdate();
  475. if (string.IsNullOrEmpty(this.txtok.Text))
  476. {
  477. MessageBoxCustom.Show("请选择礼服!");
  478. return;
  479. }
  480. this.Qd = this.txtok.Text;
  481. this.Close();
  482. }
  483. }
  484. }