123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- 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.StatisticalEmployeeWork
- {
- public partial class WorkStatisticalPhotographer : LYFZ.Software.UI.StatisticalEmployeeWork.WorkStatisticalPhotographer
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- public WorkStatisticalPhotographer()
- {
- this.Load += WorkStatisticalPhotographer_Load;
- this.Shown += WorkStatisticalPhotographer_Shown;
- this.dtDataTimeStart.Leave += dtDataTimeStart_Leave;
- this.btnQuery.Click += btnQuery_Click;
- this.btnExport.Click += btnExport_Click;
- this.btnClose.Click += btnClose_Click;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void WorkStatisticalPhotographer_Load(object sender, EventArgs e)
- {
- this.dtDataTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM") + "-01";
- this.dtDataTimeEnd.DateValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- cbx_SearchUser.SelectedIndex = 0;
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void WorkStatisticalPhotographer_Shown(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbtreevperson, true, IsFirstNodeName: "全部", IsShowResign: false);
- cmbtreevperson.IsNodeMouseClick = true;
- cmbtreevperson.IsSelectParentNode = true;
- this.cmbtreevperson.TextFindTag("全部");
- this.btnQuery_Click(this, null);
- bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.工作统计);
- if (!b)
- {
- this.Close();
- }
- }
- /// <summary>
- /// 开始日期离开事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dtDataTimeStart_Leave(object sender, EventArgs e)
- {
- this.dtDataTimeEnd.DateValue = Convert.ToDateTime(this.dtDataTimeStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- }
- /// <summary>
- /// 获取员工编号
- /// </summary>
- /// <returns></returns>
- string GetEmployeeDataInfo()
- {
- string strWhere = "";
- TreeNode tBode = this.cmbtreevperson.SelectedNode;
- string searchSqlKey = "Ords_Photographer";
- switch(cbx_SearchUser.Text)
- {
- case "接单人":
- searchSqlKey = "Ord_OrderPersonNumber";
- break;
- case "摄影师":
- searchSqlKey = "Ords_Photographer";
- break;
- case "客服人员":
- searchSqlKey = "客服人员";
- break;
-
- }
- if (tBode.Name == "StoreName")
- {
- if (tBode.Nodes.Count > 0)
- {
- foreach (TreeNode node in tBode.Nodes)
- {
- if (node.Nodes.Count > 0)
- {
- foreach (TreeNode userNode in node.Nodes)
- {
- if (strWhere != "")
- {
- strWhere += " or ";
- }
- strWhere += " "+ searchSqlKey + " like '%" + userNode.Tag + "%'";
- }
- }
- }
- }
- }
- else if (tBode.Name == "Department")
- {
- if (tBode.Nodes.Count > 0)
- {
- foreach (TreeNode userNode in tBode.Nodes)
- {
- if (strWhere != "")
- {
- strWhere += " or ";
- }
- strWhere += " " + searchSqlKey + " like '%" + userNode.Tag + "%'";
- }
- }
- }
- else if (tBode.Name == "User")
- {
- if (strWhere != "")
- {
- strWhere += " or ";
- }
- strWhere += " " + searchSqlKey + " like '%" + tBode.Tag + "%'";
- //strWhere += tBode.Tag ;
- }
- if (string.IsNullOrEmpty(strWhere))
- {
- strWhere = " " + searchSqlKey + " = '-1'";
- }
- //strDepartment = "'" + string.Join("','", department.ToArray()) + "'";
- return strWhere;
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- DAL.DAL_ErpOrdersPhotography bLLErpOrdersPhotography = new DAL.DAL_ErpOrdersPhotography();
- if (string.IsNullOrEmpty(this.dtDataTimeStart.DateValue.Trim()) && string.IsNullOrEmpty(this.dtDataTimeEnd.DateValue.Trim()))
- { MessageBoxCustom.Show("日期段不能为空"); return; }
- if (Convert.ToDateTime(this.dtDataTimeEnd.DateValue) < Convert.ToDateTime(this.dtDataTimeStart.DateValue))
- { MessageBoxCustom.Show("开始日期不能大于结束日期"); return; }
- if (string.IsNullOrEmpty(this.cmbtreevperson.Text.Trim()))
- { MessageBoxCustom.Show("摄影师不能为空!"); return; }
- string StrWhere = "Ords_PhotographStatus = '1'";
- StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Ords_PhotographMaxTime", this.dtDataTimeStart.DateValue.Trim(), this.dtDataTimeEnd.DateValue.Trim());
- if (this.cmbtreevperson.Text.Trim() != "全部")
- { StrWhere += " And ("+ GetEmployeeDataInfo() + ")"; }
- else
- { StrWhere += " And Ords_Photographer != ''"; }
- DataTable dt = bLLErpOrdersPhotography.GetStatisticalPhotographerData(StrWhere, " Ords_Photographer as 摄影师 ");
- DataTable useDt = new BLL.BLL_ErpUser().GetAllList().Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- List<DataRow> useDr = useDt.AsEnumerable().Where(p => p.Field<string>("User_EmployeeID") == dr["摄影师"].ToString_s()).ToList();
- if (useDr.Count > 0)
- {
- dr["摄影师"] = useDr[0]["User_Name"];
- }
- useDr = useDt.AsEnumerable().Where(p => p.Field<string>("User_EmployeeID") == dr["客服人员"].ToString_s()).ToList();
- if (useDr.Count > 0)
- {
- dr["客服人员"] = useDr[0]["User_Name"];
- }
- }
- if (dt.Rows.Count > 0)
- {
- dt = dt.AsEnumerable().OrderByDescending(p => p.Field<string>("拍摄日期")).CopyToDataTable();
- }
- /*string StrTableName = "tb_ErpOrderDigital Left Join dbo.tb_ErpOrder on Ord_Number = Ordv_Number Left Join tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber " +
- "Left Join dbo.BView_OrderAmount on Order_Number = Ord_Number Left Join OrderPhotographyData on Ords_ViceNumber = Ordv_ViceNumber ";
- string StrColumnName = "Ord_SinceOrderNumber AS 订单号," +
- "dbo.fn_CheckOrderType(Ord_Type) AS 订单类型," +
- "Cus_Name AS 客户姓名," +
- "Cus_Sex_cs AS 客户性别," +
- "Cus_Telephone AS 客户电话," +
- "Ord_OrderPersonName AS 接单人," +
- "Ord_SeriesName AS 套系名称," +
- "Ord_SeriesPrice AS 套系价格," +
- "Ords_Photographer AS 摄影师," +
- "dbo.fn_CheckDateTime(Ords_PhotographMaxTime) AS 拍摄日期," +
- "Ords_SightsName AS 拍摄名称," +
- "(case Ords_PhotographStatus when '1' then 'OK' else '未拍' end ) AS 拍照状态," +
- "(套系金额 + isnull(加挑金额,0) - isnull(收款金额,0)) AS 欠款";
- string sql = @"with OrderPhotographyData as (
- select distinct
- Ordpg_PhotographyStatus as Ords_PhotographStatus,
- max(Ordpg_PhotographyTime) as Ords_PhotographMaxTime,
- Ordpg_Photographer as Ords_Photographer ,
- Ordpg_Number,
- Ordpg_ViceNumber as Ords_ViceNumber,
- STUFF(
- (
- SELECT ',' + Ordpg_Sights
- FROM[dbo].tb_ErpOrdersPhotography
- WHERE Ordpg_ViceNumber = A.Ordpg_ViceNumber
- FOR XML PATH('')
- )
- ,1,1,''
- )AS Ords_SightsName
- from
- tb_ErpOrdersPhotography as A
- group by Ordpg_Number,Ordpg_ViceNumber,Ordpg_PhotographyStatus,Ordpg_PhotographyTime,Ordpg_Photographer
- )" +
- "select " + StrColumnName + " from " + StrTableName + " where " + StrWhere;*/
- //DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: StrWhere, ShowColumnName: StrColumnName).Tables[0];
- //DataTable dt = orbll.GetView_Custom(sql).Tables[0];
- this.dgvData.DataSource(dt, strHideField: "");
- this.dgvData.Columns["客户电话"].Width = 180;
- this.dgvData.Columns["拍摄名称"].Width = 200;
- this.dgvData.Columns["拍摄日期"].Width = 110;
- this.dgvData.FillLastColumn(isAddNullColumns: true);
- string StrStatisticalText = "总数量:" + dt.Rows.Count;
- DataRow[] dtRow1 = dt.Select("订单类型 = '婚纱订单'");
- if (dtRow1.Length > 0)
- { StrStatisticalText += " 婚纱订单:" + dtRow1.Length; }
- DataRow[] dtRow2 = dt.Select("订单类型 = '儿童订单'");
- if (dtRow2.Length > 0)
- { StrStatisticalText += " 儿童订单:" + dtRow2.Length; }
- DataRow[] dtRow3 = dt.Select("订单类型 = '写真订单'");
- if (dtRow3.Length > 0)
- { StrStatisticalText += " 写真订单:" + dtRow3.Length; }
- // 套系价格列求和;
- try
- {
- double sumObject = Convert.ToDouble(dt.Compute("sum(套系价格)", "true"));
- StrStatisticalText += string.Format(" 套系总价:{0:N2}, 套系平均价:{1:N2}", sumObject, sumObject / dt.Rows.Count);
- }
- catch { }
- this.txtStatisticalText.Text = StrStatisticalText;
- }
- /// <summary>
- /// 导出
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnExport_Click(object sender, EventArgs e)
- {
- this.dgvData.ExportDataTable(this.UcNavigationTool.LabTitle);
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
|