123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- 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 WorkStatisticalDesign : LYFZ.Software.UI.StatisticalEmployeeWork.WorkStatisticalDesign
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- public WorkStatisticalDesign()
- {
- this.Load += WorkStatisticalDesign_Load;
- this.Shown += WorkStatisticalDesign_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 WorkStatisticalDesign_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");
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void WorkStatisticalDesign_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;
- 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 += " Ordv_DesignerName like '%" + userNode.Tag + "%'";
- }
- }
- }
- }
- }
- else if (tBode.Name == "Department")
- {
- if (tBode.Nodes.Count > 0)
- {
- foreach (TreeNode userNode in tBode.Nodes)
- {
- if (strWhere != "")
- {
- strWhere += " or ";
- }
- strWhere += " Ordv_DesignerName like '%" + userNode.Tag + "%'";
- }
- }
- }
- else if (tBode.Name == "User")
- {
- if (strWhere != "")
- {
- strWhere += " or ";
- }
- strWhere += " Ordv_DesignerName like '%" + tBode.Tag + "%'";
- //strWhere += tBode.Tag ;
- }
- if (string.IsNullOrEmpty(strWhere))
- {
- strWhere = " Ordv_DesignerName = '-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)
- {
- 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 = "Ordv_DesignerStatus = '2' And Ordv_DesignerName != ''";
- StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Ordv_DesignerTime", this.dtDataTimeStart.DateValue.Trim(), this.dtDataTimeEnd.DateValue.Trim());
- if (this.cmbtreevperson.Text.Trim() != "全部")
- { StrWhere += " And ("+ GetEmployeeDataInfo() + ") "; }
- DAL.DAL_ErpOrdersPhotography bLLErpOrdersPhotography = new DAL.DAL_ErpOrdersPhotography();
- DataTable dt = bLLErpOrdersPhotography.GetStatisticalRepairPieceData(StrWhere, "dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) AS 设计师" +
- ",dbo.fn_CheckDateTime(Ordv_DesignerTime) AS 设计日期" +
- ",dbo.fn_CheckOrderEarlyRepairStatus(Ordv_DesignerStatus) AS 设计状态");
- 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 tb_ErpOrderDigitalStatus 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 套系价格" +
- ",dbo.fn_CheckUserIDGetUserName(Ordv_DesignerName) AS 设计师" +
- ",dbo.fn_CheckDateTime(Ordv_DesignerTime) AS 设计日期" +
- ",Ords_SightsName AS 拍摄名称" +
- ",dbo.fn_CheckOrderDesignerStatus(Ordv_DesignerStatus) AS 设计状态" +
- ",(套系金额 + isnull(加挑金额,0) - isnull(收款金额,0)) AS 欠款";
- DataTable dt = orbll.GetView_Custom(StrTableName, StrWhere: StrWhere, ShowColumnName: StrColumnName).Tables[0];*/
- this.dgvData.DataSource(dt, strHideField: "Ordv_ViceNumber");
- 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();
- }
- }
- }
|