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.CameraControlBook
{
public partial class OrderControlFormMain : LYFZ.Software.UI.CameraControlBook.OrderControlFormMain
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
public OrderControlFormMain()
{
this.Load += OrderControlFormMain_Load;
this.Shown += OrderControlFormMain_Shown;
this.btnQuery.Click += btnQuery_Click;
this.btnExport.Click += btnExport_Click;
this.btnCloses.Click += btnCloses_Click;
this.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
this.dgvData.EventRowExpandCollapse += dgvData_EventRowExpandCollapse;
}
///
/// 窗体加载事件
///
///
///
void OrderControlFormMain_Load(object sender, EventArgs e)
{
string StrColumnName = "订单号,订单类型,分店,客户姓名,客户拼音,客户性别,客户电话,预约拍照日期,完成状态,取件状态";
this.dgvData.DataColumns(StrColumns: StrColumnName);
}
///
/// 窗体加载事件
///
///
///
void OrderControlFormMain_Shown(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 查询
///
///
///
void btnQuery_Click(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
///
///
///
///
void btnExport_Click(object sender, EventArgs e)
{
if (this.dgvData.Rows.Count > 0)
{
string StrtableName = this.tabControlEx1.SelectedTab.Text.Trim();
this.dgvData.ExportDataTable(StrtableName);
}
}
///
/// 关闭
///
///
///
void btnCloses_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 选项卡选择事件
///
///
///
void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 分页前数据,便于展开时用来查询订单的子数据
///
DataTable tblMianSelectData = new DataTable();
///
/// 创建行
///
void PublicFunctionRows()
{
int intViceCount = 1;
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ExpiredReservationPhotographyNotPhotography":
intViceCount = 2;
break;
}
tblMianSelectData = new DataTable();
tblMianSelectData = orbll.GetView_Custom(this.GetTableName()).Tables[0];
this.dgvData.ViceCount = intViceCount;
this.dgvData.DataSourceMain(tblMianSelectData, strHideField: "PID,Ord_Number,Ord_ViceOrderCount");
this.dgvData.FillLastColumn(isAddNullColumns: true);
Hashtable htData = new Hashtable();
for (int i = 0; i < tblMianSelectData.Rows.Count; i++)
{ htData[tblMianSelectData.Rows[i]["Ord_Number"].ToString().Trim()] = tblMianSelectData.Rows[i]["Ord_Number"].ToString().Trim(); }
this.dataGridViewStatisticsCount1.LocationX = this.dgvData.RowHeadersWidth;
this.dataGridViewStatisticsCount1.CurrenQuantity = htData.Count;
this.dataGridViewStatisticsCount1.TotalQuantity = htData.Count;
bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.客服中心已过预约把控);
if (!b)
{
this.Close();
}
}
///
/// 获取视图表
///
///
string GetTableName()
{
string StrWhere = "";
string StrTableName = "";
if (!string.IsNullOrEmpty(this.txtQuery.Text.Trim()))
{ StrWhere = "Where (订单号 like '%" + this.txtQuery.Text.Trim() + "%' or 客户姓名 like '%" + this.txtQuery.Text.Trim() + "%' or 客户拼音 like '%" + this.txtQuery.Text.Trim() + "%' or 客户电话 like '%" + this.txtQuery.Text.Trim() + "%')"; }
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ExpiredReservationPhotographyNotPhotography":
StrTableName = "with t AS ( " +
"select Max(ID) AS PID,Ordpg_Number,Ordpg_ViceNumber,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS Ordpg_ReservationPhotographyTime,Ordpg_PhotographyStatus " +
"from tb_ErpOrdersPhotography " +
"where Ordpg_PhotographyStatus != '1' And Ordpg_ReservationPhotographyTime is not null And Ordpg_ViceNumber != '' " +
"Group By Ordpg_Number,Ordpg_ViceNumber,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)),Ordpg_PhotographyStatus " +
") " +
", t1 AS( " +
"select PID,Ord_Number,Ordpg_ViceNumber,Ord_DividedShop, " +
"CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号, " +
"dbo.fn_CheckOrderType(Ord_Type) AS 订单类型, " +
"Company_Name AS 分店, " +
"Cus_Name AS 客户姓名, " +
"Cus_Name_py AS 客户拼音, " +
"Cus_Sex_cs AS 客户性别, " +
"Cus_Telephone AS 客户电话, " +
"Ordpg_ReservationPhotographyTime AS 预约拍照日期, " +
"dbo.fn_CheckOrderPhotographyStatus(t.Ordpg_PhotographyStatus) AS 拍摄状态, " +
"(SELECT Count(Ordpg_ViceNumber) AS CountID FROM t AS tt WHERE tt.Ordpg_ViceNumber = t.Ordpg_ViceNumber) AS Ord_ViceOrderCount " +
"from t " +
"Left Join tb_ErpOrder on Ord_Number = t.Ordpg_Number " +
"Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
"Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
"where Ord_Number is not null And convert(datetime,Ordpg_ReservationPhotographyTime,120) < GETDATE() " +
") " +
"select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约拍照日期,拍摄状态,Ord_ViceOrderCount " +
"from t1 " + StrWhere + " " +
"order by Ordpg_ViceNumber,预约拍照日期";
break;
case "tabPage_ExpiredReservationLookDesignNotLookDesign":
StrTableName = "with t AS( " +
"select tb_ErpOrderDigital.ID AS PID, " +
"Ord_Number, " +
"Ordv_ViceNumber, " +
"Ord_DividedShop, " +
"CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号, " +
"dbo.fn_CheckOrderType(Ord_Type) AS 订单类型, " +
"Company_Name AS 分店, " +
"Cus_Name AS 客户姓名, " +
"Cus_Name_py AS 客户拼音, " +
"Cus_Sex_cs AS 客户性别, " +
"Cus_Telephone AS 客户电话, " +
"dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationLookDesignTime)) AS 预约看版日期, " +
"dbo.fn_CheckOrderLookDesignStatus(Ordv_LookDesignStatus) AS 看版状态, " +
"(SELECT Count(Ordv_ViceNumber) AS CountID FROM tb_ErpOrderDigital AS tt WHERE tt.Ordv_ViceNumber = tb_ErpOrderDigital.Ordv_ViceNumber) AS Ord_ViceOrderCount " +
"from tb_ErpOrderDigital " +
"Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
"Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
"Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
"where Ord_Number is not null And Ordv_LookDesignStatus != '1' And convert(datetime,Ordv_ReservationLookDesignTime,120) < GETDATE() " +
") " +
"select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约看版日期,看版状态,Ord_ViceOrderCount " +
"from t " + StrWhere + " " +
"order by Ordv_ViceNumber,预约看版日期";
break;
case "tabPage_ExpiredReservationPickupNotComplete":
StrTableName = "with t AS " +
"(" +
"select " +
"Max(ID) AS PID," +
"OPlist_ViceNumber," +
"dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS OPlist_ReservationTakeTime," +
"OPlist_CompletedStatus," +
"OPlist_PickupStatus " +
"from tb_ErpOrderProductList " +
"where OPlist_Type = '2' And OPlist_ReservationTakeTime is not null And OPlist_PickupStatus = '0' And OPlist_CompletedStatus = '0' And OPlist_ViceNumber != '' " +
"Group By OPlist_ViceNumber,OPlist_CompletedStatus,OPlist_PickupStatus,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime))" +
")" +
", t1 AS " +
"(" +
"select " +
"PID," +
"Ord_Number," +
"Ordv_ViceNumber," +
"Ord_DividedShop," +
"CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号," +
"dbo.fn_CheckOrderType(Ord_Type) AS 订单类型," +
"Company_Name AS 分店," +
"Cus_Name AS 客户姓名," +
"Cus_Name_py AS 客户拼音," +
"Cus_Sex_cs AS 客户性别," +
"Cus_Telephone AS 客户电话," +
"OPlist_ReservationTakeTime AS 预约取件日期," +
"dbo.fn_CheckProductCompletedStatus(t.OPlist_CompletedStatus) AS 完成状态," +
"dbo.fn_CheckProductTakePiecesStatus(t.OPlist_PickupStatus) AS 取件状态," +
"(SELECT Count(OPlist_ViceNumber) AS CountID FROM t AS tt WHERE tt.OPlist_ViceNumber = Ordv_ViceNumber) AS Ord_ViceOrderCount " +// tt.OPlist_ReservationTakeTime = t.OPlist_ReservationTakeTime
"from t " +
"Left Join tb_ErpOrderDigital on Ordv_ViceNumber = OPlist_ViceNumber " +
"Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
"Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
"Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
"where Ord_Number is not null And convert(datetime,OPlist_ReservationTakeTime,120) < GETDATE() " +
")" +
"select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约取件日期,完成状态,取件状态,Ord_ViceOrderCount from t1 " + StrWhere + " " +
"order by Ordv_ViceNumber,预约取件日期";
break;
case "tabPage_ExpiredReservationPickupNotPickup":
StrTableName = "with t AS " +
"(" +
"select " +
"Max(ID) AS PID," +
"OPlist_ViceNumber," +
"dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS OPlist_ReservationTakeTime," +
"OPlist_CompletedStatus," +
"OPlist_PickupStatus " +
"from tb_ErpOrderProductList " +
"where OPlist_Type = '2' And OPlist_ReservationTakeTime is not null And OPlist_PickupStatus = '0' And OPlist_ViceNumber != '' " +
"Group By OPlist_ViceNumber,OPlist_CompletedStatus,OPlist_PickupStatus,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime))" +
")" +
", t1 AS" +
"(" +
"select " +
"PID," +
"Ord_Number," +
"Ordv_ViceNumber," +
"Ord_DividedShop," +
"CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号," +
"dbo.fn_CheckOrderType(Ord_Type) AS 订单类型," +
"Company_Name AS 分店," +
"Cus_Name AS 客户姓名," +
"Cus_Name_py AS 客户拼音," +
"Cus_Sex_cs AS 客户性别," +
"Cus_Telephone AS 客户电话," +
"OPlist_ReservationTakeTime AS 预约取件日期," +
"dbo.fn_CheckProductCompletedStatus(t.OPlist_CompletedStatus) AS 完成状态," +
"dbo.fn_CheckProductTakePiecesStatus(t.OPlist_PickupStatus) AS 取件状态," +
"(SELECT Count(OPlist_ViceNumber) AS CountID FROM t AS tt WHERE tt.OPlist_ViceNumber = Ordv_ViceNumber) AS Ord_ViceOrderCount " +// And tt.OPlist_ReservationTakeTime = t.OPlist_ReservationTakeTime
"from t " +
"Left Join tb_ErpOrderDigital on Ordv_ViceNumber = OPlist_ViceNumber " +
"Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
"Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
"Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
"where Ord_Number is not null And convert(datetime,OPlist_ReservationTakeTime,120) < GETDATE() " +
")" +
"select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约取件日期,完成状态,取件状态,Ord_ViceOrderCount from t1 " + StrWhere + " " +
"order by Ordv_ViceNumber,预约取件日期";
break;
case "tabPage_ExpireReservationSelect":
StrTableName = "with t AS( " +
"select tb_ErpOrderDigital.ID AS PID, " +
"Ord_Number, " +
"Ordv_ViceNumber, " +
"Ord_DividedShop, " +
"CASE Ord_SinceOrderNumber WHEN '' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号, " +
"dbo.fn_CheckOrderType(Ord_Type) AS 订单类型, " +
"Company_Name AS 分店, " +
"Cus_Name AS 客户姓名, " +
"Cus_Name_py AS 客户拼音, " +
"Cus_Sex_cs AS 客户性别, " +
"Cus_Telephone AS 客户电话, " +
"dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationFilmSelectionTime)) AS 预约选样日期, " +
"dbo.fn_CheckOrderFilmSelectionStatus(Ordv_FilmSelectionStatus) AS 选样状态, " +
"(SELECT Count(Ordv_ViceNumber) AS CountID FROM tb_ErpOrderDigital AS tt WHERE tt.Ordv_ViceNumber = tb_ErpOrderDigital.Ordv_ViceNumber) AS Ord_ViceOrderCount " +
"from tb_ErpOrderDigital " +
"Left Join tb_ErpOrder on Ord_Number = Ordv_Number " +
"Left Join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber " +
"Left Join tb_ErpCompanyInfo on Company_DividedShop = Ord_DividedShop " +
"where Ord_Number is not null And Ordv_FilmSelectionStatus != '1' And convert(datetime,Ordv_ReservationFilmSelectionTime,120) < GETDATE() " +
") " +
"select PID,Ord_Number,订单号,订单类型,分店,客户姓名,客户性别,客户电话,预约选样日期,选样状态,Ord_ViceOrderCount " +
"from t " + StrWhere + " " +
"order by Ordv_ViceNumber,预约选样日期";
break;
}
return StrTableName;
}
///
/// 展开副级
///
///
void dgvData_EventRowExpandCollapse(ComponentLibrary.DataGridViewEc.EventExpandCollapse e)
{
//现再为展开
if (e.ExpandOrCollapse)
{
if (tblMianSelectData.Rows.Count > 0)
{
string StrOrderBy = "";
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ExpiredReservationPhotographyNotPhotography":
StrOrderBy = "预约拍照日期";
break;
case "tabPage_ExpiredReservationLookDesignNotLookDesign":
StrOrderBy = "预约看版日期";
break;
case "tabPage_ExpiredReservationPickupNotComplete":
case "tabPage_ExpiredReservationPickupNotPickup":
StrOrderBy = "预约取件日期";
break;
}
DataRow[] dtRow = this.tblMianSelectData.Select("Ord_Number = '" + this.dgvData.CurrentRow.Cells["Ord_Number"].Value.ToString().Trim() + "' and PID <> '" + this.dgvData.CurrentRow.Cells["PID"].Value.ToString().Trim() + "'", StrOrderBy);
this.dgvData.DgvValueFiledNull = this.dgvData.StrValueNullColumn + ",订单号,订单类型,分店";
this.dgvData.DataSourceViceRow(dtRow);
}
}
//现再为折叠
else { }
}
}
}