using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Collections; using LYFZ.Software.MainBusiness.DoorCityProcess; using LYFZ.Helper; namespace LYFZ.Software.MainBusiness.CameraControlBook.SmallForm { public partial class WeddingReservationSmallForm : LYFZ.Software.UI.CameraControlBook.SmallForm.WeddingReservationSmallForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpProduct pdtbll = new BLL.BLL_ErpProduct(); LYFZ.BLL.BLL_SMSTemplates smsTemplates = new BLL.BLL_SMSTemplates(); LYFZ.BLL.BLL_ErpPlusPickItems Pbll = new BLL.BLL_ErpPlusPickItems(); LYFZ.BLL.BLL_ErpWeddingService Wbll = new BLL.BLL_ErpWeddingService(); LYFZ.BLL.BLL_ErpProductIntStorage pisbll = new BLL.BLL_ErpProductIntStorage(); LYFZ.BLL.BLL_ErpProductOutStorage posbll = new BLL.BLL_ErpProductOutStorage(); LYFZ.BLL.BLL_ErpOrderWorkAnPaiRecord ordwr = new BLL.BLL_ErpOrderWorkAnPaiRecord(); LYFZ.BLL.BLL_ErpPieceCommissionRecords pcrbll = new BLL.BLL_ErpPieceCommissionRecords(); public WeddingReservationSmallForm() { this.Shown += WeddingReservationSmallForm_Shown; this.btnAddingGuests.Click += btnAddingGuests_Click; this.btnUpdate.Click += btnUpdate_Click; this.btnAddService.Click += btnAddService_Click; this.btnDelete.Click += btnDelete_Click; this.btnSave.Click += btnSave_Click; this.lstTextQuery.MouseDoubleClick += lstTextQuery_MouseDoubleClick; this.lstTextQuery.KeyDown += lstTextQuery_KeyDown; this.txtTextQuery.EventTextBoxEx_TextChanged += txtTextQuery_EventTextBoxEx_TextChanged; this.txtTextQuery.Enter += txtTextQuery_Enter; this.txtTextQuery.KeyDown += txtTextQuery_KeyDown; this.txtTextQuery.Leave += txtTextQuery_Leave; this.dgvData.CellDoubleClick += dgvData_CellDoubleClick; this.cmbtreevdgv.Leave += cmbtreevdgv_Leave; this.cmbtreevStoreName.Leave += cmbtreevStoreName_Leave; this.cmbtreevStoreName.IsNodeMouseClick = true; this.cmbtreevStoreName.AfterSelectLevelFirstNode = true; this.cmbdgv.Leave += cmbdgv_Leave; this.mskdgv.Leave += mskdgv_Leave; this.txtdgv.Leave += txtdgv_Leave; this.dtpcdgv.Leave += dtpcdgv_Leave; this.dgvData.CellMouseDown += dgvData_CellMouseDown; this.btnQuery.Click += btnQuery_Click; this.txtIntCount.Leave += txtIntCount_Leave; this.txtIntCount.KeyPress += txtIntCount_KeyPress; this.dgvData.DataGridViewConMenu_ItemClicked += dgvData_DataGridViewConMenu_ItemClicked; } Model.CameraTimeTemplate currentSelectCameraTime = null; /// /// 当前选择的档期 /// public Model.CameraTimeTemplate CurrentSelectCameraTime { get => currentSelectCameraTime; set => currentSelectCameraTime = value; } /// /// 是否保存 /// public bool IsSaveed = false; /// /// 订单号 /// public string OrdNumber; private DataTable tbl_Department = new DataTable(); private ArrayList listDeteleID = new ArrayList(); string[] StrStatus = ("未开始,进行中,OK").Split( ',' ); /// /// 首次运行 true是,false不是 /// bool IsFirstRun = true; /// /// 订单类型 /// string StrOrdType = ""; /// /// 重新安排 /// bool IsUpdateAnPai = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CameraControlBook, LYFZ.CustomAttributes.OperatingAuthority.CameraControlBook_PhotographClientAnPaiUpdate ); /// /// 窗体加载事件 /// /// /// void WeddingReservationSmallForm_Shown( object sender, EventArgs e ) { if (this.currentSelectCameraTime != null) { this.lbSelectDateInfo.Text = this.currentSelectCameraTime.GetCameraTimeInfo(LYFZ.DAL.DAL_ErpCompanyInfo.ToShopIDToShopName(this.currentSelectCameraTime.DayTemplate.ShopID), String.Format("{0} {1}", this.currentSelectCameraTime.DayTemplate.CameraDateTime.JavaScriptTimeStampToDateTime().ToYYYY_MM_dd(), this.currentSelectCameraTime.CameraTime)); } else { this.lbSelectDateInfo.Text = ""; } LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindStoreNameALL( this.cmbtreevStoreName, IsShowAllText: false ); tbl_Department = orbll.GetView_Custom( "tb_ErpDepartment", ShowColumnName: "ID,Dt_Name" ).Tables[0]; if ( !string.IsNullOrEmpty( OrdNumber ) ) { this.panelEx2.Visible = false; this.panelEx4.Height = this.panelEx1.Size.Height - 4; this.btnAddingGuests.Visible = false; this.GetOrdNumberGetData(); } else { this.SetClientData(); this.GetOrdNumberGetData(); } this.panelEx4.Visible = true; this.IsFirstRun = false; this.btnSave.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CameraControlBook, LYFZ.CustomAttributes.OperatingAuthority.CameraControlBook_ServiceClientAnPai ); } /// /// 添加客人 /// /// /// void btnAddingGuests_Click( object sender, EventArgs e ) { EnumPublic.OrderType orderType = LYFZ.EnumPublic.OrderType.服务订单; #if DEBUG this.OpenNewOrder( orderType, "" ); #else LYFZ.Software.MainBusiness.DoorCityProcess.OnSingleFormMain01 frm = new OnSingleFormMain01(); frm.OrdType = orderType; frm.ShowDialog(); if (frm.IsSaveed) { this.OrdNumber = frm.StrNumber; this.GetOrdNumberGetData(); } #endif } /// /// 修改资料 /// /// /// void btnUpdate_Click( object sender, EventArgs e ) { if ( !string.IsNullOrEmpty( this.OrdNumber ) ) { if ( !string.IsNullOrEmpty( this.StrOrdType ) ) { EnumPublic.OrderType orderType = (LYFZ.EnumPublic.OrderType)Enum.Parse( typeof( LYFZ.EnumPublic.OrderType ), this.StrOrdType ); //#if DEBUG this.OpenNewOrder( orderType, this.OrdNumber ); //#else // LYFZ.Software.MainBusiness.DoorCityProcess.OnSingleFormMain01 frm = new OnSingleFormMain01(); // frm.OrdType = orderType; // frm.StrNumber = this.OrdNumber; // frm.ShowDialog(); // if (frm.IsSaveed) // { // this.OrdNumber = frm.StrNumber; // this.GetOrdNumberGetData(); // } //#endif } } } void OpenNewOrder( EnumPublic.OrderType orderType, string _OrderNumber = "" ) { frmNewOrder newOrder = new frmNewOrder(); newOrder.OrderNumber = _OrderNumber; //newOrder.IsShowUcNavigationTool = false; //newOrder.StartPosition = System.Windows.Forms.FormStartPosition.Manual; //newOrder.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y); //newOrder.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height); newOrder.OrderType = orderType; newOrder.ShowDialog(); if ( newOrder.IsSaveData ) { this.OrdNumber = newOrder.OrderNumber; this.GetOrdNumberGetData(); } } /// /// 添加服务 /// /// /// void btnAddService_Click( object sender, EventArgs e ) { if ( string.IsNullOrEmpty( this.OrdNumber ) ) { MessageBoxCustom.Show( "未选择订单!" ); return; } LYFZ.Software.MainBusiness.DoorCityProcess.SetSmallForm.ToolboxSamllForm frm = new LYFZ.Software.MainBusiness.DoorCityProcess.SetSmallForm.ToolboxSamllForm(); frm.LoadType = "婚庆服务"; frm.ShowDialog(); if ( frm.IsSaveed ) { List mlist = frm.mlist; for ( int k = 0; k < this.dgvData.Rows.Count; k++ ) { for ( int i = 0; i < mlist.Count; i++ ) { if ( this.dgvData.Rows[k].Cells["Ws_ProdNumber"].Value.ToString().Trim() == mlist[i].Prod_Number.Trim() && this.dgvData.Rows[k].Cells["服务状态"].Value.ToString().Trim() != "OK" ) { this.dgvData.Rows[k].Cells["数量"].Value = (Convert.ToInt32( this.dgvData.Rows[k].Cells["数量"].Value ) + 1).ToString().Trim(); this.dgvData.Rows[k].Tag = "1"; mlist.RemoveAt( i ); break; } } } for ( int i = 0; i < mlist.Count; i++ ) { DataGridViewRow dgvl = new DataGridViewRow(); DataGridViewCell cell = null; cell = new DataGridViewTextBoxCell(); cell.Value = ""; dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); cell.Value = mlist[i].Prod_Number.Trim(); dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); cell.Value = "2"; dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); cell.Value = mlist[i].Prod_CostPrice; dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); cell.Value = mlist[i].Prod_SalesPrice; dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); cell.Value = mlist[i].Prod_Name.Trim(); dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); cell.Value = "1"; dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); DataTable dt = orbll.GetView_Custom( "select Company_DividedShop,Company_Name from tb_ErpCompanyInfo where Company_DividedShop ='" + LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.CurrentCompanyInfoID + "'" ).Tables[0]; cell.Value = dt.Rows[0]["Company_Name"].ToLowerString().Trim(); cell.Tag = dt.Rows[0]["Company_DividedShop"].ToLowerString().Trim(); dgvl.Cells.Add( cell ); cell = new DataGridViewTextBoxCell(); cell.Value = StrStatus[0].Trim(); dgvl.Cells.Add( cell ); for ( int k = 0; k < 5; k++ ) { cell = new DataGridViewTextBoxCell(); cell.Value = ""; cell.Tag = ""; dgvl.Cells.Add( cell ); } dgvl.Tag = "1"; this.dgvData.Rows.Add( dgvl ); } } } /// /// 删除服务 /// /// /// void btnDelete_Click( object sender, EventArgs e ) { if ( this.dgvData.SelectedRows.Count > 0 ) { if ( this.dgvData.SelectedRows.Count == 1 ) { if ( this.dgvData.SelectedRows[0].Cells["ID"].Value.ToString().Trim() != "" ) { if ( MessageBoxCustom.Show( "你确定要删除选择的服务?", "温馨提示", MessageBoxButtons.YesNo ) == DialogResult.Yes ) { if ( this.dgvData.SelectedRows[0].Cells["Ws_Type"].Value.ToString().Trim() == "2" ) { listDeteleID.Add( this.dgvData.SelectedRows[0].Cells["ID"].Value.ToString().Trim() ); } this.dgvData.Rows.RemoveAt( this.dgvData.SelectedRows[0].Index ); } } else { this.dgvData.Rows.RemoveAt( this.dgvData.SelectedRows[0].Index ); } } else { if ( MessageBoxCustom.Show( "你确定要删除选择的服务?\r\n\r\n说明:只能删除此处添加的服务", "温馨提示", MessageBoxButtons.YesNo ) == DialogResult.Yes ) { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["ID"].Value.ToString().Trim() != "" ) { if ( this.dgvData.SelectedRows[i].Cells["Ws_Type"].Value.ToString().Trim() == "2" ) { listDeteleID.Add( this.dgvData.SelectedRows[i].Cells["ID"].Value.ToString().Trim() ); } this.dgvData.Rows.RemoveAt( this.dgvData.SelectedRows[i].Index ); } else { this.dgvData.Rows.RemoveAt( this.dgvData.SelectedRows[i].Index ); } } } } } } LYFZ.BLL.ReservationTimeData timeDataBll = new BLL.ReservationTimeData(); /// /// 暂存预约选择的档期数据 /// Dictionary TimeTemplateKeyValues = new Dictionary(); Model.CameraOrderType GetCameraOrderType() { return (Model.CameraOrderType)Convert.ToInt32(this.StrOrdType); } /// /// 保存 /// /// /// void btnSave_Click( object sender, EventArgs e ) { if ( this.dgvData.Rows.Count > 0 ) { if ( string.IsNullOrEmpty( this.OrdNumber ) ) { MessageBoxCustom.Show( "未选择订单!" ); return; } string StrName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID; DateTime StrTime = SDateTime.Now; List cameraParameterList = new List(); List clist = new List(); bool Isbl = false; string StrServerContent = ""; for ( int i = 0; i < this.dgvData.Rows.Count; i++ ) { if ( this.dgvData.Rows[i].Cells["ID"].Value.ToString().Trim() == "" ) { Isbl = true; StrServerContent += this.dgvData.Rows[i].Cells["服务内容"].Value.ToString().Trim() + ","; } } if ( listDeteleID.Count > 0 ) { Isbl = true; } decimal dec_Amount = 0; string str_Name = ""; string str_Remark = ""; string str_SaleMan = ""; string str_TwoSaleCategory = ""; if ( Isbl ) { LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.ServicePaymentSuperSmallForm frm = new SuperSmallForm.ServicePaymentSuperSmallForm(); frm.StrServerText = StrServerContent.TrimEnd( ',' ); frm.ShowDialog(); if ( !frm.IsSave ) { return; } dec_Amount = frm.OutAmount; str_Name = frm.OutName; str_Remark = frm.OutRemark; str_SaleMan = frm.SaleMan; str_TwoSaleCategory = frm.TwoSaleCategory; } #region 服务内容 for ( int i = 0; i < listDeteleID.Count; i++ ) { clist.Add( Wbll.GetDeleteCommandInfo( "ID", "=", listDeteleID[i].ToString().Trim() ) ); } LYFZ.Model.Model_ErpWeddingService wm = null; Hashtable htEmssAnPai = new Hashtable(); Hashtable htEmssOK = new Hashtable(); for ( int i = 0; i < this.dgvData.Rows.Count; i++ ) { if ( this.dgvData.Rows[i].Tag != null ) { if ( !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["ID"].Value.ToString().Trim() ) ) { wm = Wbll.GetModel( Convert.ToInt32( this.dgvData.Rows[i].Cells["ID"].Value ) ); string StrRen = ""; if ( this.dgvData.Rows[i].Cells["服务人员1"].Tag != null && wm.Ws_Serviceman1.Trim() != this.dgvData.Rows[i].Cells["服务人员1"].Tag.ToString().Trim() ) { StrRen += this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() + ","; } if ( this.dgvData.Rows[i].Cells["服务人员2"].Tag != null && wm.Ws_Serviceman2.Trim() != this.dgvData.Rows[i].Cells["服务人员2"].Tag.ToString().Trim() ) { StrRen += this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() + ","; } if ( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() != LYFZ.Command.Command_Validate.DateTimeToString( wm.Ws_WeddingDate ) ) { if ( !string.IsNullOrEmpty( StrRen ) ) { if ( htEmssAnPai.ContainsKey( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() ) ) { htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] + StrRen; } else { htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = StrRen; } } else { string StrRen3 = ""; if ( !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() ) ) { StrRen3 += this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() + ","; } if ( !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() ) ) { StrRen3 += this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() + ","; } if ( htEmssAnPai.ContainsKey( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() ) ) { htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] + StrRen3; } else { htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = StrRen3; } } } string StrStatus = this.dgvData.Rows[i].Cells["服务状态"].Value.ToString().Trim() == "未开始" ? "0" : this.dgvData.Rows[i].Cells["服务状态"].Value.ToString().Trim() == "OK" ? "1" : "2"; if ( this.dgvData.Rows[i].Cells["服务状态"].Tag != null ) { if ( this.dgvData.Rows[i].Cells["服务状态"].Tag.ToString().Trim() == "1" && wm.Ws_Status.Trim() != StrStatus && StrStatus == "1" ) { string StrRen2 = ""; if ( !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() ) ) { StrRen2 += this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() + ","; } if ( !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["服务人员2"].Tag.ToString().Trim() ) ) { StrRen2 += this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() + ","; } if ( htEmssOK.ContainsKey( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() ) ) { htEmssOK[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = htEmssOK[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] + StrRen2; } else { htEmssOK[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = StrRen2; } } } if(StrStatus!="0") { wm.Ws_ServiceShopID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.CurrentCompanyInfoID; } if ( this.dgvData.Rows[i].Cells["数量"].Value.ToString().Trim() != "" ) { wm.Ws_ProdQuantity = Convert.ToInt32( this.dgvData.Rows[i].Cells["数量"].Value ); } if ( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() != "" && this.dgvData.Rows[i].Cells["服务时间"].Value.ToString().Trim() != "" ) { wm.Ws_WeddingDate = Convert.ToDateTime( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() + " " + this.dgvData.Rows[i].Cells["服务时间"].Value.ToString().Trim() ); } else if ( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() != "" ) { wm.Ws_WeddingDate = Convert.ToDateTime( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() ); } else { wm.Ws_WeddingDate = null; this.dgvData.Rows[i].Cells["服务时间"].Value = ""; } if ( this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() != "" ) { wm.Ws_Serviceman1 = this.dgvData.Rows[i].Cells["服务人员1"].Tag.ToString().Trim(); } else { wm.Ws_Serviceman1 = ""; } if ( this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() != "" ) { wm.Ws_Serviceman2 = this.dgvData.Rows[i].Cells["服务人员2"].Tag.ToString().Trim(); } else { wm.Ws_Serviceman2 = ""; } //// if (string.IsNullOrEmpty(wm.Ws_ReservationServiceDividedShop)) //{ wm.Ws_ReservationServiceDividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); } if ( this.dgvData.Rows[i].Cells["服务门店"].Tag != null ) { wm.Ws_ReservationServiceDividedShop = this.dgvData.Rows[i].Cells["服务门店"].Tag.ToString(); } else { wm.Ws_ReservationServiceDividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); } wm.Ws_Status = StrStatus; wm.Ws_Remark = this.dgvData.Rows[i].Cells["服务备注"].Value.ToString().Trim(); wm.Ws_WeddingDispatchDate = StrTime; wm.Ws_WeddingDispatcher = StrName; clist.AddRange( this.GetLessInventory( ref wm, StrTime, StrName ) ); clist.Add( Wbll.GetUpdateCommandInfo( wm ) ); #region 设置模板预约 cameraParameterList.Add(new Model.ReservtionParameter { ShopID = wm.Ws_ReservationServiceDividedShop , DayDate = this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() , Time = this.dgvData.Rows[i].Cells["服务时间"].Value.ToString().Trim() , VID = wm.ID.ToString() }); #endregion LYFZ.Model.Model_ErpWeddingService modelnew = Wbll.GetModel( Convert.ToInt32( this.dgvData.Rows[i].Cells["ID"].Value ) ); if ( !modelnew.Ws_Serviceman1.Equals( wm.Ws_Serviceman1 ) || !modelnew.Ws_Serviceman2.Equals( wm.Ws_Serviceman2 ) || !modelnew.Ws_WeddingDate.Equals( wm.Ws_WeddingDate ) || !modelnew.Ws_ReservationServiceDividedShop.Equals( wm.Ws_ReservationServiceDividedShop ) ) { string storaRecord = ""; if ( this.dgvData.Rows[i].Cells["服务门店"].Value.ToString().Trim() != "" ) { storaRecord = "门店:" + this.dgvData.Rows[i].Cells["服务门店"].Value.ToString().Trim() + " "; } LYFZ.Model.Model_ErpOrderWorkAnPaiRecord modelRecord = new Model.Model_ErpOrderWorkAnPaiRecord(); modelRecord.Ordwr_Number = "OWPR_" + LYFZ.BLL.BLL_ErpCustomer.GetClientNumber(); modelRecord.Ordwr_WorkNumber = wm.ID.ToString().Trim(); modelRecord.Ordwr_OrdNumber = wm.Ws_Number; modelRecord.Ordwr_ViceNumber = wm.Ws_ViceNumber; modelRecord.Ordwr_ModuleName = LYFZ.EnumPublic.WorkAnPaiChangeLogEnum.摄控安排服务客人.ToString(); modelRecord.Ordwr_UpdateOrderName = wm.Ws_ProdName; modelRecord.Ordwr_UpdateAgoPerson = wm.Ws_WeddingDispatcher; modelRecord.Ordwr_UpdateAgoTime = wm.Ws_WeddingDispatchDate; modelRecord.Ordwr_UpdateAgoData = storaRecord + "服务时间:" + LYFZ.BLL.OtherCommonModel.DateTimeToString( wm.Ws_WeddingDate ) + " 服务人员1:" + LYFZ.BLL.BLL_ErpOrderView.GetUserName( wm.Ws_Serviceman1 ) + " 服务人员2:" + LYFZ.BLL.BLL_ErpOrderView.GetUserName( wm.Ws_Serviceman2 ); modelRecord.Ordwr_CreateDatetime = StrTime; modelRecord.Ordwr_CreateName = StrName; clist.Add( ordwr.GetAddCommandInfo( modelRecord ) ); } if ( LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ServiceCompletedAddPieceRate && wm.Ws_Status == "1" ) { if ( !string.IsNullOrEmpty( wm.Ws_Serviceman1 ) ) { LYFZ.Model.Model_ErpPieceCommissionRecords modelRecords = LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetPieceCommissionRecordsModel( wm, 1, StrTime, StrName ); if ( modelRecords != null ) { clist.Add( pcrbll.GetAddCommandInfo( modelRecords ) ); } } if ( !string.IsNullOrEmpty( wm.Ws_Serviceman2 ) ) { LYFZ.Model.Model_ErpPieceCommissionRecords modelRecords = LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetPieceCommissionRecordsModel( wm, 2, StrTime, StrName ); if ( modelRecords != null ) { clist.Add( pcrbll.GetAddCommandInfo( modelRecords ) ); } } } else { string StrContentName = wm.Ws_Number + "_" + wm.Ws_ProdName + "_" + wm.Ws_UpdateDateTime.ToString( "yyyyMMdd HHmmssfff" ); DataTable tbl = orbll.GetView_Custom( "tb_ErpPieceCommissionRecords", StrWhere: "Pcr_MarkKey = '" + StrContentName + "'", ShowColumnName: "ID" ).Tables[0]; if ( tbl.Rows.Count > 0 ) { clist.Add( pcrbll.GetDeleteCommandInfo( "ID", "=", tbl.Rows[0]["ID"] ) ); } } } else { wm = new Model.Model_ErpWeddingService(); string StrRen = ""; if ( !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["服务人员1"].Tag.ToString().Trim() ) ) { StrRen += this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() + ","; } if ( StrRen != this.dgvData.Rows[i].Cells["服务人员2"].Tag.ToString().Trim() && !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["服务人员2"].Tag.ToString().Trim() ) ) { StrRen += this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() + ","; } if ( string.IsNullOrEmpty( StrRen ) ) { if ( !string.IsNullOrEmpty( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() ) ) { if ( htEmssAnPai.ContainsKey( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() ) ) { htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] + StrRen; } else { htEmssAnPai[this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim()] = StrRen; } } } wm.Ws_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); wm.Ws_Number = this.OrdNumber; wm.Ws_Type = "2"; wm.Ws_OrderByNumber = (i + 1); wm.Ws_ProdNumber = this.dgvData.Rows[i].Cells["Ws_ProdNumber"].Value.ToString().Trim(); wm.Ws_ProdName = this.dgvData.Rows[i].Cells["服务内容"].Value.ToString().Trim(); wm.Ws_ProdCostPrice = Convert.ToDecimal( this.dgvData.Rows[i].Cells["Ws_ProdCostPrice"].Value ); wm.Ws_ProdSoldPrice = Convert.ToDecimal( this.dgvData.Rows[i].Cells["Ws_ProdSoldPrice"].Value ); wm.Ws_ProdQuantity = Convert.ToInt32( this.dgvData.Rows[i].Cells["数量"].Value ); if ( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() != "" ) { if ( this.dgvData.Rows[i].Cells["服务时间"].Value.ToString().Trim() != "" ) { wm.Ws_WeddingDate = Convert.ToDateTime( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() + " " + this.dgvData.Rows[i].Cells["服务时间"].Value.ToString().Trim() ); } else { wm.Ws_WeddingDate = Convert.ToDateTime( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() ); } } wm.Ws_WeddingDateLunar = "0"; if ( this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() != "" ) { wm.Ws_Serviceman1 = this.dgvData.Rows[i].Cells["服务人员1"].Tag.ToString().Trim(); } else { wm.Ws_Serviceman1 = ""; } if ( this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() != "" ) { wm.Ws_Serviceman2 = this.dgvData.Rows[i].Cells["服务人员2"].Tag.ToString().Trim(); } else { wm.Ws_Serviceman2 = ""; } wm.Ws_Status = this.dgvData.Rows[i].Cells["服务状态"].Value.ToString().Trim() == "未开始" ? "0" : this.dgvData.Rows[i].Cells["服务状态"].Value.ToString().Trim() == "OK" ? "1" : "2"; wm.Ws_Remark = this.dgvData.Rows[i].Cells["服务备注"].Value.ToString().Trim(); if ( this.dgvData.Rows[i].Cells["服务日期"].Value.ToString().Trim() != "" || this.dgvData.Rows[i].Cells["服务人员1"].Value.ToString().Trim() != "" || this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() != "" || this.dgvData.Rows[i].Cells["服务人员2"].Value.ToString().Trim() != "" || this.dgvData.Rows[i].Cells["服务状态"].Value.ToString().Trim() != "未开始" || this.dgvData.Rows[i].Cells["服务备注"].Value.ToString().Trim() != "" ) { wm.Ws_WeddingDispatchDate = StrTime; wm.Ws_WeddingDispatcher = StrName; } // if (string.IsNullOrEmpty(wm.Ws_ReservationServiceDividedShop)) { wm.Ws_ReservationServiceDividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); } wm.Ws_UpdateDateTime = StrTime; wm.Ws_UpdateName = StrName; clist.AddRange( this.GetLessInventory( ref wm, StrTime, StrName ) ); clist.Add( Wbll.GetAddCommandInfo( wm ) ); if ( LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ServiceCompletedAddPieceRate && wm.Ws_Status == "1" ) { if ( !string.IsNullOrEmpty( wm.Ws_Serviceman1 ) ) { LYFZ.Model.Model_ErpPieceCommissionRecords modelRecords = LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetPieceCommissionRecordsModel( wm, 1, StrTime, StrName ); if ( modelRecords != null ) { clist.Add( pcrbll.GetAddCommandInfo( modelRecords ) ); } } if ( !string.IsNullOrEmpty( wm.Ws_Serviceman2 ) ) { LYFZ.Model.Model_ErpPieceCommissionRecords modelRecords = LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetPieceCommissionRecordsModel( wm, 2, StrTime, StrName ); if ( modelRecords != null ) { clist.Add( pcrbll.GetAddCommandInfo( modelRecords ) ); } } } } } } #endregion #region 新增收款项目 if ( Isbl ) { LYFZ.Model.Model_ErpPlusPickItems model = new Model.Model_ErpPlusPickItems();// Obll.GetModel("Ord_Number", this.OrdNumber); model.Plu_OrdNumber = this.OrdNumber; model.Plu_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); model.Plu_Amount = dec_Amount; model.Plu_Goods = str_Name; model.Plu_GoodsCosts = "0"; model.Plu_SourceType = "0"; model.Plu_OpenSingle = str_SaleMan; model.Plu_TwoPinsCategory = str_TwoSaleCategory; model.Plu_RecordedPerson = StrName; model.Plu_CreateTime = StrTime; clist.Add( Pbll.GetAddCommandInfo( model ) ); } #endregion if ( clist.Count > 0 ) { string retErrorMsg = ""; if (!this.timeDataBll.UpdateReservationTimeDataCommandInfoList(OrdNumber, this.txtOrderNumber.Text, Model.CameraType.服务客人, this.GetCameraOrderType(), cameraParameterList, ref clist, ref retErrorMsg)) { MessageBoxCustom.Show(String.Format("保存预约失败:{0}", retErrorMsg)); return; } if ( LYFZ.BLL.BaseBllOperate.ExecuteSqlTran( clist ) <= 0 ) { MessageBoxCustom.Show( "添加收收款项目失败;" ); return; } new System.Threading.Thread( new System.Threading.ThreadStart( delegate () { LYFZ.BLL.BLL_ErpOrderDigitalStatus.UpdateDigitalStatus( this.OrdNumber, EnumPublic.OrderDigitalStatusEnum.摄控服务 ); } ) ).Start(); } if ( htEmssAnPai.Count > 0 || htEmssOK.Count > 0 ) { System.Threading.Thread t = new System.Threading.Thread( new System.Threading.ThreadStart( delegate () { if ( htEmssAnPai.Count > 0 ) { foreach ( DictionaryEntry item in htEmssAnPai ) { if ( !string.IsNullOrEmpty( item.Key.ToString().Trim() ) ) { Model.SMSParameters sparameters = new Model.SMSParameters(); sparameters.OrderNumber = wm.Ws_Number; sparameters.AppointmentPhotographingTime = Convert.ToDateTime( item.Key ); try { smsTemplates.GenerateEventSMS( EnumPublic.SmsSendEvent.服务预约后X分钟, sparameters ); } catch { } } } } if ( htEmssOK.Count > 0 ) { foreach ( DictionaryEntry item in htEmssOK ) { if ( !string.IsNullOrEmpty( item.Key.ToString().Trim() ) ) { Model.SMSParameters sparameters = new Model.SMSParameters(); sparameters.OrderNumber = wm.Ws_Number; sparameters.AppointmentPhotographingTime = Convert.ToDateTime( item.Key ); try { smsTemplates.GenerateEventSMS( EnumPublic.SmsSendEvent.服务完成后X分钟, sparameters ); } catch { } } } } } ) ); t.Start(); } MessageBoxCustom.Show( "保存成功" ); this.IsSaveed = true; this.Close(); } } /// /// 减库存 /// /// /// /// /// List GetLessInventory( ref LYFZ.Model.Model_ErpWeddingService model, DateTime StrTime, string StrUserID ) { List clist = new List(); DataTable tblList = orbll.GetView_Custom( "tb_ErpProduct", StrWhere: "Prod_Number = '" + model.Ws_ProdNumber + "' And Prod_Availability = 1", ShowColumnName: "*" ).Tables[0]; if ( tblList.Rows.Count > 0 ) { LYFZ.Model.Model_ErpProduct modelpt = pdtbll.DataRowToModel( tblList.Rows[0] ); if ( model.Ws_Status == "1" ) { int CompletedHadLessQuantity = model.Ws_CompletedHadLessQuantity; int CompletedQuantity = model.Ws_ProdQuantity; model.Ws_CompletedHadLessQuantity = CompletedQuantity; if ( CompletedQuantity > CompletedHadLessQuantity ) { modelpt.Prod_Quantity = modelpt.Prod_Quantity - (CompletedQuantity - CompletedHadLessQuantity); LYFZ.Model.Model_ErpProductOutStorage modelOutStorage = new Model.Model_ErpProductOutStorage(); modelOutStorage.Pos_OutQuantity = (CompletedQuantity - CompletedHadLessQuantity); modelOutStorage.Pos_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); modelOutStorage.Pos_ProductCategory = modelpt.Prod_Class; modelOutStorage.Pos_ProductNumber = modelpt.Prod_Number; modelOutStorage.Pos_Remark = "服务商品,服务完成自动出库"; modelOutStorage.Pos_OutTime = StrTime; modelOutStorage.Pos_OutName = StrUserID; clist.Add( posbll.GetAddCommandInfo( modelOutStorage ) ); } else { modelpt.Prod_Quantity = modelpt.Prod_Quantity + (CompletedHadLessQuantity - CompletedQuantity); LYFZ.Model.Model_ErpProductIntStorage modelIntStorage = new Model.Model_ErpProductIntStorage(); modelIntStorage.Pis_PurchaseQuantity = (CompletedHadLessQuantity - CompletedQuantity); modelIntStorage.Pis_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); modelIntStorage.Pis_ProductCategory = modelpt.Prod_Class; modelIntStorage.Pis_ProductNumber = modelpt.Prod_Number; modelIntStorage.Pis_PurchasePrice = modelpt.Prod_CostPrice; modelIntStorage.Pis_PurchaseVendor = ""; modelIntStorage.Pis_Remark = "服务商品,由已完成数量" + CompletedHadLessQuantity + "修改为" + CompletedQuantity; modelIntStorage.Pis_CreateName = StrUserID; modelIntStorage.Pis_CreateDatetime = StrTime; clist.Add( pisbll.GetAddCommandInfo( modelIntStorage ) ); } } else { LYFZ.Model.Model_ErpProductIntStorage modelIntStorage = new Model.Model_ErpProductIntStorage(); modelpt.Prod_Quantity = modelpt.Prod_Quantity + model.Ws_CompletedHadLessQuantity; modelIntStorage.Pis_PurchaseQuantity = model.Ws_CompletedHadLessQuantity; model.Ws_CompletedHadLessQuantity = 0; modelIntStorage.Pis_DividedShop = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID(); modelIntStorage.Pis_ProductCategory = modelpt.Prod_Class; modelIntStorage.Pis_ProductNumber = modelpt.Prod_Number; modelIntStorage.Pis_PurchasePrice = modelpt.Prod_CostPrice; modelIntStorage.Pis_PurchaseVendor = ""; modelIntStorage.Pis_Remark = "服务商品,由已完成修改为未完成自动入库之前已出库的数量"; modelIntStorage.Pis_CreateName = StrUserID; modelIntStorage.Pis_CreateDatetime = StrTime; clist.Add( pisbll.GetAddCommandInfo( modelIntStorage ) ); } modelpt.Prod_UpdateDateTime = StrTime; modelpt.Prod_UpdateName = StrUserID; clist.Add( pdtbll.GetUpdateCommandInfo( modelpt ) ); } return clist; } /// /// 列表事件双击 /// /// /// void lstTextQuery_MouseDoubleClick( object sender, MouseEventArgs e ) { if ( this.lstTextQuery.Items.Count > 0 ) { if ( ((ListItem)this.lstTextQuery.SelectedItem) != null ) { this.OrdNumber = ((ListItem)this.lstTextQuery.SelectedItem).StrValue.ToString().Trim(); this.GetOrdNumberGetData(); this.txtTextQuery.Text = ((ListItem)this.lstTextQuery.SelectedItem).StrText; } } this.lstTextQuery.Visible = false; } /// /// 回车键 /// /// /// void lstTextQuery_KeyDown( object sender, KeyEventArgs e ) { if ( e.KeyCode == Keys.Enter ) { this.lstTextQuery_MouseDoubleClick( this, null ); } } /// /// 输入值变化 /// /// /// void txtTextQuery_EventTextBoxEx_TextChanged( object sender, EventArgs e ) { if ( !this.IsFirstRun ) { if ( this.txtTextQuery.Text.Trim() == "" ) { this.lstTextQuery.Visible = true; } } } /// /// 点击输入框 /// /// /// void txtTextQuery_Enter( object sender, EventArgs e ) { this.txtTextQuery_EventTextBoxEx_TextChanged( null, null ); } /// /// 查询 /// /// /// void btnQuery_Click( object sender, EventArgs e ) { LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.InputQueryClient( this.txtTextQuery, this.lstTextQuery, cameraType: Model.CameraType.服务客人); } /// /// 按键盘上的下健时 /// /// /// void txtTextQuery_KeyDown( object sender, KeyEventArgs e ) { if ( e.KeyCode == Keys.Down || e.KeyCode == Keys.Up ) { if (this.lstTextQuery.Items.Count > 0) { if (this.lstTextQuery.SelectedItem != null) { this.lstTextQuery.SelectedIndex = 0; this.lstTextQuery.Focus(); } } } else if ( e.KeyCode == Keys.Enter ) { LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.InputQueryClient( this.txtTextQuery, this.lstTextQuery, cameraType: Model.CameraType.服务客人); } } /// /// 文本框失去焦点事件 /// /// /// void txtTextQuery_Leave( object sender, EventArgs e ) { if ( !this.lstTextQuery.Focused ) { this.lstTextQuery.Visible = false; } } /// /// 列表列双击事件 /// /// /// void dgvData_CellDoubleClick( object sender, DataGridViewCellEventArgs e ) { if ( e.ColumnIndex >= 0 && e.RowIndex >= 0 ) { this.cmbdgv.Visible = false; this.mskdgv.Visible = false; this.dtpcdgv.Visible = false; this.cmbtreevdgv.Visible = false; this.txtdgv.Visible = false; this.lstTextQuery.Visible = false; this.txtIntCount.Visible = false; if ( this.dgvData.CurrentRow.Cells["服务状态"].Value.ToString().Trim() != "OK" ) { if ( String.IsNullOrEmpty( this.dgvData.Rows[e.RowIndex].Cells["ID"].Value.ToString() ) ) { if ( this.dgvData.Columns[e.ColumnIndex].Name == "数量" ) { DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex]; Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true ); this.txtIntCount.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y - 1 ); this.txtIntCount.Size = rect.Size; this.txtIntCount.Visible = true; this.txtIntCount.Text = (String)cell.Value; this.txtIntCount.Focus(); } else { return; } } DataTable dt = orbll.GetView_Custom( "tb_ErpWeddingService", StrWhere: "ID = '" + this.dgvData.Rows[e.RowIndex].Cells["ID"].Value + "'", ShowColumnName: "Ws_ReservationServiceDividedShop,Ws_WeddingDate,Ws_Serviceman1,Ws_Serviceman2,Ws_Remark" ).Tables[0]; if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务门店" ) { if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_ReservationServiceDividedShop"].ToString() ) ) && !IsUpdateAnPai ) { return; } DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex]; Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true ); this.cmbtreevStoreName.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y ); this.cmbtreevStoreName.Size = rect.Size; this.cmbtreevStoreName.Visible = true; this.mskdgv.Visible = false; this.cmbtreevdgv.Visible = false; this.txtdgv.Visible = false; this.dtpcdgv.Visible = false; this.cmbtreevStoreName.TextFindTag( cell.Value.ToString().Trim() ); this.cmbtreevStoreName.StrKey = "F"; this.cmbtreevStoreName.Focus(); } else if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务日期" )//选择日期 { if ( !IsUpdateAnPai && dt.Rows.Count > 0 ) { if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_WeddingDate"].ToString() ) ) ) { return; } } DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex]; Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true ); this.dtpcdgv.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y ); this.dtpcdgv.Size = rect.Size; this.dtpcdgv.Visible = true; this.dtpcdgv.DateValue = cell.Value.ToString().Trim(); this.dtpcdgv.Focus(); } else if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务时间" )//选择时间 { if ( this.dgvData.CurrentRow.Cells["服务日期"].Value.ToString().Trim() != "" ) { if ( !IsUpdateAnPai && dt.Rows.Count > 0 ) { if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_WeddingDate"].ToString() ) ) && LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_WeddingDate"].ToString(), "HH:mm" ) != "00:00" ) { return; } } if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsWithinSchedule|| !LYFZSS.SystemSpecterPossessed.IsNewCameraControlBook()) { DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex]; Rectangle rect = this.dgvData.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, true); this.mskdgv.Location = new Point(rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y); this.mskdgv.Size = rect.Size; this.mskdgv.Visible = true; this.mskdgv.Text = cell.Value.ToString().Trim(); this.mskdgv.Tag = "S"; this.mskdgv.Focus(); } else { //选择时间 DateTime dayDate = SDateTime.Now; string shopID = ""; List dateTimes = GetDateTime(); List selectShopIDs = GetSelectShopID(); if (dateTimes.Count > 0) { dayDate = dateTimes[0]; } if (selectShopIDs.Count > 0) { shopID = selectShopIDs[0]; } if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition) { if (selectShopIDs.Count <= 0) { MessageBoxCustom.Show("需要先选择要预约的门店"); return; } } if (dateTimes.Count <= 0) { MessageBoxCustom.Show("需要先选择服务日期"); return; } Model.CameraTimeTemplate cameraTime = PhotographedReservationSmallForm.GetCameraTime(dayDate, shopID, Model.CameraType.服务客人, this.GetCameraOrderType()); if (cameraTime != null) { DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex]; cell.Value = cameraTime.CameraTime; if (TimeTemplateKeyValues.ContainsKey(e.RowIndex)) { this.TimeTemplateKeyValues.Remove(e.RowIndex); } this.TimeTemplateKeyValues.Add(e.RowIndex, cameraTime); this.dgvData.Rows[e.RowIndex].Tag = "1"; } } } else { MessageBoxCustom.Show( "请先填服务日期" ); return; } } else if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务状态" )//选择状态 { if ( this.dgvData.CurrentRow.Cells["服务日期"].Value.ToString().Trim() != "" ) { if ( this.dgvData.CurrentRow.Cells["服务人员1"].Value.ToString().Trim() != "" || this.dgvData.CurrentRow.Cells["服务人员2"].Value.ToString().Trim() != "" ) { DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex]; Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true ); this.cmbdgv.Items.Clear(); for ( int i = 0; i < StrStatus.Length; i++ ) { this.cmbdgv.Items.Add( StrStatus[i].Trim() ); } this.cmbdgv.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y ); this.cmbdgv.Size = rect.Size; this.cmbdgv.Visible = true; this.cmbdgv.Text = cell.Value.ToString().Trim(); this.cmbdgv.Tag = "Z"; this.cmbdgv.Focus(); } else { MessageBoxCustom.Show( "服务人员必填一位" ); return; } } else { MessageBoxCustom.Show( "请先填服务日期" ); return; } } else if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务备注" )//选择状态 { if ( !IsUpdateAnPai && dt.Rows.Count > 0 ) { if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_Remark"].ToString() ) ) ) { return; } } DataGridViewCell cell = this.dgvData.CurrentRow.Cells[e.ColumnIndex]; Rectangle rect = this.dgvData.GetCellDisplayRectangle( cell.ColumnIndex, cell.RowIndex, true ); this.txtdgv.Location = new Point( rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y - 1 ); this.txtdgv.Size = rect.Size; this.txtdgv.Visible = true; this.txtdgv.Text = (String)cell.Value; this.txtdgv.Focus(); this.txtdgv.Focus(); } else if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务人员1" || this.dgvData.Columns[e.ColumnIndex].Name == "服务人员2" ) { LYFZ.EnumPublic.EnumWorkPersonType WorkPersonType = EnumPublic.EnumWorkPersonType.服务师1; if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务人员1" ) { if ( !IsUpdateAnPai && dt.Rows.Count > 0 ) { if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_Serviceman1"].ToString() ) ) ) { return; } } WorkPersonType = EnumPublic.EnumWorkPersonType.服务师1; } if ( this.dgvData.Columns[e.ColumnIndex].Name == "服务人员2" ) { if ( !IsUpdateAnPai && dt.Rows.Count > 0 ) { if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_Serviceman2"].ToString() ) ) ) { return; } } WorkPersonType = EnumPublic.EnumWorkPersonType.服务师2; } LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.SelectWorkPersonSuperSmallForm frm = new SuperSmallForm.SelectWorkPersonSuperSmallForm(); frm.StrTime = this.dgvData.CurrentRow.Cells["服务日期"].Value.ToString().Trim(); frm.WorkPersonType = WorkPersonType; frm.ShowDialog(); if ( frm.IsSaveed ) { this.dgvData.CurrentRow.Cells[e.ColumnIndex].Value = frm.StrPersonName; this.dgvData.CurrentRow.Cells[e.ColumnIndex].Tag = frm.StrPersonNumber; this.dgvData.CurrentRow.Tag = "1"; } } } else { MessageBoxCustom.Show( "此服务已结束不能再修改!" ); return; } } } /// /// 服务人员失去焦点 /// /// /// void cmbtreevdgv_Leave( object sender, EventArgs e ) { if ( this.cmbtreevdgv.StrKey != null ) { if ( this.cmbtreevdgv.StrKey.ToString().Trim() == "R1" ) { this.dgvData.CurrentRow.Cells["服务人员1"].Value = this.cmbtreevdgv.Text.Trim(); if ( this.cmbtreevdgv.Text != "" ) { this.dgvData.CurrentRow.Cells["服务人员1"].Tag = this.cmbtreevdgv.Tag.ToString().Trim(); } else { this.dgvData.CurrentRow.Cells["服务人员1"].Tag = null; } } if ( this.cmbtreevdgv.StrKey.ToString().Trim() == "R2" ) { this.dgvData.CurrentRow.Cells["服务人员2"].Value = this.cmbtreevdgv.Text.Trim(); if ( this.cmbtreevdgv.Text != "" ) { this.dgvData.CurrentRow.Cells["服务人员2"].Tag = this.cmbtreevdgv.Tag.ToString().Trim(); } else { this.dgvData.CurrentRow.Cells["服务人员2"].Tag = null; } } this.dgvData.CurrentRow.Tag = "1"; this.cmbtreevdgv.Visible = false; } } /// /// 选择门店 /// /// /// void cmbtreevStoreName_Leave( object sender, EventArgs e ) { if ( this.cmbtreevStoreName.StrKey != null ) { if ( this.cmbtreevStoreName.StrKey.ToString().Trim() == "F" ) { if ( this.cmbtreevStoreName.Text.Trim() != "" ) { this.dgvData.CurrentRow.Cells["服务门店"].Value = this.cmbtreevStoreName.Text.Trim(); this.dgvData.CurrentRow.Cells["服务门店"].Tag = this.cmbtreevStoreName.Tag; } else { this.dgvData.CurrentRow.Cells["服务门店"].Value = ""; this.dgvData.CurrentRow.Cells["服务门店"].Tag = null; } this.dgvData.CurrentRow.Tag = "1"; } this.cmbtreevStoreName.Visible = false; } } /// /// 下拉选择失去焦点 /// /// /// void cmbdgv_Leave( object sender, EventArgs e ) { if ( this.cmbdgv.Tag != null ) { if ( this.cmbdgv.Tag.ToString().Trim() == "Z" ) { this.dgvData.CurrentRow.Cells["服务状态"].Value = this.cmbdgv.Text.Trim(); } this.dgvData.CurrentRow.Cells["服务状态"].Tag = "1"; this.dgvData.CurrentRow.Tag = "1"; this.cmbdgv.Visible = false; } } /// /// 下拉选择失去焦点 /// /// /// void mskdgv_Leave( object sender, EventArgs e ) { if ( this.mskdgv.Tag != null ) { if ( this.mskdgv.Tag.ToString().Trim() == "S" ) { if ( this.mskdgv.Text.Trim() != ":" ) { try { DateTime strts = Convert.ToDateTime( SDateTime.Now.ToString( "yyyy-MM-dd" ) + " " + this.mskdgv.Text.Trim() ); this.dgvData.CurrentRow.Cells["服务时间"].Value = this.mskdgv.Text.Trim(); } catch { MessageBoxCustom.Show( "不是有效的时间格式" ); this.mskdgv.Text = ""; this.mskdgv.Focus(); return; } } else { this.dgvData.CurrentRow.Cells["服务时间"].Value = ""; } this.dgvData.CurrentRow.Cells["服务时间"].Tag = "1"; this.dgvData.CurrentRow.Tag = "1"; } this.mskdgv.Visible = false; } } /// /// 备注离开事件 /// /// /// void txtdgv_Leave( object sender, EventArgs e ) { this.dgvData.CurrentRow.Cells["服务备注"].Value = this.txtdgv.Text.Trim(); this.dgvData.CurrentRow.Tag = "1"; this.txtdgv.Visible = false; } /// /// 数量离开事件 /// /// /// void txtIntCount_Leave( object sender, EventArgs e ) { this.dgvData.CurrentRow.Cells["数量"].Value = this.txtIntCount.Text.Trim(); this.dgvData.CurrentRow.Tag = "1"; this.txtIntCount.Visible = false; } /// /// 日期控件失去焦点 /// /// /// void dtpcdgv_Leave( object sender, EventArgs e ) { if ( this.dgvData.CurrentCell.ColumnIndex == this.dgvData.Columns["服务日期"].Index ) { if ( this.dgvData.CurrentRow.Cells["服务日期"].Value.ToString().Trim() != this.dtpcdgv.DateValue.Trim() && !string.IsNullOrEmpty( this.dtpcdgv.DateValue.Trim() ) ) { this.dgvData.CurrentRow.Cells["服务日期"].Tag = "1"; } if ( !string.IsNullOrEmpty( this.dtpcdgv.DateValue.Trim() ) ) { if ( !string.IsNullOrEmpty( this.dgvData.CurrentRow.Cells["服务人员1"].Value.ToString().Trim() ) ) { if ( this.dgvData.CurrentRow.Cells["服务人员1"].Tag != null ) { if ( LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetRestPerson( this.dtpcdgv.DateValue.Trim(), this.dgvData.CurrentRow.Cells["服务人员1"].Tag.ToString().Trim() ) ) { MessageBoxCustom.Show( this.dgvData.CurrentRow.Cells["服务人员1"].Value.ToString().Trim() + " '" + this.dtpcdgv.DateValue.Trim() + "'休息,不能安排工作!" ); this.dtpcdgv.DateValue = ""; this.dtpcdgv.Focus(); return; } } } if ( !string.IsNullOrEmpty( this.dgvData.CurrentRow.Cells["服务人员2"].Value.ToString().Trim() ) ) { if ( this.dgvData.CurrentRow.Cells["服务人员2"].Tag != null ) { if ( LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetRestPerson( this.dtpcdgv.DateValue.Trim(), this.dgvData.CurrentRow.Cells["服务人员2"].Tag.ToString().Trim() ) ) { MessageBoxCustom.Show( this.dgvData.CurrentRow.Cells["服务人员2"].Value.ToString().Trim() + " '" + this.dtpcdgv.DateValue.Trim() + "'休息,不能安排工作!" ); this.dtpcdgv.DateValue = ""; this.dtpcdgv.Focus(); return; } } } this.dgvData.CurrentRow.Cells["服务日期"].Value = this.dtpcdgv.DateValue.Trim(); } else { this.dgvData.CurrentRow.Cells["服务日期"].Value = ""; this.dgvData.CurrentRow.Cells["服务时间"].Value = ""; } this.dgvData.CurrentRow.Tag = "1"; } this.dtpcdgv.Text = ""; this.dtpcdgv.Visible = false; } /// /// 绑定 /// /// void GetOrdNumberGetData() { string strWhere = ""; string strWhere2 = ""; if ( !string.IsNullOrEmpty( this.OrdNumber ) ) { strWhere = " Ord_Number = '" + this.OrdNumber + "'"; strWhere2 = " and Ws_Number = '" + this.OrdNumber + "'"; } else { strWhere = " tb_ErpOrder.ID = '0' "; strWhere2 = " and tb_ErpWeddingService.ID = '0'"; } string strViewName = "tb_ErpOrder Left Join dbo.tb_ErpOrderDigital ON Ord_Number = Ordv_Number " + "left join dbo.tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber"; string strColumnName = "Ord_DividedShop," + "M_Cus_CustomerNumber," + "Cus_Name," + "Cus_Sex_cs," + "Ord_SeriesPrice," + "Ordv_IntoRegisterQuantity," + "Ordv_IntoBottomQuantity," + "CASE [Ord_SinceOrderNumber] WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS ShowOrdNumber," + "Ord_SeriesName,Ord_Type," + "(select stuff((select ',' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('')),1,1,'')) as OrdPe_OrdersPerson," + "Ordv_ViceNumber," + "Case when Ord_Type = '1' then (select top 1 Ordpg_Sights from dbo.tb_ErpOrdersPhotography where Ordpg_Number = Ordv_Number and Ordpg_ViceNumber = Ordv_ViceNumber) else '' end AS Ordpg_Sights"; string strColumnName2 = "tb_ErpWeddingService.ID," + "Ws_ProdNumber," + "Ws_Type," + "Ws_ProdCostPrice," + "Ws_ProdSoldPrice," + "Ws_ProdName AS 服务内容," + "Ws_ProdQuantity AS 数量," + "Company_Name AS 服务门店," + "Company_DividedShop AS 门店编号," + "dbo.fn_CheckWeddingServiceStatus(Ws_Status) AS 服务状态," + "dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ws_WeddingDate)) AS 服务日期," + "dbo.fn_CheckDateTimeReturn_Time(dbo.fn_CheckDateTime(Ws_WeddingDate)) AS 服务时间," + "Ws_Serviceman1 AS 服务人员1," + "Ws_Serviceman2 AS 服务人员2," + "Ws_Remark AS 服务备注"; string ExecuteSql = orbll.GetView_CustomReturnExecuteSql( strViewName, StrWhere: strWhere, ShowColumnName: strColumnName ); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql( "tb_ErpWeddingService Left Join tb_ErpCompanyInfo on Company_DividedShop = Ws_ReservationServiceDividedShop", StrWhere: " (Ws_Type = '1' or Ws_Type = '2') " + strWhere2, ShowColumnName: strColumnName2 ); DataSet dtSet = orbll.GetView_Custom( ExecuteSql ); DataTable tblOrder = dtSet.Tables["ds"]; DataTable tblWedding = dtSet.Tables["ds1"]; if ( this.dgvData.Columns.Count <= 0 ) { for ( int i = 0; i < tblWedding.Columns.Count; i++ ) { if ( tblWedding.Columns[i].ColumnName.Trim() != "门店编号" ) { DataGridViewColumn dc = new DataGridViewColumn(); dc.HeaderText = tblWedding.Columns[i].ColumnName.Trim(); dc.Name = tblWedding.Columns[i].ColumnName.Trim(); switch ( dc.Name.Trim() ) { case "ID": case "Ws_ProdNumber": case "Ws_Type": case "Ws_ProdCostPrice": case "Ws_ProdSoldPrice": dc.Visible = false; break; case "服务备注": dc.Width = 240; break; case "数量": dc.Width = 80; break; default: break; } dc.ReadOnly = true; this.dgvData.Columns.Add( dc ); } } } this.dgvData.Rows.Clear(); if ( tblOrder.Rows.Count > 0 ) { if ( tblOrder.Rows[0]["Ord_DividedShop"].ToString().Trim() != LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID() ) { if ( MessageBoxCustom.Show( "'" + tblOrder.Rows[0]["ShowOrdNumber"].ToString().Trim() + "'订单不属于本店所开,是否要继续安排?", "温馨提示", MessageBoxButtons.YesNo ) == DialogResult.No ) { return; } } if (!LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.IsWithinSchedule) { if (this.currentSelectCameraTime != null) { if (tblOrder.Rows[0]["Ord_Type"].ToString().Trim() != this.currentSelectCameraTime.DayTemplate.OrderType.ToString()) { MessageBoxCustom.Show(this.currentSelectCameraTime.GetPromptInfo()); return; } } } this.tx_serial_price.Text = tblOrder.Rows[0]["Ord_SeriesPrice"].ToString().Trim(); this.tx_rdrc.Text = string.Format( "{0}\\{1}", tblOrder.Rows[0]["Ordv_IntoBottomQuantity"].ToString().Trim(), tblOrder.Rows[0]["Ordv_IntoRegisterQuantity"].ToString().Trim() ); this.txtOrderNumber.Text = tblOrder.Rows[0]["ShowOrdNumber"].ToString().Trim(); this.txtSeriesName.Text = tblOrder.Rows[0]["Ord_SeriesName"].ToString().Trim(); this.txtOrdersPerson.Text = tblOrder.Rows[0]["OrdPe_OrdersPerson"].ToString().Trim(); DataTable tblClientWedding = orbll.GetView_Custom( "tb_ErpCustomer", StrWhere: "Cus_CustomerNumber = '" + tblOrder.Rows[0]["M_Cus_CustomerNumber"].ToString().Trim() + "'", ShowColumnName: "Cus_DayForMarriage,Cus_DayForMarriageLunar" ).Tables[0]; if ( tblClientWedding.Rows.Count > 0 ) { this.txtWedding.Text = LYFZ.Command.Command_Validate.DateTimeToString( tblClientWedding.Rows[0]["Cus_DayForMarriage"] ); this.chkWedding.Checked = false; if ( LYFZ.Command.Command_Validate.DateTimeToString( tblClientWedding.Rows[0]["Cus_DayForMarriage"] ) != "" ) { if ( tblClientWedding.Rows[0]["Cus_DayForMarriageLunar"].ToString().Trim() == "1" ) { this.chkWedding.Checked = true; } } } this.StrOrdType = tblOrder.Rows[0]["Ord_Type"].ToString().Trim(); this.SetClientData( tblOrder.Rows[0]["Cus_Name"].ToString().Trim(), tblOrder.Rows[0]["Cus_Sex_cs"].ToString().Trim(), tblOrder.Rows[0]["Ord_Type"].ToString().Trim() ); //DataGridViewCell cellShopID = null; // DataGridViewCell cellDate = null; // DataGridViewCell cellTime = null; for ( int i = 0; i < tblWedding.Rows.Count; i++ ) { DataGridViewRow dgvl = new DataGridViewRow(); DataGridViewCell cell = null; for ( int j = 0; j < tblWedding.Columns.Count; j++ ) { if ( tblWedding.Columns[j].ColumnName.Trim() != "门店编号" ) { cell = new DataGridViewTextBoxCell(); switch ( tblWedding.Columns[j].ColumnName.Trim() ) { case "服务门店": // cellShopID = cell; cell.Value = tblWedding.Rows[i][tblWedding.Columns[j].ColumnName].ToString().Trim(); cell.Tag = tblWedding.Rows[i]["门店编号"].ToString().Trim(); break; case "服务人员1": case "服务人员2": cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName( tblWedding.Rows[i][tblWedding.Columns[j].ColumnName] ); cell.Tag = tblWedding.Rows[i][tblWedding.Columns[j].ColumnName].ToString().Trim(); break; default: cell.Value = tblWedding.Rows[i][tblWedding.Columns[j].ColumnName].ToString().Trim(); break; } dgvl.Cells.Add( cell ); } } this.dgvData.Rows.Add( dgvl ); } } } /// /// 设计加载的项 /// /// /// /// void SetClientData( string StrName, string StrSex, string StrOrderType ) { string[] StrNameArray = StrName.Trim().Split( '/' ); string[] StrSexArray = StrSex.Trim().Split( '/' ); this.btnUpdate.Visible = false; this.panelWedding.Visible = false; if ( StrOrderType.Trim() == "0" || StrOrderType.Trim() == "4" ) { if ( StrNameArray.Length > 1 ) { if ( StrSexArray[0].Trim() == "男" ) { lblName1.Text = "男宾姓名:"; } else if ( StrSexArray[0].Trim() == "女" ) { lblName1.Text = "女宾姓名:"; } txtName1.Text = StrNameArray[0].Trim(); if ( StrSexArray[1].Trim() == "男" ) { lblName2.Text = "男宾姓名:"; } else if ( StrSexArray[1].Trim() == "女" ) { lblName2.Text = "女宾姓名:"; } txtName2.Text = StrNameArray[1].Trim(); } else { lblName1.Text = "男宾姓名:"; lblName2.Text = "女宾姓名:"; if ( StrSexArray[0].Trim() == "男" ) { txtName1.Text = StrNameArray[0].Trim(); } else if ( StrSexArray[0].Trim() == "女" ) { txtName2.Text = StrNameArray[0].Trim(); } } this.panelWedding.Visible = true; } else if ( StrOrderType.Trim() == "1" ) { lblName1.Text = "宝贝姓名:"; lblName2.Text = "家长姓名:"; txtName1.Text = StrNameArray[0].Trim(); if (StrNameArray.Length > 1) { txtName2.Text = StrNameArray[1].Trim(); } else { txtName2.Text = StrNameArray[0].Trim(); } } else if ( StrOrderType.Trim() == "2" ) { lblName1.Text = "客户姓名:"; lblName2.Text = "客户性别:"; txtName1.Text = StrNameArray[0].Trim(); txtName2.Text = StrSexArray[0].Trim(); } else if ( StrOrderType.Trim() == "3" ) { lblName1.Text = "客户姓名:"; lblName2.Text = "客户性别:"; txtName1.Text = StrNameArray[0].Trim(); txtName2.Text = StrSexArray[0].Trim(); this.btnUpdate.Visible = true; this.panelWedding.Visible = true; } //lblName1.Location = new Point(15, lblName1.Location.Y); //lblName2.Location = new Point(311, lblName1.Location.Y); } /// /// 设计加载的项 /// void SetClientData() { string StrOrderType = LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.GetVersion(); this.panelWedding.Visible = false; if ( StrOrderType.Trim() == "-1" ) { lblName1.Text = "男/家姓名:"; lblName2.Text = "女/宝姓名:"; //lblName1.Location = new Point(10, lblName1.Location.Y); //lblName2.Location = new Point(lblName1.Location.X, lblName2.Location.Y); } else if ( StrOrderType.Trim() == "2" ) { lblName1.Text = "客户姓名:"; lblName2.Text = "客户性别:"; } else if ( StrOrderType.Trim() == "0" ) { lblName1.Text = "男宾姓名:"; lblName2.Text = "女宾姓名:"; this.panelWedding.Visible = true; } else if ( StrOrderType.Trim() == "1" ) { lblName1.Text = "家长姓名:"; lblName2.Text = "宝贝姓名:"; } //lblName1.Location = new Point(15, lblName1.Location.Y); //lblName2.Location = new Point(lblName1.Location.X, lblName2.Location.Y); } /// /// 列表列点击事件(右键) /// /// /// void dgvData_CellMouseDown( object sender, DataGridViewCellMouseEventArgs e ) { if ( e.Button == MouseButtons.Right ) { if ( e.ColumnIndex != -1 && e.RowIndex != -1 ) { ToolStripMenuItem item = null; #region 日期 if ( e.ColumnIndex == this.dgvData.Columns["服务日期"].Index ) { //弹出操作菜单 item = new ToolStripMenuItem(); item.Text = "清空值"; item.Tag = "StrDate"; this.dgvData.conMenu.Items.Add( item ); item = new ToolStripMenuItem(); item.Text = "日期"; item.Tag = "StrDate"; this.dgvData.conMenu.Items.Add( item ); } if ( e.ColumnIndex == this.dgvData.Columns["服务时间"].Index ) { //弹出操作菜单 item = new ToolStripMenuItem(); item.Text = "清空值"; item.Tag = "StrTime"; this.dgvData.conMenu.Items.Add( item ); item = new ToolStripMenuItem(); item.Text = "时间"; item.Tag = "StrTime"; this.dgvData.conMenu.Items.Add( item ); } if ( e.ColumnIndex == this.dgvData.Columns["服务状态"].Index ) { //弹出操作菜单 item = new ToolStripMenuItem(); item.Text = "清空值"; item.Tag = "StrStatus"; this.dgvData.conMenu.Items.Add( item ); item = new ToolStripMenuItem(); item.Text = "未开始"; item.Tag = "StrStatus"; this.dgvData.conMenu.Items.Add( item ); item = new ToolStripMenuItem(); item.Text = "OK"; item.Tag = "StrStatus"; this.dgvData.conMenu.Items.Add( item ); } if ( e.ColumnIndex == this.dgvData.Columns["服务人员1"].Index ) { //弹出操作菜单 item = new ToolStripMenuItem(); item.Text = "清空值"; item.Tag = "STrCmbTreeV1"; this.dgvData.conMenu.Items.Add( item ); item = new ToolStripMenuItem(); item.Text = "选择人员"; item.Tag = "STrCmbTreeV1"; this.dgvData.conMenu.Items.Add( item ); } if ( e.ColumnIndex == this.dgvData.Columns["服务人员2"].Index ) { //弹出操作菜单 item = new ToolStripMenuItem(); item.Text = "清空值"; item.Tag = "STrCmbTreeV2"; this.dgvData.conMenu.Items.Add( item ); item = new ToolStripMenuItem(); item.Text = "选择人员"; item.Tag = "STrCmbTreeV2"; this.dgvData.conMenu.Items.Add( item ); } if ( e.ColumnIndex == this.dgvData.Columns["服务备注"].Index ) { //弹出操作菜单 item = new ToolStripMenuItem(); item.Text = "清空值"; item.Tag = "StrText"; this.dgvData.conMenu.Items.Add( item ); item = new ToolStripMenuItem(); item.Text = "填写备注"; item.Tag = "StrText"; this.dgvData.conMenu.Items.Add( item ); } #endregion } } } /// /// 获取预约门店ID /// /// List GetSelectShopID() { List shopIDlist = new List(); foreach (DataGridViewRow dataGridView in this.dgvData.SelectedRows) { if (dataGridView.Cells["服务门店"].Tag != null) { string shopID = dataGridView.Cells["服务门店"].Tag.ToString(); if (!shopIDlist.Any(s => s.ToLower() == shopID.ToLower())) { shopIDlist.Add(shopID); } } } if (shopIDlist.Count > 1) { MessageBoxCustom.Show("不能同时预约不同门店的摄控时间"); } return shopIDlist; } /// /// 获取预约日期 /// /// List GetDateTime() { List dateTimelist = new List(); foreach (DataGridViewRow dataGridView in this.dgvData.SelectedRows) { if (dataGridView.Cells["服务日期"].Value != null) { string dateTimeString = dataGridView.Cells["服务日期"].Value.ToString(); if (!String.IsNullOrWhiteSpace(dateTimeString)) { if (!dateTimelist.Any(d => d.ToYYYY_MM_dd().ToLower() == dateTimeString.ToLower())) { dateTimelist.Add(Convert.ToDateTime(dateTimeString)); } } } } if (dateTimelist.Count > 1) { MessageBoxCustom.Show("不能同时预约不同日期的摄控时间"); } return dateTimelist; } /// /// 右键菜单选择项事件 /// /// /// void dgvData_DataGridViewConMenu_ItemClicked( object sender, ToolStripItemClickedEventArgs e ) { ToolStripItem item = e.ClickedItem; #region string strID = ""; for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { strID += "'" + this.dgvData.SelectedRows[i].Cells["ID"].Value.ToString().Trim() + "',"; } DataTable dt = orbll.GetView_Custom( "tb_ErpWeddingService", StrWhere: "ID in (" + strID.TrimEnd( ',' ) + ")", ShowColumnName: "ID,Ws_WeddingDate,Ws_Serviceman1,Ws_Serviceman2,Ws_Remark" ).Tables[0]; dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] }; if ( item.Tag.ToString().Trim() == "StrDate" ) { if ( item.Text.Trim() == "日期" ) { LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetDateSuperSmallForm frm = new SuperSmallForm.GetDateSuperSmallForm(); frm.ShowDialog(); if ( frm.IsOK ) { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_WeddingDate"].ToString() ) ) && !IsUpdateAnPai ) { return; } if ( this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != frm.StrValue.Trim() && !string.IsNullOrEmpty( frm.StrValue.Trim() ) ) { this.dgvData.SelectedRows[i].Cells["服务日期"].Tag = "1"; } this.dgvData.SelectedRows[i].Cells["服务日期"].Value = frm.StrValue; this.dgvData.SelectedRows[i].Tag = "1"; } else { if ( this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != frm.StrValue.Trim() && !string.IsNullOrEmpty( frm.StrValue.Trim() ) ) { this.dgvData.SelectedRows[i].Cells["服务日期"].Tag = "1"; } this.dgvData.SelectedRows[i].Cells["服务日期"].Value = frm.StrValue; this.dgvData.SelectedRows[i].Tag = "1"; } } } } } else { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_WeddingDate"].ToString() ) ) && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务日期"].Value = ""; this.dgvData.SelectedRows[i].Tag = "1"; } else { this.dgvData.SelectedRows[i].Cells["服务日期"].Value = ""; this.dgvData.SelectedRows[i].Tag = "1"; } } } } } else if ( item.Tag.ToString().Trim() == "StrTime" ) { if ( item.Text.Trim() == "时间" ) { /* LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetTimeSuperSmallForm frm = new SuperSmallForm.GetTimeSuperSmallForm(); frm.ShowDialog(); if ( frm.IsOK ) { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_WeddingDate"].ToString() ) ) && LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_WeddingDate"].ToString(), "HH:mm" ) != "00:00" && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务时间"].Value = frm.StrValue; this.dgvData.SelectedRows[i].Tag = "1"; } else { this.dgvData.SelectedRows[i].Cells["服务时间"].Value = frm.StrValue; this.dgvData.SelectedRows[i].Tag = "1"; } } } }*/ DateTime dayDate = SDateTime.Now; string shopID = ""; List dateTimes = GetDateTime(); List selectShopIDs = GetSelectShopID(); if (dateTimes.Count > 0) { dayDate = dateTimes[0]; } if (selectShopIDs.Count > 0) { shopID = selectShopIDs[0]; } if (LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.IsGroupEdition) { if (selectShopIDs.Count <= 0) { MessageBoxCustom.Show("需要先选择要预约的门店"); return; } } if (dateTimes.Count <= 0) { MessageBoxCustom.Show("需要先选择服务日期"); return; } Model.CameraTimeTemplate cameraTime = PhotographedReservationSmallForm.GetCameraTime(dayDate, shopID, Model.CameraType.服务客人, this.GetCameraOrderType()); if (cameraTime != null) { for (int i = 0; i < this.dgvData.SelectedRows.Count; i++) { if (this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "") { if (dt.Rows.Count > 0) { DataRow dtRow = dt.Rows.Find(dt.Rows[0]["ID"]); if (!string.IsNullOrEmpty(LYFZ.Command.Command_Validate.DateTimeToString(dtRow["Ws_WeddingDate"].ToString())) && LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[0]["Ws_WeddingDate"].ToString(), "HH:mm") != "00:00" && !IsUpdateAnPai) { return; } this.dgvData.SelectedRows[i].Cells["服务时间"].Value = cameraTime.CameraTime; this.dgvData.SelectedRows[i].Tag = "1"; } else { this.dgvData.SelectedRows[i].Cells["服务时间"].Value = cameraTime.CameraTime; this.dgvData.SelectedRows[i].Tag = "1"; } if (TimeTemplateKeyValues.ContainsKey(this.dgvData.SelectedRows[i].Index)) { this.TimeTemplateKeyValues.Remove(this.dgvData.SelectedRows[i].Index); } this.TimeTemplateKeyValues.Add(this.dgvData.SelectedRows[i].Index, cameraTime); } } } } else { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_WeddingDate"].ToString() ) ) && LYFZ.Command.Command_Validate.DateTimeToString( dt.Rows[0]["Ws_WeddingDate"].ToString(), "HH:mm" ) != "00:00" && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务时间"].Value = ""; this.dgvData.SelectedRows[i].Tag = "1"; } else { this.dgvData.SelectedRows[i].Cells["服务时间"].Value = ""; this.dgvData.SelectedRows[i].Tag = "1"; } } } } } else if ( item.Tag.ToString().Trim() == "StrStatus" ) { if ( item.Text.Trim() != "清空值" ) { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "" && (this.dgvData.SelectedRows[i].Cells["服务人员1"].Value.ToString().Trim() != "" || this.dgvData.SelectedRows[i].Cells["服务人员2"].Value.ToString().Trim() != "") ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != item.Text.Trim() && !string.IsNullOrEmpty( item.Text.Trim() ) ) { this.dgvData.SelectedRows[i].Cells["服务状态"].Tag = "1"; } this.dgvData.SelectedRows[i].Cells["服务状态"].Value = item.Text.Trim(); this.dgvData.SelectedRows[i].Tag = "1"; } } } else { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" ) { this.dgvData.SelectedRows[i].Cells["服务状态"].Value = ""; this.dgvData.SelectedRows[i].Tag = "1"; } } } } else if ( item.Tag.ToString().Trim() == "StrText" ) { if ( item.Text.Trim() == "填写备注" ) { LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetTextRemarkSuperSmallForm frm = new SuperSmallForm.GetTextRemarkSuperSmallForm(); frm.ShowDialog(); if ( frm.IsSaveed ) { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_Remark"].ToString() ) ) && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务备注"].Value = frm.StrValue; this.dgvData.SelectedRows[i].Tag = "1"; } else { this.dgvData.SelectedRows[i].Cells["服务备注"].Value = frm.StrValue; this.dgvData.SelectedRows[i].Tag = "1"; } } } } else { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_Remark"].ToString() ) ) && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务备注"].Value = ""; this.dgvData.SelectedRows[i].Tag = "1"; } else { this.dgvData.SelectedRows[i].Cells["服务备注"].Value = ""; this.dgvData.SelectedRows[i].Tag = "1"; } } } } else if ( item.Tag.ToString().Trim() == "STrCmbTreeV1" || item.Tag.ToString().Trim() == "STrCmbTreeV2" ) { if ( item.Text.Trim() == "选择人员" ) { LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.SelectWorkPersonSuperSmallForm frm = new SuperSmallForm.SelectWorkPersonSuperSmallForm(); frm.StrTime = this.dgvData.CurrentRow.Cells["服务日期"].Value.ToString().Trim(); if ( item.Tag.ToString().Trim() == "STrCmbTreeV1" ) { frm.WorkPersonType = LYFZ.EnumPublic.EnumWorkPersonType.服务师1; } else { frm.WorkPersonType = LYFZ.EnumPublic.EnumWorkPersonType.服务师2; } frm.ShowDialog(); if ( frm.IsSaveed ) { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "" ) { if ( item.Tag.ToString().Trim() == "STrCmbTreeV1" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_Serviceman1"].ToString() ) ) && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务人员1"].Value = frm.StrPersonName; this.dgvData.SelectedRows[i].Cells["服务人员1"].Tag = frm.StrPersonNumber; } else { this.dgvData.SelectedRows[i].Cells["服务人员1"].Value = frm.StrPersonName; this.dgvData.SelectedRows[i].Cells["服务人员1"].Tag = frm.StrPersonNumber; } } else if ( item.Tag.ToString().Trim() == "STrCmbTreeV2" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_Serviceman2"].ToString() ) ) && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务人员2"].Value = frm.StrPersonName; this.dgvData.SelectedRows[i].Cells["服务人员2"].Tag = frm.StrPersonNumber; } else { this.dgvData.SelectedRows[i].Cells["服务人员2"].Value = frm.StrPersonName; this.dgvData.SelectedRows[i].Cells["服务人员2"].Tag = frm.StrPersonNumber; } } this.dgvData.SelectedRows[i].Tag = "1"; } } this.dgvData.CurrentRow.Tag = "1"; } } else { for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ ) { if ( this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "" ) { if ( item.Tag.ToString().Trim() == "STrCmbTreeV1" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_Serviceman1"].ToString() ) ) && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务人员1"].Value = ""; this.dgvData.SelectedRows[i].Cells["服务人员1"].Tag = null; this.dgvData.SelectedRows[i].Tag = "1"; } else { this.dgvData.SelectedRows[i].Cells["服务人员1"].Value = ""; this.dgvData.SelectedRows[i].Cells["服务人员1"].Tag = null; this.dgvData.SelectedRows[i].Tag = "1"; } } else if ( item.Tag.ToString().Trim() == "STrCmbTreeV2" ) { if ( dt.Rows.Count > 0 ) { DataRow dtRow = dt.Rows.Find( dt.Rows[0]["ID"] ); if ( !string.IsNullOrEmpty( LYFZ.Command.Command_Validate.DateTimeToString( dtRow["Ws_Serviceman2"].ToString() ) ) && !IsUpdateAnPai ) { return; } this.dgvData.SelectedRows[i].Cells["服务人员2"].Value = ""; this.dgvData.SelectedRows[i].Cells["服务人员2"].Tag = null; } else { this.dgvData.SelectedRows[i].Cells["服务人员2"].Value = ""; this.dgvData.SelectedRows[i].Cells["服务人员2"].Tag = null; } } this.dgvData.CurrentRow.Tag = "1"; } } } } //else if (item.Tag.ToString().Trim() == "STrCmbTreeV1") //{ // if (item.Text.Trim() == "选择人员") // { // LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetPeopleSuperSmallForm frm = new SuperSmallForm.GetPeopleSuperSmallForm(); // frm.ShowDialog(); // if (frm.IsOK) // { // for (int i = 0; i < this.dgvData.SelectedRows.Count; i++) // { // if (this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "") // { // string[] strValues = frm.StrValue.Split(','); // this.dgvData.SelectedRows[i].Cells["服务人员1"].Value = strValues[0]; // this.dgvData.SelectedRows[i].Cells["服务人员1"].Tag = strValues[1]; // this.dgvData.SelectedRows[i].Tag = "1"; // } // } // } // } // else // { // for (int i = 0; i < this.dgvData.SelectedRows.Count; i++) // { // if (this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "") // { // this.dgvData.SelectedRows[i].Cells["服务人员1"].Value = ""; // this.dgvData.SelectedRows[i].Cells["服务人员1"].Tag = null; // this.dgvData.SelectedRows[i].Tag = "1"; // } // } // } //} //else if (item.Tag.ToString().Trim() == "STrCmbTreeV2") //{ // if (item.Text.Trim() == "选择人员") // { // LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm.GetPeopleSuperSmallForm frm = new SuperSmallForm.GetPeopleSuperSmallForm(); // frm.ShowDialog(); // if (frm.IsOK) // { // for (int i = 0; i < this.dgvData.SelectedRows.Count; i++) // { // if (this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "") // { // string[] strValues = frm.StrValue.Split(','); // this.dgvData.SelectedRows[i].Cells["服务人员2"].Value = strValues[0]; // this.dgvData.SelectedRows[i].Cells["服务人员2"].Tag = strValues[1]; // this.dgvData.SelectedRows[i].Tag = "1"; // } // } // } // } // else // { // for (int i = 0; i < this.dgvData.SelectedRows.Count; i++) // { // if (this.dgvData.SelectedRows[i].Cells["服务状态"].Value.ToString().Trim() != "OK" && this.dgvData.SelectedRows[i].Cells["服务日期"].Value.ToString().Trim() != "") // { // this.dgvData.SelectedRows[i].Cells["服务人员2"].Value = ""; // this.dgvData.SelectedRows[i].Cells["服务人员2"].Tag = null; // this.dgvData.SelectedRows[i].Tag = "1"; // } // } // } //} #endregion } /// /// 限制数量输入规则 /// /// /// void txtIntCount_KeyPress( object sender, KeyPressEventArgs e ) { if ( !Char.IsNumber( e.KeyChar ) && !Char.IsControl( e.KeyChar ) ) { e.Handled = true; } } } }