FrmEntry.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Imaging;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace LYFZ.Software.MainBusiness.Dresses.DressEntry
  12. {
  13. public partial class FrmEntry : LYFZ.Software.UI.Dresses.DressEntry.FrmEntry
  14. {
  15. Image imgdelete = null;
  16. public string Type = "";
  17. public string Dsfm_DressNumber = "";
  18. bool bl = false;
  19. public FrmEntry()
  20. {
  21. this.FormClosed += FrmEntry_FormClosed;
  22. }
  23. void FrmEntry_FormClosed(object sender, FormClosedEventArgs e)
  24. {
  25. if (bl)
  26. {
  27. this.DialogResult = DialogResult.OK;
  28. }
  29. }
  30. public void ShowImage(string path)
  31. {
  32. if ((this.picDsfm_PicturePath.Image != null)) //先释放
  33. {
  34. picDsfm_PicturePath.Image.Dispose();
  35. picDsfm_PicturePath.Image = null;
  36. }
  37. if (System.IO.File.Exists(path))
  38. {
  39. Image img = Image.FromFile(path); //加载图片
  40. MemoryStream mstr = new MemoryStream(); //创建新的MemoryStream
  41. img.Save(mstr, ImageFormat.Gif); // 保存这个对象
  42. picDsfm_PicturePath.Image = Image.FromStream(mstr); //显示
  43. img.Dispose();//释放占用
  44. }
  45. }
  46. #region 加载
  47. protected override void FrmEntry_Shown(object sender, EventArgs e)
  48. {
  49. try
  50. {
  51. //获取礼服编号
  52. Random action = new Random();
  53. txtDsfm_DressNumber.Text = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + "1";//获取新编号
  54. BindDsfm_DressType();
  55. GetDsfm_PlacedRegion();
  56. #region 修改
  57. if (Type == "Update")
  58. {
  59. if (!string.IsNullOrEmpty(Dsfm_DressNumber))
  60. {
  61. txtDsfm_DressNumber.Enabled = false;
  62. LYFZ.BLL.BLL_ErpDressFrom DressFromBll = new BLL.BLL_ErpDressFrom();
  63. DataTable dt = DressFromBll.GetList("Dsfm_DressNumber='" + Dsfm_DressNumber + "' ").Tables[0];
  64. if (dt.Rows.Count > 0)
  65. {
  66. txtDsfm_DressNumber.Text = Dsfm_DressNumber;
  67. CtvDsfm_DressType.TagFindText(dt.Rows[0]["Dsfm_DressType"].ToString());
  68. cmbDsfm_PlacedRegion.SelectedValue = dt.Rows[0]["Dsfm_PlacedRegion"].ToString();
  69. txtDsfm_DressName.Text = dt.Rows[0]["Dsfm_DressName"].ToString();
  70. txtDsfm_DressBrand.Text = dt.Rows[0]["Dsfm_DressBrand"].ToString();
  71. txtDsfm_DressSize.Text = dt.Rows[0]["Dsfm_DressSize"].ToString();
  72. txtDsfm_DressQuantity.Text = dt.Rows[0]["Dsfm_DressQuantity"].ToString();
  73. txtDsfm_CostPrice.Text = dt.Rows[0]["Dsfm_CostPrice"].ToString();
  74. txtDsfm_RentPrice.Text = dt.Rows[0]["Dsfm_RentPrice"].ToString();
  75. txtDsfm_SalePrice.Text = dt.Rows[0]["Dsfm_SalePrice"].ToString();
  76. if (dt.Rows[0]["Dsfm_IsEnabled"].ToString() == "1")
  77. {
  78. radDsfm_IsEnabled1.Checked = true;
  79. }
  80. else { radDsfm_IsEnabled2.Checked = true; }
  81. txtDsfm_DressRemark.Text = dt.Rows[0]["Dsfm_DressRemark"].ToString();
  82. ShowImage(BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + dt.Rows[0]["Dsfm_PicturePath"]);
  83. }
  84. }
  85. }
  86. #endregion
  87. }
  88. catch (Exception ex)
  89. {
  90. MessageBoxCustom.Show(ex.Message);
  91. }
  92. }
  93. #endregion
  94. #region 设置
  95. protected override void btnDsfm_PlacedRegion_Click(object sender, EventArgs e)
  96. {
  97. try
  98. {
  99. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
  100. LYFZ.BLL.BLL_ErpSystemCategory bll = new BLL.BLL_ErpSystemCategory();
  101. DataTable dt = bll.GetList("Sc_ClassCode='BEAJBGADBHCCHEFEI'").Tables[0];
  102. if (dt.Rows.Count > 0)
  103. {
  104. set.TypeName = dt.Rows[0]["Sc_ClassCode"].ToString();
  105. }
  106. set.Version = "Version";
  107. if (set.ShowDialog() == DialogResult.OK)
  108. {
  109. GetDsfm_PlacedRegion();
  110. }
  111. }
  112. catch (Exception ex)
  113. {
  114. MessageBoxCustom.Show(ex.Message);
  115. }
  116. }
  117. protected override void btnDsfm_DressType_Click(object sender, EventArgs e)
  118. {
  119. try
  120. {
  121. LYFZ.Software.MainBusiness.InitialSet.FrmSystemSet set = new InitialSet.FrmSystemSet();
  122. LYFZ.BLL.BLL_ErpSystemCategory bll = new BLL.BLL_ErpSystemCategory();
  123. DataTable dt = bll.GetList("Sc_ClassCode='BEAJBGADDCBAHFFA'").Tables[0];
  124. if (dt.Rows.Count > 0)
  125. {
  126. set.TypeName = dt.Rows[0]["Sc_ClassCode"].ToString();
  127. }
  128. set.Version = "Version";
  129. if (set.ShowDialog() == DialogResult.OK)
  130. {
  131. BindDsfm_DressType();
  132. }
  133. }
  134. catch (Exception ex)
  135. {
  136. MessageBoxCustom.Show(ex.Message);
  137. }
  138. }
  139. #endregion
  140. string PhotoFilePath = "";
  141. #region 上传
  142. protected override void btnUpload_Click(object sender, EventArgs e)
  143. {
  144. openFileDialog1.Filter = "图片文件(*.jpg)|*.jpg|图片文件(*.gif)|*.gif|图片文件(*.bmp)|*.bmp|图片文件(*.png)|*.png";
  145. openFileDialog1.FileName = "";
  146. if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  147. {
  148. PhotoFilePath = openFileDialog1.FileName;
  149. //this.picDsfm_PicturePath.Image = Image.FromFile(PhotoFilePath);
  150. imgdelete = Image.FromFile(PhotoFilePath);
  151. picDsfm_PicturePath.Image = imgdelete;
  152. }
  153. if (Type == "Update")
  154. {
  155. lblUpload.Text = PhotoFilePath;
  156. }
  157. }
  158. #endregion
  159. #region 输入框限制
  160. protected override void txtDsfm_SalePrice_KeyPress(object sender, KeyPressEventArgs e)
  161. {
  162. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  163. {
  164. e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
  165. }
  166. else if (Char.IsPunctuation(e.KeyChar))
  167. {
  168. if (e.KeyChar == '.')
  169. {
  170. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  171. {
  172. e.Handled = true;
  173. }
  174. }
  175. else
  176. {
  177. e.Handled = true;
  178. }
  179. }
  180. }
  181. protected override void txtDsfm_RentPrice_KeyPress(object sender, KeyPressEventArgs e)
  182. {
  183. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  184. {
  185. e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
  186. }
  187. else if (Char.IsPunctuation(e.KeyChar))
  188. {
  189. if (e.KeyChar == '.')
  190. {
  191. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  192. {
  193. e.Handled = true;
  194. }
  195. }
  196. else
  197. {
  198. e.Handled = true;
  199. }
  200. }
  201. }
  202. protected override void txtDsfm_CostPrice_KeyPress(object sender, KeyPressEventArgs e)
  203. {
  204. if (!Char.IsNumber(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar))
  205. {
  206. e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
  207. }
  208. else if (Char.IsPunctuation(e.KeyChar))
  209. {
  210. if (e.KeyChar == '.')
  211. {
  212. if (((System.Windows.Forms.TextBox)sender).Text.LastIndexOf('.') != -1)
  213. {
  214. e.Handled = true;
  215. }
  216. }
  217. else
  218. {
  219. e.Handled = true;
  220. }
  221. }
  222. }
  223. protected override void txtDsfm_DressQuantity_KeyPress(object sender, KeyPressEventArgs e)
  224. {
  225. if (!Char.IsNumber(e.KeyChar) && !Char.IsControl(e.KeyChar))
  226. {
  227. e.Handled = true;
  228. }
  229. }
  230. #endregion
  231. #region 关闭
  232. protected override void btnClose_Click(object sender, EventArgs e)
  233. {
  234. this.Close();
  235. }
  236. #endregion
  237. #region 清空
  238. protected override void btnClear_Click(object sender, EventArgs e)
  239. {
  240. CtvDsfm_DressType.Text = "";
  241. cmbDsfm_PlacedRegion.Text = "";
  242. Clear();
  243. }
  244. public void Clear()
  245. {
  246. //获取礼服编号
  247. Random action = new Random();
  248. txtDsfm_DressNumber.Text = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + "1";//获取新编号
  249. txtDsfm_DressName.Text = "";
  250. txtDsfm_DressBrand.Text = "";
  251. txtDsfm_DressSize.Text = "";
  252. txtDsfm_DressQuantity.Text = "1";
  253. txtDsfm_CostPrice.Text = "";
  254. txtDsfm_RentPrice.Text = "";
  255. txtDsfm_SalePrice.Text = "";
  256. radDsfm_IsEnabled1.Checked = true;
  257. txtDsfm_DressRemark.Text = "";
  258. PhotoFilePath = "";
  259. picDsfm_PicturePath.Image = null;
  260. }
  261. #endregion
  262. #region 保存
  263. protected override void btnSave_Click(object sender, EventArgs e)
  264. {
  265. try
  266. {
  267. DataTable dt = new DataTable();
  268. LYFZ.BLL.BLL_ErpDressFrom DressBll = new BLL.BLL_ErpDressFrom();
  269. LYFZ.Model.Model_ErpDressFrom model = new Model.Model_ErpDressFrom();
  270. #region 输入框
  271. if (string.IsNullOrEmpty(CtvDsfm_DressType.Text))
  272. {
  273. MessageBoxCustom.Show("礼服类别不能为空!");
  274. return;
  275. }
  276. if (string.IsNullOrEmpty(cmbDsfm_PlacedRegion.Text))
  277. {
  278. MessageBoxCustom.Show("摆放区域不能为空!");
  279. return;
  280. }
  281. if (string.IsNullOrEmpty(txtDsfm_DressName.Text))
  282. {
  283. MessageBoxCustom.Show("礼服名称不能为空!");
  284. return;
  285. }
  286. if (string.IsNullOrEmpty(txtDsfm_DressQuantity.Text))
  287. {
  288. MessageBoxCustom.Show("礼服数量不能为空!");
  289. return;
  290. }
  291. if (Convert.ToInt32(txtDsfm_DressQuantity.Text) > 1)
  292. {
  293. MessageBoxCustom.Show("礼服数量不能大于1!");
  294. return;
  295. }
  296. if (string.IsNullOrEmpty(txtDsfm_CostPrice.Text))
  297. {
  298. MessageBoxCustom.Show("成本价格不能为空!");
  299. return;
  300. }
  301. if (string.IsNullOrEmpty(txtDsfm_RentPrice.Text))
  302. {
  303. MessageBoxCustom.Show("出租价格不能为空!");
  304. return;
  305. }
  306. if (string.IsNullOrEmpty(txtDsfm_SalePrice.Text))
  307. {
  308. MessageBoxCustom.Show("出售价格不能为空!");
  309. return;
  310. }
  311. /* if (picDsfm_PicturePath.Image == null)
  312. {
  313. MessageBoxCustom.Show("礼服图片不能为空!");
  314. return;
  315. }*/
  316. #endregion
  317. #region 增加
  318. if (Type == "Add")
  319. {
  320. #region 保存
  321. #region 判断礼服编号是否存在
  322. if (DressBll.Exists("Dsfm_DressNumber", this.txtDsfm_DressNumber.Text) == true)
  323. {
  324. MessageBoxCustom.Show("礼服编号已经存在!请刷新重新获取!");
  325. return;
  326. }
  327. #endregion
  328. model.Dsfm_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID();
  329. model.Dsfm_DressNumber = txtDsfm_DressNumber.Text.Trim();
  330. model.Dsfm_DressType = CtvDsfm_DressType.Tag.ToString();
  331. model.Dsfm_DressName = txtDsfm_DressName.Text.Trim();
  332. model.Dsfm_DressBrand = txtDsfm_DressBrand.Text.Trim();
  333. model.Dsfm_DressSize = txtDsfm_DressSize.Text.Trim();
  334. model.Dsfm_DressQuantity = Convert.ToInt32(txtDsfm_DressQuantity.Text.Trim());
  335. model.Dsfm_CostPrice = Convert.ToDecimal(txtDsfm_CostPrice.Text.Trim());
  336. model.Dsfm_RentPrice = Convert.ToDecimal(txtDsfm_RentPrice.Text.Trim());
  337. model.Dsfm_SalePrice = Convert.ToDecimal(txtDsfm_SalePrice.Text.Trim());
  338. if (radDsfm_IsEnabled1.Checked == true)
  339. {
  340. model.Dsfm_IsEnabled = "1";
  341. }
  342. else { model.Dsfm_IsEnabled = "0"; }
  343. model.Dsfm_PlacedRegion = cmbDsfm_PlacedRegion.SelectedValue.ToString();
  344. #region 增加礼服图片
  345. dt = DressBll.GetList("Dsfm_DressNumber='" + model.Dsfm_DressNumber + "'").Tables[0];
  346. if (dt.Rows.Count == 0)
  347. {
  348. if (!string.IsNullOrEmpty(PhotoFilePath))
  349. {
  350. #region 选择图片
  351. //原图
  352. string paths = Path.GetExtension(PhotoFilePath);
  353. string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
  354. File.Copy(PhotoFilePath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
  355. model.Dsfm_PicturePath = path;
  356. //缩略图
  357. path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
  358. ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(PhotoFilePath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
  359. #endregion
  360. }
  361. else
  362. {
  363. #region 默认图片
  364. //原图
  365. string paths = ".png";//Path.GetExtension(imgPath);
  366. string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
  367. // File.Copy(imgPath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
  368. model.Dsfm_PicturePath = path;
  369. //缩略图
  370. // path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
  371. // ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(imgPath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
  372. #endregion
  373. }
  374. }
  375. #endregion
  376. model.Dsfm_DressRemark = txtDsfm_DressRemark.Text.Trim();
  377. model.Dsfm_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  378. model.Dsfm_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  379. if (DressBll.Add(model) == true)
  380. {
  381. if (picDsfm_PicturePath.Image != null)
  382. picDsfm_PicturePath.Image.Dispose();
  383. MessageBoxCustom.Show("保存成功!");
  384. bl = true;
  385. Clear();
  386. }
  387. else { MessageBoxCustom.Show("保存失败!"); }
  388. return;
  389. #region 数量大于1
  390. //if (Convert.ToInt32(txtDsfm_DressQuantity.Text) > 1)
  391. //{
  392. // int sum = Convert.ToInt32(txtDsfm_DressQuantity.Text);
  393. // for (int i = 0; i < sum; i++)
  394. // {
  395. // model.Dsfm_DressNumber = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + i;//获取新编号
  396. // model.Dsfm_DressType = CtvDsfm_DressType.Tag.ToString();
  397. // model.Dsfm_DressName = txtDsfm_DressName.Text.Trim();
  398. // model.Dsfm_DressBrand = txtDsfm_DressBrand.Text.Trim();
  399. // model.Dsfm_DressSize = txtDsfm_DressSize.Text.Trim();
  400. // model.Dsfm_DressQuantity =1;
  401. // model.Dsfm_CostPrice = Convert.ToDecimal(txtDsfm_CostPrice.Text.Trim());
  402. // model.Dsfm_RentPrice = Convert.ToDecimal(txtDsfm_RentPrice.Text.Trim());
  403. // model.Dsfm_SalePrice = Convert.ToDecimal(txtDsfm_SalePrice.Text.Trim());
  404. // if (radDsfm_IsEnabled1.Checked == true)
  405. // {
  406. // model.Dsfm_IsEnabled = "1";
  407. // }
  408. // else { model.Dsfm_IsEnabled = "0"; }
  409. // model.Dsfm_PlacedRegion = cmbDsfm_PlacedRegion.SelectedValue.ToString();
  410. // #region 增加礼服图片
  411. // dt = DressBll.GetList("Dsfm_DressNumber='" + model.Dsfm_DressNumber + "'").Tables[0];
  412. // if (dt.Rows.Count == 0)
  413. // {
  414. // if (!string.IsNullOrEmpty(PhotoFilePath))
  415. // {
  416. // #region 选择图片
  417. // //原图
  418. // string paths = Path.GetExtension(PhotoFilePath);
  419. // string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
  420. // File.Copy(PhotoFilePath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
  421. // model.Dsfm_PicturePath = path;
  422. // //缩略图
  423. // path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
  424. // ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(PhotoFilePath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
  425. // #endregion
  426. // }
  427. // else
  428. // {
  429. // #region 默认图片
  430. // //原图
  431. // string paths = ".png"; //Path.GetExtension(imgPath);
  432. // string path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")" + paths;
  433. // // File.Copy(imgPath, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
  434. // model.Dsfm_PicturePath = path;
  435. // //缩略图
  436. // path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
  437. // // ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(imgPath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
  438. // #endregion
  439. // }
  440. // }
  441. // #endregion
  442. // model.Dsfm_DressRemark = txtDsfm_DressRemark.Text.Trim();
  443. // model.Dsfm_CreateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  444. // model.Dsfm_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  445. // DressBll.Add(model);
  446. // }
  447. // if (picDsfm_PicturePath.Image != null)
  448. // picDsfm_PicturePath.Image.Dispose();
  449. // MessageBoxCustom.Show("保存成功!");
  450. // bl = true;
  451. // Clear();
  452. //}
  453. #endregion
  454. #endregion
  455. }
  456. #endregion
  457. #region 修改
  458. if (Type == "Update")
  459. {
  460. dt = new DataTable();
  461. dt = DressBll.GetList("Dsfm_DressNumber='" + Dsfm_DressNumber + "'").Tables[0];
  462. int Id = Convert.ToInt32(dt.Rows[0]["ID"]);
  463. model = DressBll.GetModel(Id);
  464. model.Dsfm_DressType = CtvDsfm_DressType.Tag.ToString();
  465. model.Dsfm_DressName = txtDsfm_DressName.Text.Trim();
  466. model.Dsfm_DressBrand = txtDsfm_DressBrand.Text.Trim();
  467. model.Dsfm_DressSize = txtDsfm_DressSize.Text.Trim();
  468. model.Dsfm_DressQuantity = Convert.ToInt32(txtDsfm_DressQuantity.Text.Trim());
  469. model.Dsfm_CostPrice = Convert.ToDecimal(txtDsfm_CostPrice.Text.Trim());
  470. model.Dsfm_RentPrice = Convert.ToDecimal(txtDsfm_RentPrice.Text.Trim());
  471. model.Dsfm_SalePrice = Convert.ToDecimal(txtDsfm_SalePrice.Text.Trim());
  472. if (radDsfm_IsEnabled1.Checked == true)
  473. {
  474. model.Dsfm_IsEnabled = "1";
  475. }
  476. else { model.Dsfm_IsEnabled = "0"; }
  477. model.Dsfm_PlacedRegion = cmbDsfm_PlacedRegion.SelectedValue.ToString();
  478. model.Dsfm_DressRemark = txtDsfm_DressRemark.Text.Trim();
  479. model.Dsfm_UpdateDateTime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
  480. model.Dsfm_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  481. #region 修改图片
  482. if (!string.IsNullOrEmpty(lblUpload.Text))
  483. {
  484. string Dsfm_PicturePath = dt.Rows[0]["Dsfm_PicturePath"].ToString();
  485. //删除原图
  486. File.Delete((BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + dt.Rows[0]["Dsfm_PicturePath"]));
  487. //删除缩略图
  488. char[] pathst = Path.GetExtension(Dsfm_PicturePath).ToCharArray();
  489. Dsfm_PicturePath = Dsfm_PicturePath.TrimEnd(pathst);
  490. File.Delete(BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + Dsfm_PicturePath + "&Small" + Path.GetExtension(dt.Rows[0]["Dsfm_PicturePath"].ToString()));
  491. //增加原图
  492. string paths = Path.GetExtension(lblUpload.Text);
  493. string path = txtDsfm_DressName.Text + "(" + Dsfm_DressNumber + ")" + paths;
  494. File.Copy(lblUpload.Text, BLL.BLL_ErpDressFrom.GetDressFromPath() + "\\" + path);
  495. model.Dsfm_PicturePath = path;
  496. //增加缩略图
  497. path = txtDsfm_DressName.Text + "(" + model.Dsfm_DressNumber + ")&Small" + paths;
  498. ImageFunction.ThumbImgae.SaveIamge(LYFZ.ImageFunction.ThumbImgae.Thumbnail(new Bitmap(PhotoFilePath), new Size(100, 100), ImageFunction.ThumbImgae.ThumbMode.W), 98L, BLL.BLL_ErpDressFrom.GetDressFromPathSmall() + "\\" + path);
  499. }
  500. #endregion
  501. if (DressBll.Update(model) == true)
  502. {
  503. MessageBoxCustom.Show("保存成功!");
  504. bl = true;
  505. this.Close();
  506. }
  507. else { MessageBoxCustom.Show("保存失败!"); }
  508. }
  509. #endregion
  510. }
  511. catch (Exception ex)
  512. {
  513. MessageBoxCustom.Show(ex.Message);
  514. }
  515. }
  516. #endregion
  517. #region 绑定礼服类别
  518. /// <summary>
  519. /// 绑定礼服类别
  520. /// </summary>
  521. public void BindDsfm_DressType()
  522. {
  523. CtvDsfm_DressType.TreeView.Nodes.Clear();
  524. #region 绑定二级礼服类别
  525. LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
  526. DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID='59'").Tables[0];
  527. if (tbl.Rows.Count > 0)
  528. {
  529. TreeNode root = null;
  530. for (int i = 0; i < tbl.Rows.Count; i++)
  531. {
  532. root = new TreeNode();
  533. root.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
  534. root.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
  535. this.CreateTreeViewShop(root.Nodes, tbl.Rows[i]["ID"].ToString());
  536. this.CtvDsfm_DressType.TreeView.Nodes.Add(root);
  537. }
  538. }
  539. #endregion
  540. }
  541. private void CreateTreeViewShop(TreeNodeCollection nodes, string ClassCode)
  542. {
  543. if (ClassCode != "")
  544. {
  545. LYFZ.BLL.BLL_ErpSystemCategory BLLSystemCategory = new BLL.BLL_ErpSystemCategory();
  546. DataTable tbl = BLLSystemCategory.GetList("Sc_ClassParentID=" + ClassCode + "").Tables[0];
  547. if (tbl.Rows.Count > 0)
  548. {
  549. TreeNode node;
  550. for (int i = 0; i < tbl.Rows.Count; i++)
  551. {
  552. node = new TreeNode();
  553. node.Text = tbl.Rows[i]["Sc_ClassName"].ToString();
  554. node.Tag = tbl.Rows[i]["Sc_ClassCode"].ToString();
  555. nodes.Add(node);
  556. }
  557. }
  558. }
  559. }
  560. #endregion
  561. #region 绑定摆放区域
  562. /// <summary>
  563. /// 绑定摆放区域
  564. /// </summary>
  565. public void GetDsfm_PlacedRegion()
  566. {
  567. DataTable dt = new DataTable();
  568. #region 绑定摆放区域
  569. LYFZ.BLL.BLL_ErpSystemCategory SystemCategorybll = new BLL.BLL_ErpSystemCategory();
  570. DataTable dt2 = new DataTable();
  571. DataRow dr = dt.NewRow();
  572. dt2 = SystemCategorybll.GetList("Sc_ClassCode='BEAJBGADBHCCHEFEI'").Tables[0];
  573. dt = SystemCategorybll.GetList("Sc_ClassParentID=" + dt2.Rows[0]["ID"] + "").Tables[0];
  574. cmbDsfm_PlacedRegion.DataSource = dt;
  575. this.cmbDsfm_PlacedRegion.ValueMember = "Sc_ClassCode";
  576. this.cmbDsfm_PlacedRegion.DisplayMember = "Sc_ClassName";
  577. dr = dt.NewRow();
  578. dr["Sc_ClassCode"] = "-1";
  579. dr["Sc_ClassName"] = "";
  580. dt.Rows.InsertAt(dr, 0);
  581. this.cmbDsfm_PlacedRegion.SelectedIndex = 0;
  582. #endregion
  583. }
  584. #endregion
  585. #region 礼服名称输入限制
  586. protected override void txtDsfm_DressName_TextChanged(object sender, EventArgs e)
  587. {
  588. try
  589. {
  590. string Prod_Name = txtDsfm_DressName.Text;
  591. if (!string.IsNullOrEmpty(Prod_Name))
  592. {
  593. if (Prod_Name.ToUpper().Contains(":") || Prod_Name.ToUpper().Contains("?") || Prod_Name.ToUpper().Contains("\"") || Prod_Name.ToUpper().Contains("<") || Prod_Name.ToUpper().Contains(">") || Prod_Name.ToUpper().Contains("|") || Prod_Name.ToUpper().Contains("\\") || Prod_Name.ToUpper().Contains("/") || Prod_Name.ToUpper().Contains("(") || Prod_Name.ToUpper().Contains(")") || Prod_Name.ToUpper().Contains("&"))
  594. {
  595. MessageBoxCustom.Show("此名称有不合法字符!");
  596. txtDsfm_DressName.Text = "";
  597. return;
  598. }
  599. }
  600. }
  601. catch (Exception ex)
  602. {
  603. MessageBoxCustom.Show(ex.Message);
  604. }
  605. }
  606. #endregion
  607. #region 获取新的礼服编号
  608. protected override void btnRefresh_Click(object sender, EventArgs e)
  609. {
  610. //获取礼服编号
  611. Random action = new Random();
  612. txtDsfm_DressNumber.Text = "LF" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime().ToString("yyyyMM") + action.Next(100, 1000) + "1";//获取新编号
  613. }
  614. #endregion
  615. }
  616. }