123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428 |
- 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<string, string> DictDataArray = new Dictionary<string, string>();
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<Control> hideControls = new List<Control>();
- hideControls.Add(this.panelImportPhoto);
- List<Control> moveControls = new List<Control>();
- moveControls.Add(panelClose);
- moveControls.Add(panelEx10);
- LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(VersionControl.VersionFunctionEnum.财务管理薪资执行, hideControls, null, null);
- }
- /// <summary>
- /// 回车查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtkeyword_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.PublicFunctionRows(); }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSlect_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 列表双击修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- }
- /// <summary>
- /// 点事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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; }
- }
- }
- /// <summary>
- /// 条件查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- /// <summary>
- /// 录入
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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(); }
- }
- /// <summary>
- /// 修改
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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(); }
- }
- /// <summary>
- /// 收款
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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(); }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- 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("删除失败!"); }
- }
- }
- }
- /// <summary>
- /// 发短信
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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); }
- }
- /// <summary>
- /// 导入证件照
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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(); }
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 欠款
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkArrears_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 关闭窗体事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- }
- /// <summary>
- /// 绑定数据
- /// </summary>
- 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());
- }
- /// <summary>
- /// 获取查询条件
- /// </summary>
- /// <returns></returns>
- 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;
- }
-
- }
- }
|