frmSaveN8Selection.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace LYFZ.Software.MainBusiness.DoorCityProcess
  9. {
  10. public struct PerGoodImg
  11. {
  12. public string strGoodName;
  13. public List<string> listImgs;
  14. }
  15. public partial class frmSaveN8Selection : LYFZ.Software.UI.DoorCityProcess.frmSaveN8Selection
  16. {
  17. LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
  18. LYFZ.BLL.BLL_ErpProduct ptbll = new BLL.BLL_ErpProduct();
  19. private LYFZ.Model.Model_ErpOrder currentModel = null;
  20. private LYFZ.Model.Model_ErpOrderDigital currentModelDigital = null;
  21. /// <summary>
  22. /// 当前订单(儿童订单的次数)的商品列表;
  23. /// </summary>
  24. private List<LYFZ.Model.Model_ErpOrderProductList> photoModelList = null;
  25. private string n8ServerUserDirectory = "";
  26. private DAL.N8Process.DAL_N8ResultViewGoProduct dalResultViewGoProduct = null;
  27. private DAL.N8Process.DAL_N8ResultItem dalResultItem = null;
  28. private DAL.N8Process.DAL_N8Album dalAlbum = null;
  29. LYFZ.BLL.ManufactureProductsAndReservationProductsStatisticalProcess reservationProductList = null;
  30. BLL.ProductSelectedPhotoInfo currentSelectPhotoInfo = null;
  31. LYFZ.BLL.BLL_ErpOrder currentOrderBll = new BLL.BLL_ErpOrder();
  32. /// <summary>
  33. /// 每个商品,有多少版面;
  34. /// </summary>
  35. private List<PerGoodImg> listPerGoodPage = new List<PerGoodImg>();
  36. /// <summary>
  37. /// 每个商品,有多少相片(不包含商品所有版面的相片);
  38. /// </summary>
  39. private List<PerGoodImg> listPerGoodImg = new List<PerGoodImg>();
  40. /// <summary>
  41. /// 每个商品的每个版面,有多少相片;
  42. /// </summary>
  43. private List<PerGoodImg> listPerGoodPageImg = new List<PerGoodImg>();
  44. public LYFZ.Model.Model_ErpOrder CurrentModel
  45. {
  46. get
  47. {
  48. return currentModel;
  49. }
  50. set
  51. {
  52. currentModel = value;
  53. }
  54. }
  55. public LYFZ.Model.Model_ErpOrderDigital CurrentModelDigital
  56. {
  57. get
  58. {
  59. return currentModelDigital;
  60. }
  61. set
  62. {
  63. currentModelDigital = value;
  64. }
  65. }
  66. public List<LYFZ.Model.Model_ErpOrderProductList> PhotoModelList
  67. {
  68. get
  69. {
  70. return photoModelList;
  71. }
  72. set
  73. {
  74. photoModelList = value;
  75. }
  76. }
  77. public string N8ServerUserDirectory
  78. {
  79. get
  80. {
  81. return n8ServerUserDirectory;
  82. }
  83. set
  84. {
  85. n8ServerUserDirectory = value;
  86. }
  87. }
  88. public frmSaveN8Selection()
  89. {
  90. this.Load += FrmSaveN8Selection_Load;
  91. this.btn_Save.Click += Btn_Save_Click;
  92. this.btn_Cancel.Click += Btn_Cancel_Click;
  93. this.dgv_product.CellDoubleClick += Dgv_product_CellDoubleClick;
  94. this.dgv_product.CellValueChanged += Dgv_product_CellValueChanged;
  95. this.ck_Pickup.CheckedChanged += Ck_Pickup_CheckedChanged;
  96. this.ck_Expedited.CheckedChanged += Ck_Expedited_CheckedChanged;
  97. this.dt_Pickup.ValueChanged += Dt_Pickup_ValueChanged;
  98. this.tx_Money.KeyPress += Tx_Money_KeyPress;
  99. this.btn_AddMoney.Click += Btn_AddMoney_Click;
  100. this.link_record.LinkClicked += Link_record_LinkClicked;
  101. }
  102. private void Link_record_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
  103. {
  104. System.Data.DataTable tb = null;
  105. LYFZ.ExtendControlLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  106. {
  107. backgroundWorker.ReportProgress( 0, "正在加载..." );
  108. tb = this.orbll.DAL.GetOrderPickupMoneyDataTable( this.CurrentModel.Ord_Number, this.CurrentModelDigital.Ordv_ViceNumber, Convert.ToInt32( this.CurrentModel.Ord_Type ), this.CurrentModelDigital.Ordv_DigitalNumber );
  109. } );
  110. if ( tb != null )
  111. {
  112. PhotoSelectSystem.frmPlusickRecord fprod = new PhotoSelectSystem.frmPlusickRecord();
  113. fprod.TbPlusickRecord = tb;
  114. fprod.Ord_Number = this.CurrentModel.Ord_Number;
  115. fprod.Ordv_ViceNumber = this.CurrentModelDigital.Ordv_ViceNumber;
  116. fprod.Ord_Type = Convert.ToInt32( this.CurrentModel.Ord_Type );
  117. fprod.Ordv_DigitalNumber = this.CurrentModelDigital.Ordv_DigitalNumber;
  118. fprod.ShowDialog();
  119. }
  120. }
  121. private void Btn_AddMoney_Click( object sender, EventArgs e )
  122. {
  123. decimal currentPickSumMoney = Convert.ToDecimal( this.tx_Money.Text );//当前加挑总金额
  124. decimal currentPickMoney = 0;//当前加挑金额
  125. string currentPickInfo = "";//当前加挑商品内容信息
  126. frmPlusPickDescription pickInfo = new frmPlusPickDescription( currentPickSumMoney );
  127. if ( pickInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK )
  128. {
  129. currentPickMoney = pickInfo.PickMoney;
  130. currentPickInfo = pickInfo.PickInfo;
  131. LYFZ.Model.Model_ErpPlusPickItems pickModel = new Model.Model_ErpPlusPickItems();
  132. pickModel.Plu_Number = LYFZ.BLL.BLL_ErpCustomer.GetLateStagePlusPickNumber();
  133. pickModel.Plu_OrdNumber = this.CurrentModel.Ord_Number;
  134. pickModel.Plu_OrdViceNumber = this.CurrentModelDigital.Ordv_ViceNumber;
  135. pickModel.Plu_Amount = currentPickMoney;
  136. pickModel.Plu_CreateTime = SDateTime.Now;
  137. pickModel.Plu_GoodsCosts = "0";
  138. pickModel.Plu_RecordedPerson = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
  139. pickModel.Plu_SourceType = "1";
  140. pickModel.Plu_Goods = currentPickInfo;
  141. pickModel.Plu_OpenSingle = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
  142. pickModel.Plu_TwoPinsCategory = "BEBCABBAAHFCJBJGJ";
  143. pickModel.Plu_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID;
  144. if ( this.currentOrderBll.DAL.SetOrderPickupMoney( pickModel ) )
  145. {
  146. this.tx_Money.Text = (currentPickSumMoney + currentPickMoney).ToString();
  147. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog( EnumPublic.SystemLogsType.选片操作日志,
  148. "[订单号:" + this.CurrentModelDigital.Ordv_Number + "(" + this.CurrentModelDigital.Ordv_ViceNumber + ")]选片加挑金额变更 (" + currentPickInfo + ")" + currentPickMoney + "元",
  149. LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID,
  150. LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name );
  151. }
  152. }
  153. }
  154. private void Tx_Money_KeyPress( object sender, KeyPressEventArgs e )
  155. {
  156. if ( !Char.IsNumber( e.KeyChar ) && !Char.IsPunctuation( e.KeyChar ) && !Char.IsControl( e.KeyChar ) )
  157. {
  158. e.Handled = true;//消除不合适字符
  159. }
  160. else if ( Char.IsPunctuation( e.KeyChar ) )
  161. {
  162. if ( tx_Money.SelectionStart == 0 )
  163. {
  164. if ( tx_Money.Text.LastIndexOf( '-' ) == -1 )
  165. return;
  166. }
  167. if ( tx_Money.SelectionStart == 1 )
  168. {
  169. if ( tx_Money.Text.LastIndexOf( '-' ) != -1 && e.KeyChar == '.' )
  170. e.Handled = true;
  171. }
  172. if ( e.KeyChar != '.' || tx_Money.Text.LastIndexOf( '.' ) != -1 )
  173. {
  174. e.Handled = true;
  175. }
  176. }
  177. if ( tx_Money.SelectionStart == 0 )
  178. {
  179. if ( tx_Money.Text.LastIndexOf( '-' ) != -1 )
  180. e.Handled = true;
  181. }
  182. }
  183. private void Dt_Pickup_ValueChanged( object sender, EventArgs e )
  184. {
  185. foreach ( DataGridViewRow row in this.dgv_product.Rows )
  186. {
  187. row.Cells[7].Value = this.dt_Pickup.Value.ToString( "yyyy-MM-dd" );
  188. UpdateDataGridViewRowProduct( row );
  189. }
  190. }
  191. private void Ck_Expedited_CheckedChanged( object sender, EventArgs e )
  192. {
  193. foreach ( DataGridViewRow row in this.dgv_product.Rows )
  194. {
  195. if ( this.ck_Expedited.Checked )
  196. {
  197. row.Cells[4].Value = "加急";
  198. }
  199. else
  200. {
  201. row.Cells[4].Value = "";
  202. }
  203. UpdateDataGridViewRowProduct( row );
  204. if ( row.Cells[0].Value == null || row.Cells[0].Value.ToString().Length <= 0 )
  205. {
  206. row.Cells[4].Value = "";
  207. row.Cells[5].Value = "";
  208. }
  209. }
  210. }
  211. private void Ck_Pickup_CheckedChanged( object sender, EventArgs e )
  212. {
  213. if ( ck_Pickup.Checked == true )
  214. {
  215. dt_Pickup.Enabled = true;
  216. foreach ( DataGridViewRow row in this.dgv_product.Rows )
  217. {
  218. row.Cells[7].Value = this.dt_Pickup.Value.ToString( "yyyy-MM-dd" );
  219. UpdateDataGridViewRowProduct( row );
  220. }
  221. }
  222. else
  223. {
  224. dt_Pickup.Enabled = false;
  225. }
  226. }
  227. private void Dgv_product_CellValueChanged( object sender, DataGridViewCellEventArgs e )
  228. {
  229. DataGridViewCell vCell = this.dgv_product.Rows[e.RowIndex].Cells[e.ColumnIndex];
  230. object cValue = vCell.Value;
  231. try
  232. {
  233. switch ( vCell.ColumnIndex )
  234. {
  235. case 3:
  236. {
  237. int number = 1;
  238. if ( cValue != null )
  239. {
  240. if ( !int.TryParse( cValue.ToString().Trim(), out number ) )
  241. {
  242. vCell.Value = 1;
  243. }
  244. else if ( number <= 0 )
  245. {
  246. vCell.Value = 1;
  247. }
  248. }
  249. else
  250. {
  251. vCell.Value = 1;
  252. }
  253. }
  254. break;
  255. case 7:
  256. if ( vCell.Value != null && vCell.Value.ToString().Trim().Length > 0 )
  257. {
  258. DateTime PickDate;
  259. if ( !DateTime.TryParse( cValue.ToString().Trim(), out PickDate ) )
  260. {
  261. vCell.Value = "";
  262. }
  263. if ( this.dt_Pickup.Value.ToString( "yyyy-MM-dd" ) != PickDate.ToString( "yyyy-MM-dd" ) )
  264. {
  265. this.ck_Pickup.Checked = false;
  266. }
  267. }
  268. break;
  269. case 8:
  270. {
  271. }
  272. break;
  273. }
  274. UpdateDataGridViewRowProduct( this.dgv_product.Rows[vCell.RowIndex] );
  275. }
  276. catch { }
  277. }
  278. private void Dgv_product_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
  279. {
  280. if ( e.RowIndex < 0 || e.ColumnIndex < 0 )
  281. {
  282. return;
  283. }
  284. DataGridViewCell vCell = this.dgv_product.Rows[e.RowIndex].Cells[e.ColumnIndex];
  285. object cValue = vCell.Value;
  286. try
  287. {
  288. switch ( vCell.ColumnIndex )
  289. {
  290. case 4:
  291. {
  292. if ( cValue.ToString() == "加急" )
  293. {
  294. vCell.Value = "";
  295. }
  296. else
  297. {
  298. vCell.Value = "加急";
  299. }
  300. UpdateDataGridViewRowProduct( this.dgv_product.Rows[vCell.RowIndex] );
  301. }
  302. break;
  303. case 7:
  304. if ( vCell.Value == null || cValue.ToString().Trim().Length <= 0 )
  305. {
  306. vCell.Value = this.ck_Pickup.Checked ? this.dt_Pickup.Value.ToString( "yyyy-MM-dd" ) : DateTime.Now.ToString( "yyyy-MM-dd" );
  307. UpdateDataGridViewRowProduct( this.dgv_product.Rows[vCell.RowIndex] );
  308. }
  309. break;
  310. default:
  311. break;
  312. }
  313. }
  314. catch { }
  315. }
  316. private void Btn_Cancel_Click( object sender, EventArgs e )
  317. {
  318. this.Close();
  319. }
  320. private void Btn_Save_Click( object sender, EventArgs e )
  321. {
  322. #region 同步N8的选版备注到数据库中;
  323. // 加载选版的备注信息item.data;
  324. string Notexml = string.Format( "{0}\\选版结果\\item.data", N8ServerUserDirectory );
  325. dalResultItem = new DAL.N8Process.DAL_N8ResultItem( Notexml );
  326. dalResultItem.LoadResultItem();
  327. List<string> listNotes = null;
  328. string strItemNotes = null;
  329. // 获取原备注;
  330. if ( this.CurrentModelDigital != null && this.CurrentModelDigital.Ordv_SelectionFilm.Length > 0 )
  331. {
  332. listNotes = this.CurrentModelDigital.Ordv_SelectionFilm.Split( '*' ).ToList();
  333. }
  334. // N8选版备注, 直接覆盖现有的选版备注;;
  335. if ( dalResultItem.ListResultItem.Count > 0 )
  336. {
  337. strItemNotes = "?";
  338. foreach ( Model.N8Process.N8ResultItem item in dalResultItem.ListResultItem )
  339. {
  340. strItemNotes += string.Format( "{0}:{1}|", item.path, item.comment );
  341. }
  342. strItemNotes.TrimEnd( '|' );
  343. strItemNotes = LYFZ.WinAPI.SDKSecurity.EncodeHex16String( strItemNotes );
  344. // 转码;
  345. if ( listNotes != null )
  346. currentModelDigital.Ordv_SelectionFilm = listNotes[0] + string.Format( "*{0}*", strItemNotes );
  347. else
  348. currentModelDigital.Ordv_SelectionFilm = string.Format( "*{0}*", strItemNotes );
  349. }
  350. // 保存时,设置成N8选版模式;
  351. currentModelDigital.Ordv_IsN8Model = true;
  352. #endregion
  353. this.CurrentModelDigital.Ordv_LookDesignClaim = tx_CustomerRequire.Text;
  354. if ( this.currentOrderBll.DAL.SaveSelectionFilm( LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID,
  355. this.CurrentModelDigital.Ordv_ViceNumber,
  356. this.CurrentModelDigital.Ordv_SelectionFilm,
  357. LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID,
  358. this.CurrentModelDigital,
  359. this.PhotoModelList,
  360. this.CurrentModelDigital.Ordv_DesignValidation ) )
  361. {
  362. MessageBoxCustom.Show( "保存成功" );
  363. }
  364. }
  365. private void FrmSaveN8Selection_Load( object sender, EventArgs e )
  366. {
  367. FillDialogWithData();
  368. }
  369. private void FillDialogWithData()
  370. {
  371. this.currentSelectPhotoInfo = new BLL.ProductSelectedPhotoInfo( this.CurrentModelDigital.Ordv_DesignValidation, Model.Model_ErpOrder.DirectoryType.DesignPiece ); //读取当前订单已选设计片信息
  372. LYFZ.ExtendControlLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
  373. {
  374. try
  375. {
  376. reservationProductList = new BLL.ManufactureProductsAndReservationProductsStatisticalProcess(
  377. this.CurrentModel.Ord_Number,
  378. this.CurrentModelDigital.Ordv_ViceNumber,
  379. this.PhotoModelList,
  380. this.currentSelectPhotoInfo );
  381. }
  382. catch { }
  383. } );
  384. LoadN8ViewGoResult();
  385. // 订单号;
  386. this.tx_OrderNumber.Text = CurrentModel.Ord_Number;
  387. // 获取顾客资料;
  388. LYFZ.BLL.BLL_ErpCustomer cusBll = new BLL.BLL_ErpCustomer();
  389. this.tx_Customer.Text = cusBll.GetCustomerNameList( this.currentModel.Ord_Number, "," );
  390. // 获取顾客要求;
  391. this.tx_CustomerRequire.Text = CurrentModelDigital.Ordv_LookDesignClaim;
  392. // 入底数量;
  393. this.tx_films.Text = CurrentModel.Ord_IntoBottom.ToString();
  394. // 入册数量;
  395. this.tx_album.Text = CurrentModel.Ord_IntoRegister.ToString();
  396. // 加挑总金额;
  397. this.tx_Money.Text = currentOrderBll.DAL.GetOrderPickupMoney(
  398. this.CurrentModel.Ord_Number,
  399. this.CurrentModelDigital.Ordv_ViceNumber,
  400. Convert.ToInt32( this.CurrentModel.Ord_Type ),
  401. this.CurrentModelDigital.Ordv_DigitalNumber ).ToString();
  402. // 重新获取选版结果;
  403. photoModelList = currentOrderBll.GetOrderProductList( this.CurrentModel.Ord_Number, this.CurrentModelDigital.Ordv_ViceNumber, DAL.OrderProductType.制作商品 );
  404. List<LYFZ.Model.Model_ErpOrderProductList> productLists = currentOrderBll.GetOrderProductList( this.CurrentModel.Ord_Number, this.CurrentModelDigital.Ordv_ViceNumber, DAL.OrderProductType.预约商品 );
  405. foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
  406. {
  407. DataGridViewRow dgr = new DataGridViewRow();
  408. dgr.CreateCells( this.dgv_product );
  409. dgr.Tag = opl;
  410. dgr.Cells[0].Value = opl.OPlist_ProdNumber;
  411. dgr.Cells[1].Value = opl.OPlist_ProdName;
  412. dgr.Cells[2].Value = opl.OPlist_ProdSoldPrice;
  413. dgr.Cells[3].Value = opl.OPlist_ProdQuantity;
  414. dgr.Cells[4].Value = opl.OPlist_IsExpedited ? "加急" : "";
  415. foreach ( PerGoodImg pi in this.listPerGoodPage )
  416. {
  417. if ( pi.strGoodName.Equals( opl.OPlist_ProdName ) )
  418. {
  419. dgr.Cells[5].Value = pi.listImgs.Count;
  420. break;
  421. }
  422. }
  423. foreach ( PerGoodImg pi in this.listPerGoodImg )
  424. {
  425. if ( pi.strGoodName.Equals( opl.OPlist_ProdName ) )
  426. {
  427. dgr.Cells[6].Value = pi.listImgs.Count;
  428. break;
  429. }
  430. }
  431. // 预约取件日期;
  432. if ( opl.OPlist_ReservationTakeTime.Ticks != 0 )
  433. dgr.Cells[7].Value = opl.OPlist_ReservationTakeTime;
  434. dgr.Cells[8].Value = opl.OPlist_Remark;
  435. if ( !IsHasReservationProduct( opl, productLists ) )
  436. {
  437. dgr.Cells[0].Style.BackColor = Color.Red;
  438. }
  439. this.dgv_product.Rows.Add( dgr );
  440. }
  441. }
  442. /// <summary>
  443. /// 加载N8选版结果;
  444. /// </summary>
  445. private void LoadN8ViewGoResult()
  446. {
  447. // 加载商品版面结果vgproduct.data;
  448. string vgproductxml = string.Format( "{0}\\选版结果\\vgproduct.data", N8ServerUserDirectory );
  449. dalResultViewGoProduct = new DAL.N8Process.DAL_N8ResultViewGoProduct( vgproductxml );
  450. dalResultViewGoProduct.LoadResultViewGoProduct();
  451. foreach ( Model.N8Process.N8ResultViewGoProduct product in dalResultViewGoProduct.ListResultViewGoProduct )
  452. {
  453. foreach ( string img in product.ListItem )
  454. {
  455. if ( img.StartsWith( "\\版面\\" ) )
  456. {
  457. if ( !IsTheGoodImgExists( this.listPerGoodPage, product.Name, img.Substring( "\\版面\\".Length ) ) )
  458. {
  459. InsertImgToGood( this.listPerGoodPage, product.Name, img.Substring( "\\版面\\".Length ) );
  460. }
  461. }
  462. else if ( img.StartsWith( "\\照片\\" ) )
  463. {
  464. if ( !IsTheGoodImgExists( this.listPerGoodImg, product.Name, img.Substring( "\\照片\\".Length ) ) )
  465. {
  466. InsertImgToGood( this.listPerGoodImg, product.Name, img.Substring( "\\照片\\".Length ) );
  467. }
  468. }
  469. }
  470. }
  471. // 加载版面相片album.pwt;
  472. string albumxml = string.Format( "{0}\\版面\\album.pwt", N8ServerUserDirectory );
  473. dalAlbum = new DAL.N8Process.DAL_N8Album( albumxml );
  474. dalAlbum.LoadAlbum();
  475. foreach ( PerGoodImg pi in this.listPerGoodPage )
  476. {
  477. foreach ( string page in pi.listImgs )
  478. {
  479. foreach ( Model.N8Process.N8Album album in dalAlbum.ListAlbum )
  480. {
  481. // 同一版面;
  482. if ( page.Equals( album.N8PageFileName.TrimEnd( ".jpg".ToCharArray() ).ToLower() ) )
  483. {
  484. foreach ( Model.N8Process.N8PageCell cell in album.ListItem )
  485. {
  486. string file = cell.N8PageCellFileName.Substring( cell.N8PageCellFileName.LastIndexOf( '\\' ) + 1 );
  487. if ( !IsTheGoodImgExists( this.listPerGoodImg, pi.strGoodName, file ) )
  488. {
  489. InsertImgToGood( this.listPerGoodImg, pi.strGoodName, file );
  490. }
  491. }
  492. }
  493. }
  494. }
  495. }
  496. try
  497. {
  498. // 是否有新商品增加、减少;
  499. StringBuilder strSQL = new StringBuilder();
  500. strSQL.Append( "(" );
  501. #region N8新增了哪些产品
  502. // 添加了哪些或减少(不是删除)哪些;
  503. LYFZ.BLL.BLL_ErpOrderProductList ordProdBll = new BLL.BLL_ErpOrderProductList();
  504. List<LYFZ.Helper.CommandInfo> commdinfoList = new List<Helper.CommandInfo>();
  505. foreach ( Model.N8Process.N8ResultViewGoProduct product in dalResultViewGoProduct.ListResultViewGoProduct )
  506. {
  507. int nNewCount = dalResultViewGoProduct.GetResultViewGoProductCount( product.Id );
  508. int nOldCount = GetProductCount( product.Id );
  509. // 商品选版前后的数量是否有添加;
  510. if ( nNewCount > nOldCount )
  511. {// 加挑了商品;
  512. for ( int i = nOldCount; i < nNewCount; i++ )
  513. {
  514. Model.Model_ErpProduct pp = ptbll.GetModel( "Prod_Number", product.Id );
  515. Model.Model_ErpOrderProductList plt = GetSelectOrderProduct( pp );
  516. photoModelList.Add( plt );
  517. commdinfoList.Add( ordProdBll.GetAddCommandInfo( plt ) );
  518. }
  519. }
  520. else if ( nNewCount < nOldCount )
  521. {// 减少了商品,只减没有选片的,如果选片关联了相片的,不减;
  522. string tempDelIdList = "";
  523. for ( int i = nOldCount; i > nNewCount; i-- )
  524. {
  525. foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
  526. {
  527. if ( opl.OPlist_ProdNumber.Equals( product.Id ) )
  528. {
  529. string name = product.Name;
  530. if ( product.Name.EndsWith( ")" ) && product.Name[product.Name.Length - 3] == '(' )
  531. name = product.Name.Substring( 0, product.Name.Length - 3 );
  532. // if ( -1 == CurrentModelDigital.Ordv_SelectionFilm.IndexOf( product.Name ) ) // 选片和N8选版只取一个,不会同时存在;
  533. {// 没有任何相关关联,可以删除;
  534. tempDelIdList += opl.ID + ",";
  535. photoModelList.Remove( opl );
  536. }
  537. break;
  538. }
  539. }
  540. }
  541. string delSql = "delete [dbo].[tb_ErpOrderProductList] where id in (" + tempDelIdList.Trim( ',' ) + ")";
  542. Helper.SQLHelper.ExecuteSql( delSql );
  543. }
  544. }
  545. // 事务来保存新增的商品;
  546. int ret = Helper.SQLHelper.ExecuteSqlTran( commdinfoList );
  547. #endregion
  548. #region N8删除了哪些产品
  549. // 删除了哪些或增加了哪些;
  550. List<LYFZ.Model.Model_ErpOrderProductList> tmplist = new List<LYFZ.Model.Model_ErpOrderProductList>();
  551. for ( int i = photoModelList.Count - 1; i > -1; i-- )
  552. {
  553. int nNewCount = GetProductCount( photoModelList[i].OPlist_ProdNumber );
  554. int nOldCount = dalResultViewGoProduct.GetResultViewGoProductCount( photoModelList[i].OPlist_ProdNumber );
  555. if ( nNewCount != nOldCount )
  556. {// 删除了哪些;
  557. //if ( -1 == CurrentModelDigital.Ordv_SelectionFilm.IndexOf( photoModelList[i].OPlist_ProdName ) )//选片和N8选版只取一个,不会同时存在;
  558. {// 没有任何相关关联,可以删除;
  559. string delSql = "delete [dbo].[tb_ErpOrderProductList] where id = " + photoModelList[i].ID + "";
  560. Helper.SQLHelper.ExecuteSql( delSql );
  561. photoModelList.RemoveAt( i );
  562. }
  563. continue;
  564. }
  565. }
  566. #endregion
  567. }
  568. catch ( Exception ex )
  569. {
  570. }
  571. }
  572. private bool IsTheGoodImgExists( List<PerGoodImg> listPerGoodImg, string good, string image )
  573. {
  574. bool bExists = false;
  575. image = image.ToLower();
  576. image = image.TrimEnd( ".jpg".ToCharArray() );
  577. foreach ( PerGoodImg pi in listPerGoodImg )
  578. {
  579. if ( pi.strGoodName.Equals( good ) )
  580. {
  581. foreach ( string img in pi.listImgs )
  582. {
  583. if ( img.Equals( image ) )
  584. {
  585. bExists = true;
  586. break;
  587. }
  588. }
  589. break;
  590. }
  591. }
  592. return bExists;
  593. }
  594. private void InsertImgToGood( List<PerGoodImg> listPerGoodImg, string good, string image )
  595. {
  596. bool bGoodExist = false;
  597. image = image.ToLower();
  598. image = image.TrimEnd( ".jpg".ToCharArray() );
  599. foreach ( PerGoodImg pi in listPerGoodImg )
  600. {
  601. if ( pi.strGoodName.Equals( good ) )
  602. {
  603. bGoodExist = true;
  604. pi.listImgs.Add( image );
  605. break;
  606. }
  607. }
  608. if ( !bGoodExist )
  609. {
  610. PerGoodImg pi = new PerGoodImg();
  611. pi.strGoodName = good;
  612. pi.listImgs = new List<string>();
  613. pi.listImgs.Add( image );
  614. listPerGoodImg.Add( pi );
  615. }
  616. }
  617. /// <summary>
  618. /// 更新当前行的商品对象
  619. /// </summary>
  620. /// <param name="row"></param>
  621. void UpdateDataGridViewRowProduct( DataGridViewRow row, bool isupdate = true )
  622. {
  623. if ( row.Tag != null )
  624. {
  625. LYFZ.Model.Model_ErpOrderProductList ordProduct = (LYFZ.Model.Model_ErpOrderProductList)row.Tag;
  626. if ( ordProduct.OPlist_UniquelyIdentity == LYFZ.BLL.SelectPhotoHandling.IntoFilmText
  627. || ordProduct.OPlist_UniquelyIdentity == LYFZ.BLL.SelectPhotoHandling.IntoBookText )
  628. {
  629. return;
  630. }
  631. if ( row.Cells[3].Value != null )
  632. {
  633. int oldProdQuantity = ordProduct.OPlist_ProdQuantity;
  634. int newProdQuantity = Convert.ToInt32( row.Cells[3].Value );
  635. ordProduct.OPlist_ProdQuantity = newProdQuantity;
  636. row.Cells[3].Style.ForeColor = this.reservationProductList.GetRowProdQuantityTextColor( ordProduct );
  637. if ( row.Cells[3].Style.ForeColor.Name == Color.Red.Name && newProdQuantity > oldProdQuantity )
  638. {
  639. if ( ExMessageBoxCustom.Show( "您输入的数量大于预约数量,是否确定要继续输入?", msgBoxButton: MessageBoxButtons.YesNo ) == System.Windows.Forms.DialogResult.No )
  640. {
  641. row.Cells[3].Value = oldProdQuantity;
  642. ordProduct.OPlist_ProdQuantity = oldProdQuantity;
  643. row.Cells[3].Style.ForeColor = this.reservationProductList.GetRowProdQuantityTextColor( ordProduct );
  644. }
  645. }
  646. }
  647. if ( row.Cells[4].Value != null )
  648. {
  649. if ( row.Cells[4].Value.ToString().Trim().Length > 0 )
  650. {
  651. ordProduct.OPlist_IsExpedited = true;
  652. }
  653. else
  654. {
  655. ordProduct.OPlist_IsExpedited = false;
  656. }
  657. }
  658. if ( row.Cells[7].Value != null )
  659. {
  660. if ( row.Cells[7].Value.ToString().Trim().Length > 0 )
  661. {
  662. ordProduct.OPlist_ExpeditedTime = Convert.ToDateTime( row.Cells[7].Value.ToString() );
  663. }
  664. else
  665. {
  666. ordProduct.OPlist_ExpeditedTime = Convert.ToDateTime( "1900-01-01" );
  667. }
  668. ordProduct.OPlist_ReservationTakeTime = ordProduct.OPlist_ExpeditedTime;
  669. }
  670. else
  671. {
  672. ordProduct.OPlist_ExpeditedTime = Convert.ToDateTime( "1900-01-01" );
  673. ordProduct.OPlist_ReservationTakeTime = ordProduct.OPlist_ExpeditedTime;
  674. }
  675. if ( row.Cells[8].Value != null )
  676. {
  677. ordProduct.OPlist_Remark = row.Cells[8].Value.ToString().Trim();
  678. }
  679. else
  680. {
  681. ordProduct.OPlist_Remark = "";
  682. }
  683. }
  684. }
  685. /// <summary>
  686. /// 返回商品个数
  687. /// </summary>
  688. /// <param name="productId"></param>
  689. /// <returns></returns>
  690. private int GetProductCount( string productId )
  691. {
  692. int nCount = 0;
  693. foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
  694. {
  695. if ( opl.OPlist_ProdNumber.Equals( productId ) )
  696. {
  697. ++nCount;
  698. }
  699. }
  700. return nCount;
  701. }
  702. LYFZ.Model.Model_ErpOrderProductList GetSelectOrderProduct( LYFZ.Model.Model_ErpProduct pModel )
  703. {
  704. //this.CMainPhotoSelect.SelectedPieceInfoModify = true;
  705. LYFZ.Model.Model_ErpOrderProductList ordProdructModel = new LYFZ.Model.Model_ErpOrderProductList();
  706. ordProdructModel.OPlist_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID;
  707. ordProdructModel.OPlist_ProdNumber = pModel.Prod_Number;
  708. ordProdructModel.OPlist_ProdName = pModel.Prod_Name;
  709. ordProdructModel.OPlist_ProdQuantity = 1;
  710. ordProdructModel.OPlist_ProdSoldPrice = pModel.Prod_SalesPrice;
  711. ordProdructModel.OPlist_CostPrice = pModel.Prod_CostPrice;
  712. ordProdructModel.OPlist_Class = pModel.Prod_Class;
  713. ordProdructModel.OPlist_Batch = pModel.Prod_Batch;
  714. ordProdructModel.OPlist_Unit = pModel.Prod_Unit;
  715. ordProdructModel.OPlist_Type = "2";
  716. ordProdructModel.OPlist_OriginalP = pModel.Prod_Batch;
  717. ordProdructModel.OPlist_OrderNumber = this.CurrentModel.Ord_Number;
  718. ordProdructModel.OPlist_ViceNumber = this.CurrentModelDigital.Ordv_ViceNumber;
  719. ordProdructModel.OPlist_UniquelyIdentity = LYFZ.DAL.DAL_ErpOrderProductList.GetPorductUniquelyIdentity();
  720. ordProdructModel.OPlist_OrderByNumber = GetNewOPlistOrderByNumber();
  721. return ordProdructModel;
  722. }
  723. /// <summary>
  724. /// 临时计数器
  725. /// </summary>
  726. int tempOrderByNumberCount = 0;
  727. /// <summary>
  728. /// 获取新的排序编号
  729. /// </summary>
  730. /// <returns></returns>
  731. int GetNewOPlistOrderByNumber()
  732. {
  733. int retOrderByNumber = 0;
  734. tempOrderByNumberCount++;
  735. foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
  736. {
  737. if ( opl != null )
  738. {
  739. if ( opl.OPlist_OrderByNumber > retOrderByNumber )
  740. {
  741. retOrderByNumber = opl.OPlist_OrderByNumber;
  742. }
  743. }
  744. }
  745. return retOrderByNumber + tempOrderByNumberCount;
  746. }
  747. /// <summary>
  748. /// 判断一个制作商品是否有对应的预约商品, 如果没有则表示该商品为加挑商品;
  749. /// </summary>
  750. /// <param name="model">制作商品</param>
  751. /// <param name="list">预约商品列表</param>
  752. /// <returns></returns>
  753. bool IsHasReservationProduct( LYFZ.Model.Model_ErpOrderProductList model, List<LYFZ.Model.Model_ErpOrderProductList> list )
  754. {
  755. bool has = false;
  756. foreach ( LYFZ.Model.Model_ErpOrderProductList item in list )
  757. {
  758. if ( item.OPlist_OrderByNumber == model.OPlist_OrderByNumber )
  759. {
  760. has = true;
  761. break;
  762. }
  763. }
  764. return has;
  765. }
  766. }
  767. }