123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.DoorCityProcess
- {
- public struct PerGoodImg
- {
- public string strGoodName;
- public List<string> listImgs;
- }
- public partial class frmSaveN8Selection : LYFZ.Software.UI.DoorCityProcess.frmSaveN8Selection
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_ErpProduct ptbll = new BLL.BLL_ErpProduct();
- private LYFZ.Model.Model_ErpOrder currentModel = null;
- private LYFZ.Model.Model_ErpOrderDigital currentModelDigital = null;
- /// <summary>
- /// 当前订单(儿童订单的次数)的商品列表;
- /// </summary>
- private List<LYFZ.Model.Model_ErpOrderProductList> photoModelList = null;
- private string n8ServerUserDirectory = "";
- private DAL.N8Process.DAL_N8ResultViewGoProduct dalResultViewGoProduct = null;
- private DAL.N8Process.DAL_N8ResultItem dalResultItem = null;
- private DAL.N8Process.DAL_N8Album dalAlbum = null;
- LYFZ.BLL.ManufactureProductsAndReservationProductsStatisticalProcess reservationProductList = null;
- BLL.ProductSelectedPhotoInfo currentSelectPhotoInfo = null;
- LYFZ.BLL.BLL_ErpOrder currentOrderBll = new BLL.BLL_ErpOrder();
- /// <summary>
- /// 每个商品,有多少版面;
- /// </summary>
- private List<PerGoodImg> listPerGoodPage = new List<PerGoodImg>();
- /// <summary>
- /// 每个商品,有多少相片(不包含商品所有版面的相片);
- /// </summary>
- private List<PerGoodImg> listPerGoodImg = new List<PerGoodImg>();
- /// <summary>
- /// 每个商品的每个版面,有多少相片;
- /// </summary>
- private List<PerGoodImg> listPerGoodPageImg = new List<PerGoodImg>();
- public LYFZ.Model.Model_ErpOrder CurrentModel
- {
- get
- {
- return currentModel;
- }
- set
- {
- currentModel = value;
- }
- }
- public LYFZ.Model.Model_ErpOrderDigital CurrentModelDigital
- {
- get
- {
- return currentModelDigital;
- }
- set
- {
- currentModelDigital = value;
- }
- }
- public List<LYFZ.Model.Model_ErpOrderProductList> PhotoModelList
- {
- get
- {
- return photoModelList;
- }
- set
- {
- photoModelList = value;
- }
- }
- public string N8ServerUserDirectory
- {
- get
- {
- return n8ServerUserDirectory;
- }
- set
- {
- n8ServerUserDirectory = value;
- }
- }
- public frmSaveN8Selection()
- {
- this.Load += FrmSaveN8Selection_Load;
- this.btn_Save.Click += Btn_Save_Click;
- this.btn_Cancel.Click += Btn_Cancel_Click;
- this.dgv_product.CellDoubleClick += Dgv_product_CellDoubleClick;
- this.dgv_product.CellValueChanged += Dgv_product_CellValueChanged;
- this.ck_Pickup.CheckedChanged += Ck_Pickup_CheckedChanged;
- this.ck_Expedited.CheckedChanged += Ck_Expedited_CheckedChanged;
- this.dt_Pickup.ValueChanged += Dt_Pickup_ValueChanged;
- this.tx_Money.KeyPress += Tx_Money_KeyPress;
- this.btn_AddMoney.Click += Btn_AddMoney_Click;
- this.link_record.LinkClicked += Link_record_LinkClicked;
- }
- private void Link_record_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e )
- {
- System.Data.DataTable tb = null;
- LYFZ.ExtendControlLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {
- backgroundWorker.ReportProgress( 0, "正在加载..." );
- tb = this.orbll.DAL.GetOrderPickupMoneyDataTable( this.CurrentModel.Ord_Number, this.CurrentModelDigital.Ordv_ViceNumber, Convert.ToInt32( this.CurrentModel.Ord_Type ), this.CurrentModelDigital.Ordv_DigitalNumber );
- } );
- if ( tb != null )
- {
- PhotoSelectSystem.frmPlusickRecord fprod = new PhotoSelectSystem.frmPlusickRecord();
- fprod.TbPlusickRecord = tb;
- fprod.Ord_Number = this.CurrentModel.Ord_Number;
- fprod.Ordv_ViceNumber = this.CurrentModelDigital.Ordv_ViceNumber;
- fprod.Ord_Type = Convert.ToInt32( this.CurrentModel.Ord_Type );
- fprod.Ordv_DigitalNumber = this.CurrentModelDigital.Ordv_DigitalNumber;
- fprod.ShowDialog();
- }
- }
- private void Btn_AddMoney_Click( object sender, EventArgs e )
- {
- decimal currentPickSumMoney = Convert.ToDecimal( this.tx_Money.Text );//当前加挑总金额
- decimal currentPickMoney = 0;//当前加挑金额
- string currentPickInfo = "";//当前加挑商品内容信息
- frmPlusPickDescription pickInfo = new frmPlusPickDescription( currentPickSumMoney );
- if ( pickInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK )
- {
- currentPickMoney = pickInfo.PickMoney;
- currentPickInfo = pickInfo.PickInfo;
- LYFZ.Model.Model_ErpPlusPickItems pickModel = new Model.Model_ErpPlusPickItems();
- pickModel.Plu_Number = LYFZ.BLL.BLL_ErpCustomer.GetLateStagePlusPickNumber();
- pickModel.Plu_OrdNumber = this.CurrentModel.Ord_Number;
- pickModel.Plu_OrdViceNumber = this.CurrentModelDigital.Ordv_ViceNumber;
- pickModel.Plu_Amount = currentPickMoney;
- pickModel.Plu_CreateTime = SDateTime.Now;
- pickModel.Plu_GoodsCosts = "0";
- pickModel.Plu_RecordedPerson = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
- pickModel.Plu_SourceType = "1";
- pickModel.Plu_Goods = currentPickInfo;
- pickModel.Plu_OpenSingle = LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID;
- pickModel.Plu_TwoPinsCategory = "BEBCABBAAHFCJBJGJ";
- pickModel.Plu_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID;
- if ( this.currentOrderBll.DAL.SetOrderPickupMoney( pickModel ) )
- {
- this.tx_Money.Text = (currentPickSumMoney + currentPickMoney).ToString();
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog( EnumPublic.SystemLogsType.选片操作日志,
- "[订单号:" + this.CurrentModelDigital.Ordv_Number + "(" + this.CurrentModelDigital.Ordv_ViceNumber + ")]选片加挑金额变更 (" + currentPickInfo + ")" + currentPickMoney + "元",
- LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID,
- LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name );
- }
- }
- }
- private void Tx_Money_KeyPress( object sender, KeyPressEventArgs e )
- {
- if ( !Char.IsNumber( e.KeyChar ) && !Char.IsPunctuation( e.KeyChar ) && !Char.IsControl( e.KeyChar ) )
- {
- e.Handled = true;//消除不合适字符
- }
- else if ( Char.IsPunctuation( e.KeyChar ) )
- {
- if ( tx_Money.SelectionStart == 0 )
- {
- if ( tx_Money.Text.LastIndexOf( '-' ) == -1 )
- return;
- }
- if ( tx_Money.SelectionStart == 1 )
- {
- if ( tx_Money.Text.LastIndexOf( '-' ) != -1 && e.KeyChar == '.' )
- e.Handled = true;
- }
- if ( e.KeyChar != '.' || tx_Money.Text.LastIndexOf( '.' ) != -1 )
- {
- e.Handled = true;
- }
- }
- if ( tx_Money.SelectionStart == 0 )
- {
- if ( tx_Money.Text.LastIndexOf( '-' ) != -1 )
- e.Handled = true;
- }
- }
- private void Dt_Pickup_ValueChanged( object sender, EventArgs e )
- {
- foreach ( DataGridViewRow row in this.dgv_product.Rows )
- {
- row.Cells[7].Value = this.dt_Pickup.Value.ToString( "yyyy-MM-dd" );
- UpdateDataGridViewRowProduct( row );
- }
- }
- private void Ck_Expedited_CheckedChanged( object sender, EventArgs e )
- {
- foreach ( DataGridViewRow row in this.dgv_product.Rows )
- {
- if ( this.ck_Expedited.Checked )
- {
- row.Cells[4].Value = "加急";
- }
- else
- {
- row.Cells[4].Value = "";
- }
- UpdateDataGridViewRowProduct( row );
- if ( row.Cells[0].Value == null || row.Cells[0].Value.ToString().Length <= 0 )
- {
- row.Cells[4].Value = "";
- row.Cells[5].Value = "";
- }
- }
- }
- private void Ck_Pickup_CheckedChanged( object sender, EventArgs e )
- {
- if ( ck_Pickup.Checked == true )
- {
- dt_Pickup.Enabled = true;
- foreach ( DataGridViewRow row in this.dgv_product.Rows )
- {
- row.Cells[7].Value = this.dt_Pickup.Value.ToString( "yyyy-MM-dd" );
- UpdateDataGridViewRowProduct( row );
- }
- }
- else
- {
- dt_Pickup.Enabled = false;
- }
- }
- private void Dgv_product_CellValueChanged( object sender, DataGridViewCellEventArgs e )
- {
- DataGridViewCell vCell = this.dgv_product.Rows[e.RowIndex].Cells[e.ColumnIndex];
- object cValue = vCell.Value;
- try
- {
- switch ( vCell.ColumnIndex )
- {
- case 3:
- {
- int number = 1;
- if ( cValue != null )
- {
- if ( !int.TryParse( cValue.ToString().Trim(), out number ) )
- {
- vCell.Value = 1;
- }
- else if ( number <= 0 )
- {
- vCell.Value = 1;
- }
- }
- else
- {
- vCell.Value = 1;
- }
- }
- break;
- case 7:
- if ( vCell.Value != null && vCell.Value.ToString().Trim().Length > 0 )
- {
- DateTime PickDate;
- if ( !DateTime.TryParse( cValue.ToString().Trim(), out PickDate ) )
- {
- vCell.Value = "";
- }
- if ( this.dt_Pickup.Value.ToString( "yyyy-MM-dd" ) != PickDate.ToString( "yyyy-MM-dd" ) )
- {
- this.ck_Pickup.Checked = false;
- }
- }
- break;
- case 8:
- {
- }
- break;
- }
- UpdateDataGridViewRowProduct( this.dgv_product.Rows[vCell.RowIndex] );
- }
- catch { }
- }
- private void Dgv_product_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
- {
- if ( e.RowIndex < 0 || e.ColumnIndex < 0 )
- {
- return;
- }
- DataGridViewCell vCell = this.dgv_product.Rows[e.RowIndex].Cells[e.ColumnIndex];
- object cValue = vCell.Value;
- try
- {
- switch ( vCell.ColumnIndex )
- {
- case 4:
- {
- if ( cValue.ToString() == "加急" )
- {
- vCell.Value = "";
- }
- else
- {
- vCell.Value = "加急";
- }
- UpdateDataGridViewRowProduct( this.dgv_product.Rows[vCell.RowIndex] );
- }
- break;
- case 7:
- if ( vCell.Value == null || cValue.ToString().Trim().Length <= 0 )
- {
- vCell.Value = this.ck_Pickup.Checked ? this.dt_Pickup.Value.ToString( "yyyy-MM-dd" ) : DateTime.Now.ToString( "yyyy-MM-dd" );
- UpdateDataGridViewRowProduct( this.dgv_product.Rows[vCell.RowIndex] );
- }
- break;
- default:
- break;
- }
- }
- catch { }
- }
- private void Btn_Cancel_Click( object sender, EventArgs e )
- {
- this.Close();
- }
- private void Btn_Save_Click( object sender, EventArgs e )
- {
- #region 同步N8的选版备注到数据库中;
- // 加载选版的备注信息item.data;
- string Notexml = string.Format( "{0}\\选版结果\\item.data", N8ServerUserDirectory );
- dalResultItem = new DAL.N8Process.DAL_N8ResultItem( Notexml );
- dalResultItem.LoadResultItem();
- List<string> listNotes = null;
- string strItemNotes = null;
- // 获取原备注;
- if ( this.CurrentModelDigital != null && this.CurrentModelDigital.Ordv_SelectionFilm.Length > 0 )
- {
- listNotes = this.CurrentModelDigital.Ordv_SelectionFilm.Split( '*' ).ToList();
- }
- // N8选版备注, 直接覆盖现有的选版备注;;
- if ( dalResultItem.ListResultItem.Count > 0 )
- {
- strItemNotes = "?";
- foreach ( Model.N8Process.N8ResultItem item in dalResultItem.ListResultItem )
- {
- strItemNotes += string.Format( "{0}:{1}|", item.path, item.comment );
- }
- strItemNotes.TrimEnd( '|' );
- strItemNotes = LYFZ.WinAPI.SDKSecurity.EncodeHex16String( strItemNotes );
- // 转码;
- if ( listNotes != null )
- currentModelDigital.Ordv_SelectionFilm = listNotes[0] + string.Format( "*{0}*", strItemNotes );
- else
- currentModelDigital.Ordv_SelectionFilm = string.Format( "*{0}*", strItemNotes );
- }
- // 保存时,设置成N8选版模式;
- currentModelDigital.Ordv_IsN8Model = true;
- #endregion
- this.CurrentModelDigital.Ordv_LookDesignClaim = tx_CustomerRequire.Text;
- if ( this.currentOrderBll.DAL.SaveSelectionFilm( LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID,
- this.CurrentModelDigital.Ordv_ViceNumber,
- this.CurrentModelDigital.Ordv_SelectionFilm,
- LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID,
- this.CurrentModelDigital,
- this.PhotoModelList,
- this.CurrentModelDigital.Ordv_DesignValidation ) )
- {
- MessageBoxCustom.Show( "保存成功" );
- }
- }
- private void FrmSaveN8Selection_Load( object sender, EventArgs e )
- {
- FillDialogWithData();
- }
- private void FillDialogWithData()
- {
- this.currentSelectPhotoInfo = new BLL.ProductSelectedPhotoInfo( this.CurrentModelDigital.Ordv_DesignValidation, Model.Model_ErpOrder.DirectoryType.DesignPiece ); //读取当前订单已选设计片信息
- LYFZ.ExtendControlLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
- {
- try
- {
- reservationProductList = new BLL.ManufactureProductsAndReservationProductsStatisticalProcess(
- this.CurrentModel.Ord_Number,
- this.CurrentModelDigital.Ordv_ViceNumber,
- this.PhotoModelList,
- this.currentSelectPhotoInfo );
- }
- catch { }
- } );
- LoadN8ViewGoResult();
- // 订单号;
- this.tx_OrderNumber.Text = CurrentModel.Ord_Number;
- // 获取顾客资料;
- LYFZ.BLL.BLL_ErpCustomer cusBll = new BLL.BLL_ErpCustomer();
- this.tx_Customer.Text = cusBll.GetCustomerNameList( this.currentModel.Ord_Number, "," );
- // 获取顾客要求;
- this.tx_CustomerRequire.Text = CurrentModelDigital.Ordv_LookDesignClaim;
- // 入底数量;
- this.tx_films.Text = CurrentModel.Ord_IntoBottom.ToString();
- // 入册数量;
- this.tx_album.Text = CurrentModel.Ord_IntoRegister.ToString();
- // 加挑总金额;
- this.tx_Money.Text = currentOrderBll.DAL.GetOrderPickupMoney(
- this.CurrentModel.Ord_Number,
- this.CurrentModelDigital.Ordv_ViceNumber,
- Convert.ToInt32( this.CurrentModel.Ord_Type ),
- this.CurrentModelDigital.Ordv_DigitalNumber ).ToString();
- // 重新获取选版结果;
- photoModelList = currentOrderBll.GetOrderProductList( this.CurrentModel.Ord_Number, this.CurrentModelDigital.Ordv_ViceNumber, DAL.OrderProductType.制作商品 );
- List<LYFZ.Model.Model_ErpOrderProductList> productLists = currentOrderBll.GetOrderProductList( this.CurrentModel.Ord_Number, this.CurrentModelDigital.Ordv_ViceNumber, DAL.OrderProductType.预约商品 );
- foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
- {
- DataGridViewRow dgr = new DataGridViewRow();
- dgr.CreateCells( this.dgv_product );
- dgr.Tag = opl;
- dgr.Cells[0].Value = opl.OPlist_ProdNumber;
- dgr.Cells[1].Value = opl.OPlist_ProdName;
- dgr.Cells[2].Value = opl.OPlist_ProdSoldPrice;
- dgr.Cells[3].Value = opl.OPlist_ProdQuantity;
- dgr.Cells[4].Value = opl.OPlist_IsExpedited ? "加急" : "";
- foreach ( PerGoodImg pi in this.listPerGoodPage )
- {
- if ( pi.strGoodName.Equals( opl.OPlist_ProdName ) )
- {
- dgr.Cells[5].Value = pi.listImgs.Count;
- break;
- }
- }
- foreach ( PerGoodImg pi in this.listPerGoodImg )
- {
- if ( pi.strGoodName.Equals( opl.OPlist_ProdName ) )
- {
- dgr.Cells[6].Value = pi.listImgs.Count;
- break;
- }
- }
- // 预约取件日期;
- if ( opl.OPlist_ReservationTakeTime.Ticks != 0 )
- dgr.Cells[7].Value = opl.OPlist_ReservationTakeTime;
- dgr.Cells[8].Value = opl.OPlist_Remark;
- if ( !IsHasReservationProduct( opl, productLists ) )
- {
- dgr.Cells[0].Style.BackColor = Color.Red;
- }
- this.dgv_product.Rows.Add( dgr );
- }
- }
- /// <summary>
- /// 加载N8选版结果;
- /// </summary>
- private void LoadN8ViewGoResult()
- {
- // 加载商品版面结果vgproduct.data;
- string vgproductxml = string.Format( "{0}\\选版结果\\vgproduct.data", N8ServerUserDirectory );
- dalResultViewGoProduct = new DAL.N8Process.DAL_N8ResultViewGoProduct( vgproductxml );
- dalResultViewGoProduct.LoadResultViewGoProduct();
- foreach ( Model.N8Process.N8ResultViewGoProduct product in dalResultViewGoProduct.ListResultViewGoProduct )
- {
- foreach ( string img in product.ListItem )
- {
- if ( img.StartsWith( "\\版面\\" ) )
- {
- if ( !IsTheGoodImgExists( this.listPerGoodPage, product.Name, img.Substring( "\\版面\\".Length ) ) )
- {
- InsertImgToGood( this.listPerGoodPage, product.Name, img.Substring( "\\版面\\".Length ) );
- }
- }
- else if ( img.StartsWith( "\\照片\\" ) )
- {
- if ( !IsTheGoodImgExists( this.listPerGoodImg, product.Name, img.Substring( "\\照片\\".Length ) ) )
- {
- InsertImgToGood( this.listPerGoodImg, product.Name, img.Substring( "\\照片\\".Length ) );
- }
- }
- }
- }
- // 加载版面相片album.pwt;
- string albumxml = string.Format( "{0}\\版面\\album.pwt", N8ServerUserDirectory );
- dalAlbum = new DAL.N8Process.DAL_N8Album( albumxml );
- dalAlbum.LoadAlbum();
- foreach ( PerGoodImg pi in this.listPerGoodPage )
- {
- foreach ( string page in pi.listImgs )
- {
- foreach ( Model.N8Process.N8Album album in dalAlbum.ListAlbum )
- {
- // 同一版面;
- if ( page.Equals( album.N8PageFileName.TrimEnd( ".jpg".ToCharArray() ).ToLower() ) )
- {
- foreach ( Model.N8Process.N8PageCell cell in album.ListItem )
- {
- string file = cell.N8PageCellFileName.Substring( cell.N8PageCellFileName.LastIndexOf( '\\' ) + 1 );
- if ( !IsTheGoodImgExists( this.listPerGoodImg, pi.strGoodName, file ) )
- {
- InsertImgToGood( this.listPerGoodImg, pi.strGoodName, file );
- }
- }
- }
- }
- }
- }
- try
- {
- // 是否有新商品增加、减少;
- StringBuilder strSQL = new StringBuilder();
- strSQL.Append( "(" );
- #region N8新增了哪些产品
- // 添加了哪些或减少(不是删除)哪些;
- LYFZ.BLL.BLL_ErpOrderProductList ordProdBll = new BLL.BLL_ErpOrderProductList();
- List<LYFZ.Helper.CommandInfo> commdinfoList = new List<Helper.CommandInfo>();
- foreach ( Model.N8Process.N8ResultViewGoProduct product in dalResultViewGoProduct.ListResultViewGoProduct )
- {
- int nNewCount = dalResultViewGoProduct.GetResultViewGoProductCount( product.Id );
- int nOldCount = GetProductCount( product.Id );
- // 商品选版前后的数量是否有添加;
- if ( nNewCount > nOldCount )
- {// 加挑了商品;
- for ( int i = nOldCount; i < nNewCount; i++ )
- {
- Model.Model_ErpProduct pp = ptbll.GetModel( "Prod_Number", product.Id );
- Model.Model_ErpOrderProductList plt = GetSelectOrderProduct( pp );
- photoModelList.Add( plt );
- commdinfoList.Add( ordProdBll.GetAddCommandInfo( plt ) );
- }
- }
- else if ( nNewCount < nOldCount )
- {// 减少了商品,只减没有选片的,如果选片关联了相片的,不减;
- string tempDelIdList = "";
- for ( int i = nOldCount; i > nNewCount; i-- )
- {
- foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
- {
- if ( opl.OPlist_ProdNumber.Equals( product.Id ) )
- {
- string name = product.Name;
- if ( product.Name.EndsWith( ")" ) && product.Name[product.Name.Length - 3] == '(' )
- name = product.Name.Substring( 0, product.Name.Length - 3 );
- // if ( -1 == CurrentModelDigital.Ordv_SelectionFilm.IndexOf( product.Name ) ) // 选片和N8选版只取一个,不会同时存在;
- {// 没有任何相关关联,可以删除;
- tempDelIdList += opl.ID + ",";
- photoModelList.Remove( opl );
- }
- break;
- }
- }
- }
- string delSql = "delete [dbo].[tb_ErpOrderProductList] where id in (" + tempDelIdList.Trim( ',' ) + ")";
- Helper.SQLHelper.ExecuteSql( delSql );
- }
- }
- // 事务来保存新增的商品;
- int ret = Helper.SQLHelper.ExecuteSqlTran( commdinfoList );
- #endregion
- #region N8删除了哪些产品
- // 删除了哪些或增加了哪些;
- List<LYFZ.Model.Model_ErpOrderProductList> tmplist = new List<LYFZ.Model.Model_ErpOrderProductList>();
- for ( int i = photoModelList.Count - 1; i > -1; i-- )
- {
- int nNewCount = GetProductCount( photoModelList[i].OPlist_ProdNumber );
- int nOldCount = dalResultViewGoProduct.GetResultViewGoProductCount( photoModelList[i].OPlist_ProdNumber );
- if ( nNewCount != nOldCount )
- {// 删除了哪些;
- //if ( -1 == CurrentModelDigital.Ordv_SelectionFilm.IndexOf( photoModelList[i].OPlist_ProdName ) )//选片和N8选版只取一个,不会同时存在;
- {// 没有任何相关关联,可以删除;
- string delSql = "delete [dbo].[tb_ErpOrderProductList] where id = " + photoModelList[i].ID + "";
- Helper.SQLHelper.ExecuteSql( delSql );
- photoModelList.RemoveAt( i );
- }
- continue;
- }
- }
- #endregion
- }
- catch ( Exception ex )
- {
- }
- }
- private bool IsTheGoodImgExists( List<PerGoodImg> listPerGoodImg, string good, string image )
- {
- bool bExists = false;
- image = image.ToLower();
- image = image.TrimEnd( ".jpg".ToCharArray() );
- foreach ( PerGoodImg pi in listPerGoodImg )
- {
- if ( pi.strGoodName.Equals( good ) )
- {
- foreach ( string img in pi.listImgs )
- {
- if ( img.Equals( image ) )
- {
- bExists = true;
- break;
- }
- }
- break;
- }
- }
- return bExists;
- }
- private void InsertImgToGood( List<PerGoodImg> listPerGoodImg, string good, string image )
- {
- bool bGoodExist = false;
- image = image.ToLower();
- image = image.TrimEnd( ".jpg".ToCharArray() );
- foreach ( PerGoodImg pi in listPerGoodImg )
- {
- if ( pi.strGoodName.Equals( good ) )
- {
- bGoodExist = true;
- pi.listImgs.Add( image );
- break;
- }
- }
- if ( !bGoodExist )
- {
- PerGoodImg pi = new PerGoodImg();
- pi.strGoodName = good;
- pi.listImgs = new List<string>();
- pi.listImgs.Add( image );
- listPerGoodImg.Add( pi );
- }
- }
- /// <summary>
- /// 更新当前行的商品对象
- /// </summary>
- /// <param name="row"></param>
- void UpdateDataGridViewRowProduct( DataGridViewRow row, bool isupdate = true )
- {
- if ( row.Tag != null )
- {
- LYFZ.Model.Model_ErpOrderProductList ordProduct = (LYFZ.Model.Model_ErpOrderProductList)row.Tag;
- if ( ordProduct.OPlist_UniquelyIdentity == LYFZ.BLL.SelectPhotoHandling.IntoFilmText
- || ordProduct.OPlist_UniquelyIdentity == LYFZ.BLL.SelectPhotoHandling.IntoBookText )
- {
- return;
- }
- if ( row.Cells[3].Value != null )
- {
- int oldProdQuantity = ordProduct.OPlist_ProdQuantity;
- int newProdQuantity = Convert.ToInt32( row.Cells[3].Value );
- ordProduct.OPlist_ProdQuantity = newProdQuantity;
- row.Cells[3].Style.ForeColor = this.reservationProductList.GetRowProdQuantityTextColor( ordProduct );
- if ( row.Cells[3].Style.ForeColor.Name == Color.Red.Name && newProdQuantity > oldProdQuantity )
- {
- if ( ExMessageBoxCustom.Show( "您输入的数量大于预约数量,是否确定要继续输入?", msgBoxButton: MessageBoxButtons.YesNo ) == System.Windows.Forms.DialogResult.No )
- {
- row.Cells[3].Value = oldProdQuantity;
- ordProduct.OPlist_ProdQuantity = oldProdQuantity;
- row.Cells[3].Style.ForeColor = this.reservationProductList.GetRowProdQuantityTextColor( ordProduct );
- }
- }
- }
- if ( row.Cells[4].Value != null )
- {
- if ( row.Cells[4].Value.ToString().Trim().Length > 0 )
- {
- ordProduct.OPlist_IsExpedited = true;
- }
- else
- {
- ordProduct.OPlist_IsExpedited = false;
- }
- }
- if ( row.Cells[7].Value != null )
- {
- if ( row.Cells[7].Value.ToString().Trim().Length > 0 )
- {
- ordProduct.OPlist_ExpeditedTime = Convert.ToDateTime( row.Cells[7].Value.ToString() );
- }
- else
- {
- ordProduct.OPlist_ExpeditedTime = Convert.ToDateTime( "1900-01-01" );
- }
- ordProduct.OPlist_ReservationTakeTime = ordProduct.OPlist_ExpeditedTime;
- }
- else
- {
- ordProduct.OPlist_ExpeditedTime = Convert.ToDateTime( "1900-01-01" );
- ordProduct.OPlist_ReservationTakeTime = ordProduct.OPlist_ExpeditedTime;
- }
- if ( row.Cells[8].Value != null )
- {
- ordProduct.OPlist_Remark = row.Cells[8].Value.ToString().Trim();
- }
- else
- {
- ordProduct.OPlist_Remark = "";
- }
- }
- }
- /// <summary>
- /// 返回商品个数
- /// </summary>
- /// <param name="productId"></param>
- /// <returns></returns>
- private int GetProductCount( string productId )
- {
- int nCount = 0;
- foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
- {
- if ( opl.OPlist_ProdNumber.Equals( productId ) )
- {
- ++nCount;
- }
- }
- return nCount;
- }
- LYFZ.Model.Model_ErpOrderProductList GetSelectOrderProduct( LYFZ.Model.Model_ErpProduct pModel )
- {
- //this.CMainPhotoSelect.SelectedPieceInfoModify = true;
- LYFZ.Model.Model_ErpOrderProductList ordProdructModel = new LYFZ.Model.Model_ErpOrderProductList();
- ordProdructModel.OPlist_DividedShop = LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID;
- ordProdructModel.OPlist_ProdNumber = pModel.Prod_Number;
- ordProdructModel.OPlist_ProdName = pModel.Prod_Name;
- ordProdructModel.OPlist_ProdQuantity = 1;
- ordProdructModel.OPlist_ProdSoldPrice = pModel.Prod_SalesPrice;
- ordProdructModel.OPlist_CostPrice = pModel.Prod_CostPrice;
- ordProdructModel.OPlist_Class = pModel.Prod_Class;
- ordProdructModel.OPlist_Batch = pModel.Prod_Batch;
- ordProdructModel.OPlist_Unit = pModel.Prod_Unit;
- ordProdructModel.OPlist_Type = "2";
- ordProdructModel.OPlist_OriginalP = pModel.Prod_Batch;
- ordProdructModel.OPlist_OrderNumber = this.CurrentModel.Ord_Number;
- ordProdructModel.OPlist_ViceNumber = this.CurrentModelDigital.Ordv_ViceNumber;
- ordProdructModel.OPlist_UniquelyIdentity = LYFZ.DAL.DAL_ErpOrderProductList.GetPorductUniquelyIdentity();
- ordProdructModel.OPlist_OrderByNumber = GetNewOPlistOrderByNumber();
- return ordProdructModel;
- }
- /// <summary>
- /// 临时计数器
- /// </summary>
- int tempOrderByNumberCount = 0;
- /// <summary>
- /// 获取新的排序编号
- /// </summary>
- /// <returns></returns>
- int GetNewOPlistOrderByNumber()
- {
- int retOrderByNumber = 0;
- tempOrderByNumberCount++;
- foreach ( LYFZ.Model.Model_ErpOrderProductList opl in photoModelList )
- {
- if ( opl != null )
- {
- if ( opl.OPlist_OrderByNumber > retOrderByNumber )
- {
- retOrderByNumber = opl.OPlist_OrderByNumber;
- }
- }
- }
- return retOrderByNumber + tempOrderByNumberCount;
- }
- /// <summary>
- /// 判断一个制作商品是否有对应的预约商品, 如果没有则表示该商品为加挑商品;
- /// </summary>
- /// <param name="model">制作商品</param>
- /// <param name="list">预约商品列表</param>
- /// <returns></returns>
- bool IsHasReservationProduct( LYFZ.Model.Model_ErpOrderProductList model, List<LYFZ.Model.Model_ErpOrderProductList> list )
- {
- bool has = false;
- foreach ( LYFZ.Model.Model_ErpOrderProductList item in list )
- {
- if ( item.OPlist_OrderByNumber == model.OPlist_OrderByNumber )
- {
- has = true;
- break;
- }
- }
- return has;
- }
- }
- }
|