123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- 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;
- namespace LYFZ.Software.MainBusiness.FinancialManagement.PieceCommissionRecords
- {
- public partial class FrmSelectCustomer : LYFZ.Software.UI.FinancialManagement.PieceCommissionRecords.FrmSelectCustomer
- {
- public string Ord_Type;
- public string Ord_Number;
- public string Ord_OrdersPerson;
- public string Ord_CustomerName1;
- public string Ord_SeriesName;
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- public FrmSelectCustomer()
- {
- this.Shown += FrmSelectCustomer_Shown;
- this.btnOk.Click += btnOk_Click;
- this.btnSlect.Click += btnSlect_Click;
- this.dgvData.DoubleClick += dgvData_DoubleClick;
- this.txtQueryText.KeyDown += txtQueryText_KeyDown;
- //this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmSelectCustomer_Shown(object sender, EventArgs e)
- { this.PublicFunctionRows(); }
- /// <summary>
- /// 获取数据
- /// </summary>
- void PublicFunctionRows()
- {
- string StrWhere1 = "";
- string StrWhere2 = "";
- int inTop = 20;
- if (this.txtQueryText.Text.Trim().Length > 0)
- {
- inTop = 100;
- StrWhere1 = "And (Cus_Name like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_Telephone like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_Name_py like '%" + this.txtQueryText.Text.Trim() + "%' or Ord_SinceOrderNumber = '" + this.txtQueryText.Text.Trim() + "')";
- StrWhere2 = "And (Cus_Name like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_Telephone like '%" + this.txtQueryText.Text.Trim() + "%' or Cus_NamePinyin like '%" + this.txtQueryText.Text.Trim() + "%' or Tsorder_Number = '" + this.txtQueryText.Text.Trim() + "')";
- }
- DataTable dtTable = new DataTable();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- string StrTableName = "with t AS " +
- "(" +
- "select tb_ErpOrder.ID,Ord_Number AS 订单编号,Ord_SinceOrderNumber AS 订单号,dbo.fn_CheckOrderType(Ord_Type) AS 订单类型,Cus_Name AS 客户姓名,Cus_Telephone AS 客户电话,接单人,Ord_SeriesName AS 套系名称,Ord_SeriesPrice AS 套系价格,1 AS 数量 " +
- "from tb_ErpOrder " +
- "Left Join dbo.CView_OrderPerson on OrdPe_OrderNumber = Ord_Number " +
- "Left Join tempTB_AggregationCustomer on Ord_Number=GP_OrderNumber " +
- "where Cus_Name is not null " + StrWhere1 + " " +
- "UNION ALL " +
- "select tb_ErpTwoSalesOrder.ID,Tsorder_Number AS 订单编号,Tsorder_Number AS 订单号,'散客消费' AS 订单类型,Cus_Name AS 客户姓名,Cus_Telephone AS 客户电话,Tsorder_OpenSingle AS 接单人,Tsorder_Name AS 套系名称,Tsorder_Money AS 套系价格,Tsorder_Quantity AS 数量 " +
- "from tb_ErpTwoSalesOrder " +
- "Left Join tb_ErpCustomer on Cus_CustomerNumber = Tsorder_CustomerNumber " +
- "Where Cus_Name is not null " + StrWhere2 +
- ")" +
- "select top " + inTop + " * from t Order By ID DESC";
- dtTable = orbll.GetView_Custom(StrTableName).Tables[0];
- //刘工临时修复 散客消费订单的订接单人显示错误问题
- foreach (DataRow row in dtTable.Rows)
- {
- if (row["订单类型"].ToString() == "散客消费")
- {
- row["接单人"] = LYFZ.DAL.DAL_ErpUser.GetUserIDToUserName(row["接单人"].ToString());
- }
- }
- });
-
- this.dgvData.DataSource(dtTable, strHideField: "ID,订单编号");
- //foreach (DataGridViewRow row in this.dgvData.Rows)
- //{
- // row.Cells["接单人"].Value="AK";
- //}
- }
- /// <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 txtQueryText_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.PublicFunctionRows(); }
- }
- /// <summary>
- /// 确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnOk_Click(object sender, EventArgs e)
- {
- if (this.dgvData.SelectedRows.Count == 0)
- { MessageBoxCustom.Show("请选中你要的客户!"); return; }
- if (this.dgvData.CurrentRow.Cells["订单类型"].Value.ToString().Trim() == "散客消费")
- { this.Ord_Type = "散客消费"; }
- else
- { this.Ord_Type = this.dgvData.CurrentRow.Cells["订单类型"].Value.ToString().Trim(); }
- this.Ord_Number = this.dgvData.CurrentRow.Cells["订单编号"].Value.ToString().Trim();
- this.Ord_OrdersPerson = this.dgvData.CurrentRow.Cells["接单人"].Value.ToString().Trim();
- this.Ord_CustomerName1 = this.dgvData.CurrentRow.Cells["客户姓名"].Value.ToString().Trim();
- this.Ord_SeriesName = this.dgvData.CurrentRow.Cells["套系名称"].Value.ToString().Trim();
- this.Close();
- }
- /// <summary>
- /// 双击确定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_DoubleClick(object sender, EventArgs e)
- { this.btnOk_Click(this, null); }
- }
- }
|