using LYFZ.ComponentLibrary; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.FinancialManagement { public partial class FrmTwoSalesOrder : LYFZ.Software.UI.FinancialManagement.FrmTwoSalesOrder { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); LYFZ.BLL.BLL_ErpSystemLogs slogbll = new BLL.BLL_ErpSystemLogs(); LYFZ.BLL.BLL_ErpTwoSalesOrder torbll = new BLL.BLL_ErpTwoSalesOrder(); LYFZ.BLL.BLL_ErpCustomerGroup cgpbll = new BLL.BLL_ErpCustomerGroup(); LYFZ.BLL.BLL_ErpOrderProductList oplistbll = new BLL.BLL_ErpOrderProductList(); LYFZ.BLL.BLL_ErpCustomerGroupMembers cgmbll = new BLL.BLL_ErpCustomerGroupMembers(); public string guid = ""; public FrmTwoSalesOrder() { this.Shown += FrmTwoSalesOrder_Shown; this.txtkeyword.KeyDown += txtkeyword_KeyDown; this.btnSlect.Click += btnSlect_Click; this.dgvData.CellDoubleClick += dgvData_CellDoubleClick; this.dgvData.CellMouseClick += dgvData_CellMouseClick; this.btnConditionsSelect.Click += btnConditionsSelect_Click; this.btnEntry.Click += btnEntry_Click; this.btnUpdate.Click += btnUpdate_Click; this.btnPayment.Click += btnPayment_Click; this.btnDelete.Click += btnDelete_Click; this.btnSMS.Click += btnSMS_Click; this.btnImportPhoto.Click += btnImportPhoto_Click; this.btnClose.Click += btnClose_Click; this.chkArrears.Click += chkArrears_Click; this.Resize += FrmTwoSalesOrder_Resize; // 导出按钮 ; this.btnExport.Click += BtnExport_Click; } private void BtnExport_Click(object sender, EventArgs e) { if (this.dgvData.Rows.Count == 0) { MessageBox.Show("没有数据可以导出"); return; } this.dgvData.ExportDataTable(); } public Dictionary DictDataArray = new Dictionary(); /// /// 窗体加载 /// /// /// void FrmTwoSalesOrder_Shown(object sender, EventArgs e) { this.panelImportPhoto.Visible = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.OtherConsumerPassportManagement; // 录入 this.btnEntry.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.Add); // 修改 this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.Update); // 删除 this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.Delete); // 发短信 this.btnSMS.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.SMSSend); // 收款 this.btnPayment.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TwoSalesOrderCompetence, CustomAttributes.OperatingAuthority.OtherConsumerReceivables); this.PublicFunctionRows(); ///控制财务管理员工奖罚薪资执行的版本权 //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D; List hideControls = new List(); hideControls.Add(this.panelImportPhoto); List moveControls = new List(); moveControls.Add(panelClose); moveControls.Add(panelEx10); LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(VersionControl.VersionFunctionEnum.财务管理薪资执行, hideControls, null, null); } /// /// 回车查询 /// /// /// void txtkeyword_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { this.PublicFunctionRows(); } } /// /// 查询 /// /// /// void btnSlect_Click(object sender, EventArgs e) { this.PublicFunctionRows(); } /// /// 列表双击修改 /// /// /// void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { if (dgvData.Rows.Count > 0) { if (!this.btnUpdate.Enabled) { return; } this.btnUpdate_Click(this, null); } } } /// /// 点事件 /// /// /// void dgvData_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (this.dgvData.Rows.Count > 0 && this.dgvData.CurrentRow != null) { if (this.dgvData.CurrentRow.Cells["Tsorder_Category"].Value.ToString().Trim() == "AAAAABZ") { this.btnImportPhoto.Enabled = true; } else { this.btnImportPhoto.Enabled = false; } } } /// /// 条件查询 /// /// /// void btnConditionsSelect_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder.FrmTwoSalesOrderConditionsSelect frm = new TwoSalesOrder.FrmTwoSalesOrderConditionsSelect(); frm.ShowDialog(); if (frm.IsSaveed) { this.DictDataArray = frm.DictDataArray; this.PublicFunctionRows(); } } /// /// 录入 /// /// /// void btnEntry_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder.FrmTwoSalesOrderEntry frm = new TwoSalesOrder.FrmTwoSalesOrderEntry(); frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual; frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y); frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height); frm.ShowDialog(); if (frm.IsSaveed) { this.PublicFunctionRows(); } } /// /// 修改 /// /// /// void btnUpdate_Click(object sender, EventArgs e) { if (this.dgvData.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选择你要修改的数据!"); return; } LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder.FrmTwoSalesOrderEntry frm = new TwoSalesOrder.FrmTwoSalesOrderEntry(); frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual; frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y); frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height); frm.StrOrderNumber = this.dgvData.CurrentRow.Cells["订单号"].Value.ToString().Trim(); frm.ShowDialog(); if (frm.IsSaveed) { this.PublicFunctionRows(); } } /// /// 收款 /// /// /// void btnPayment_Click(object sender, EventArgs e) { if (this.dgvData.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选择你要收款的数据!"); return; } LYFZ.Software.MainBusiness.FinancialManagement.TwoSalesOrder.FrmTwoSalesOrderPayment frm = new TwoSalesOrder.FrmTwoSalesOrderPayment(); frm.StrCope = Convert.ToDecimal(this.dgvData.CurrentRow.Cells["应付金额"].Value); frm.StrPaid = Convert.ToDecimal(this.dgvData.CurrentRow.Cells["已付金额"].Value); frm.StrArrears = Convert.ToDecimal(this.dgvData.CurrentRow.Cells["欠款"].Value); frm.StrOrdNumber = this.dgvData.CurrentRow.Cells["订单号"].Value.ToString().Trim(); frm.ShowDialog(); if (frm.IsSaveed) { PublicFunctionRows(); } } /// /// 删除 /// /// /// void btnDelete_Click(object sender, EventArgs e) { if (this.dgvData.SelectedRows.Count == 0) { MessageBoxCustom.Show("请选中你要删除的数据!"); return; } if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { string strOtherConsumeNumber = this.dgvData.CurrentRow.Cells["订单号"].Value.ToString().Trim(); List clist = new List(); LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { DataTable tbl = orbll.GetView_Custom("tb_ErpPayment", StrWhere: "Pay_OrdNumber = '" + strOtherConsumeNumber + "'", ShowColumnName: "ID").Tables[0]; if (tbl.Rows.Count > 0) { MessageBoxCustom.Show("订单已收款,请先删除收款!"); return; } DataTable dt = orbll.GetView_Custom("tb_ErpTwoSalesOrder", StrWhere: "Tsorder_Number = '" + strOtherConsumeNumber + "'", ShowColumnName: "ID,Tsorder_PhotoNames").Tables[0]; if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["Tsorder_PhotoNames"].ToString().Trim())) { string[] StrArrayList = dt.Rows[0]["Tsorder_PhotoNames"].ToString().Trim().Split('|'); for (int i = 0; i < StrArrayList.Length; i++) { if (!string.IsNullOrEmpty(StrArrayList[i].Trim())) { backgroundWorker.ReportProgress(0, "正在删除证件照..."); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DeleteOtherConsumePhoto(strOtherConsumeNumber + "_" + System.IO.Path.GetFileNameWithoutExtension(StrArrayList[i].Trim()) + ".jpg", IsRecursion: true, DeleteDressType: 0); LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.DeleteOtherConsumePhoto(strOtherConsumeNumber + "_" + StrArrayList[i].Trim(), IsRecursion: true, DeleteDressType: 1); } } } clist.Add(torbll.GetDeleteCommandInfo("ID", "=", dt.Rows[0]["ID"].ToString().Trim())); DataTable dtc = orbll.GetView_Custom("tb_ErpOrderProductList", StrWhere: "OPlist_OrderNumber = '" + strOtherConsumeNumber + "' And OPlist_ViceNumber = '" + strOtherConsumeNumber + "'", ShowColumnName: "ID").Tables[0]; for (int i = 0; i < dtc.Rows.Count; i++) { clist.Add(oplistbll.GetDeleteCommandInfo("ID", "=", dtc.Rows[0]["ID"].ToString().Trim())); } DataTable dta = orbll.GetView_Custom("tb_ErpCustomerGroup", StrWhere: "GP_OrderNumber = '" + strOtherConsumeNumber + "'", ShowColumnName: "ID,GP_CustomerGroupID").Tables[0]; if (dta.Rows.Count > 0) { clist.Add(cgpbll.GetDeleteCommandInfo("ID", "=", dta.Rows[0]["ID"].ToString().Trim())); DataTable dtb = orbll.GetView_Custom("tb_ErpCustomerGroupMembers", StrWhere: "GM_CustomerGroupID = '" + dta.Rows[0]["GP_CustomerGroupID"].ToString().Trim() + "'", ShowColumnName: "ID").Tables[0]; for (int i = 0; i < dtb.Rows.Count; i++) { clist.Add(cgmbll.GetDeleteCommandInfo("ID", "=", dtb.Rows[0]["ID"].ToString().Trim())); } } string logsContent = "删除其他消费订单号为:" + strOtherConsumeNumber; clist.Add(slogbll.GetAddCommandInfo(LYFZ.BLL.BLL_ErpSystemLogs.GetWriteLogModel(LYFZ.EnumPublic.SystemLogsType.删除其他消费, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name, StrInfoID: LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetLocalCompanyInfoID()))); } }); if (clist.Count > 0) { int ExecuteCount = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist); if (ExecuteCount > 0) { MessageBoxCustom.Show("删除成功!"); this.dgvData.Rows.Remove(this.dgvData.SelectedRows[0]); } else { MessageBoxCustom.Show("删除失败!"); } } } } /// /// 发短信 /// /// /// void btnSMS_Click(object sender, EventArgs e) { try { if (this.dgvData.SelectedRows.Count == 0) { MessageBoxCustom.Show("选择你要发送短信的客户!"); return; } LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms frm = new SMSManagement.SmsSend.FrmSendSms(); string Tsorder_Telephone = this.dgvData.CurrentRow.Cells["客户电话"].Value.ToString(); if (!string.IsNullOrEmpty(Tsorder_Telephone)) { frm.Phone = Tsorder_Telephone; } frm.ShowDialog(); } catch (Exception ex) { MessageBoxCustom.Show(ex.Message); } } /// /// 导入证件照 /// /// /// void btnImportPhoto_Click(object sender, EventArgs e) { if (this.dgvData.Rows.Count > 0 && this.dgvData.SelectedRows.Count > 0) { LYFZ.Software.MainBusiness.FinancialManagement.SetSmallForm.OtherConsumeImportPhotoSetSmallForm frm = new SetSmallForm.OtherConsumeImportPhotoSetSmallForm(); frm.StrOtherOrderNumber = this.dgvData.SelectedRows[0].Cells["订单号"].Value.ToString().Trim(); frm.ShowDialog(); if (frm.IsSaveed) { this.PublicFunctionRows(); } } } /// /// 关闭 /// /// /// void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 欠款 /// /// /// void chkArrears_Click(object sender, EventArgs e) { this.PublicFunctionRows(); } /// /// 关闭窗体事件 /// /// /// void FrmTwoSalesOrder_Resize(object sender, EventArgs e) { switch (this.panelClose.Location.Y) { case 4: this.flowLayoutPanel1.Height = 38; break; case 36: this.flowLayoutPanel1.Height = 70; break; } } /// /// 绑定数据 /// public void PublicFunctionRows() { string StrWhere = this.GetStrWhere(); int intTopCount = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize(); Hashtable htData = LYFZ.ComponentLibrary.DataGridOrderView.GetData_OrderOtherConsume(this.dgvData, StrWhere, intTopCount); this.dataGridViewStatisticsCount1.LocationX = this.dgvData.RowHeadersWidth; this.dataGridViewStatisticsCount1.CurrenQuantity = Convert.ToInt32(htData["CurrentCount"].ToString()); this.dataGridViewStatisticsCount1.TotalQuantity = Convert.ToInt32(htData["TotalCount"].ToString()); } /// /// 获取查询条件 /// /// string GetStrWhere() { string StrWhere = " Where 1 = 1"; string StrKeyWord = txtkeyword.Text.Trim(); #region 查询条件 if (!string.IsNullOrEmpty(StrKeyWord)) { Hashtable htData = new Hashtable(); htData["Tsorder_Number"] = ""; htData["Cus_Name"] = ""; htData["Cus_NamePinyin"] = ""; htData["Cus_Telephone"] = ""; if (LYFZ.Command.Command_Validate.IsNumber(StrKeyWord)) { if (StrKeyWord.Trim().Length == 11) { StrWhere += " And Cus_Telephone = '" + StrKeyWord + "'"; } else { StrWhere += " And Cus_Telephone like '" + StrKeyWord + "%'"; } } else if (LYFZ.Command.Command_Validate.IsEnglish(StrKeyWord)) { StrWhere += " And Cus_NamePinyin like '" + StrKeyWord + "%'"; } else if (LYFZ.Command.Command_Validate.IsChinese(StrKeyWord)) { StrWhere += " And Cus_Name like '" + StrKeyWord + "%'"; } else { StrWhere += " And Tsorder_Number like '" + StrKeyWord + "%'"; } } #endregion if (this.DictDataArray.Count > 0) { if (DictDataArray.ContainsKey("strTimeStart") && DictDataArray["strTimeStart"].ToString().Trim().Length > 0 && DictDataArray.ContainsKey("strTimeEnd") && DictDataArray["strTimeEnd"].ToString().Trim().Length > 0) { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Tsorder_CreateDatetime", DictDataArray["strTimeStart"].ToString().Trim(), DictDataArray["strTimeEnd"].ToString().Trim()); } if (DictDataArray.ContainsKey("strItemName") && DictDataArray["strItemName"].ToString().Trim().Length > 0) { StrWhere += " And Tsorder_Name = '" + DictDataArray["strItemName"].ToString().Trim() + "'"; } if (DictDataArray.ContainsKey("strOpenPerson") && DictDataArray["strOpenPerson"].ToString().Trim().Length > 0) { StrWhere += " And Tsorder_OpenSingle = '" + DictDataArray["strOpenPerson"].ToString().Trim() + "'"; } if (DictDataArray.ContainsKey("strConsumeType") && DictDataArray["strConsumeType"].ToString().Trim().Length > 0) { StrWhere += " And Tsorder_Category = '" + DictDataArray["strConsumeType"].ToString().Trim() + "'"; } if (DictDataArray.ContainsKey("strPickup") && DictDataArray["strPickup"].ToString().Trim().Length > 0) { StrWhere += " And Tsorder_PhotoPickup = '" + DictDataArray["strPickup"].ToString().Trim() + "'"; } if (DictDataArray.ContainsKey("strImport") && DictDataArray["strImport"].ToString().Trim().Length > 0) { if (DictDataArray["strImport"].ToString().Trim() == "0") { StrWhere += " And Tsorder_PhotoNames = ''"; } else if (DictDataArray["strImport"].ToString().Trim() == "1") { StrWhere += " And Tsorder_PhotoNames != ''"; } } } if (this.chkArrears.Checked) { StrWhere += " And (套系金额 - isnull(收款金额,0)) > 0"; } this.DictDataArray.Clear(); return StrWhere; } } }