using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LYFZ.Software.MainBusiness.StatisticalInquiry { public class FrmSliceStatistics : LYFZ.Software.UI.StatisticalInquiry.FrmSliceStatistics { LYFZ.BLL.BLL_ErpOrdersPhotography photographBll = new BLL.BLL_ErpOrdersPhotography(); LYFZ.BLL.BLL_ErpUser userBll = new BLL.BLL_ErpUser(); Dictionary> dicList = new Dictionary>(); public FrmSliceStatistics() { btn_Search.Click += btn_Search_Click; this.Load += FrmSliceStatistics_Load; this.dgvData.CellDoubleClick += dgvData_CellContentDoubleClick; BindErpSystemCategoryData(); } void BindErpSystemCategoryData() { BLL.BLL_ErpSystemCategory bllCategory = new BLL.BLL_ErpSystemCategory(); List categoryList = bllCategory.GetSpecifyParentIDToClassList(153); ItemValue itemValue = new ItemValue("", "全部"); cbx_Level.Items.Add(itemValue); foreach (var mod in categoryList) { cbx_Level.Items.Add(new ItemValue(mod.Sc_ClassCode, mod.Sc_ClassName)); } cbx_Level.SelectedIndex = 0; } void dgvData_CellContentDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e) { //throw new NotImplementedException(); if(e.RowIndex==-1) { return; } System.Windows.Forms.DataGridViewRow gridViewRow = this.dgvData.Rows[e.RowIndex]; FrmSliceStatisticsDetail detail = new FrmSliceStatisticsDetail(); detail.startTime = dtp_StartTime.Value.ToString("yyyy-MM-dd"); detail.endTime = dtp_EndTime.Value.ToString("yyyy-MM-dd"); detail.employeeId = gridViewRow.Tag.ToString(); detail.tempStrWhere = BindDataGridByWhere(); System.Windows.Forms.DataGridViewColumn cell = this.dgvData.Columns[e.ColumnIndex]; if (cell.HeaderText == "摄影师") { detail.employeeKey = "Ordpg_Photographer"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "摄影助理") { detail.employeeKey = "Ordpg_PhotographyAssistant"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "化妆师") { detail.employeeKey = "Ordpg_MakeupArtist"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "化妆助理") { detail.employeeKey = "Ordpg_MakeupAssistant"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "引导师") { detail.employeeKey = "Ordpg_BootDivision"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "引导助理") { detail.employeeKey = "Ordpg_BootDivisionAssistant"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "初修师") { detail.employeeKey = "Ordv_EarlyRepairName"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "精修师") { detail.employeeKey = "Ordv_RefinementName"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "选片师") { detail.employeeKey = "Ordv_FilmSelectionName"; detail.employeeKeyName = cell.HeaderText; } else if (cell.HeaderText == "设计师") { detail.employeeKey = "Ordv_DesignerName"; detail.employeeKeyName = cell.HeaderText; } detail.employeeName = gridViewRow.Cells[0].Value.ToString(); detail.ShowDialog(); } void FrmSliceStatistics_Load(object sender, EventArgs e) { btn_Search_Click(null, null); } void BindDataGridRowView() { dicList.Clear(); this.dgvData.Rows.Clear(); System.Data.DataTable userDt = userBll.GetAllList().Tables[0]; System.Data.DataTable dt = photographBll.GetOrdersPhotographyDataBySelection(dtp_StartTime.Value.ToString("yyyy-MM-dd"), dtp_EndTime.Value.ToString("yyyy-MM-dd"), BindDataGridByWhere(), false); foreach(System.Data.DataRow dr in userDt.Rows) { dicList.Add(dr["User_Name"].ToString() + "|" + dr["User_EmployeeID"], new Dictionary()); BindUserActionData(dicList[dr["User_Name"].ToString() + "|" + dr["User_EmployeeID"]], dt, dr["User_EmployeeID"].ToString()); } foreach(string key in dicList.Keys) { int rowIdnex = this.dgvData.Rows.Add(); System.Windows.Forms.DataGridViewRow gridViewRow = this.dgvData.Rows[rowIdnex]; gridViewRow.Tag = key.Split('|')[1]; gridViewRow.Cells[0].Value = key.Split('|')[0]; Dictionary valueList = dicList[key]; foreach(string columKey in valueList.Keys) { gridViewRow.Cells[columKey].Value = valueList[columKey]; } } } string BindDataGridByWhere() { string strWhere = ""; string cbxSceneryText = cbx_Scenery.SelectedItem.ToString(); string cbxSceneryValue = ""; switch (cbxSceneryText) { case "全部": break; case "外景": cbxSceneryValue = "1"; break; case "内景": cbxSceneryValue = "0"; break; } if (!string.IsNullOrEmpty(cbxSceneryValue)) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += " and "; } strWhere += " Ordpg_SightsType ='" + cbxSceneryValue + "' "; } ItemValue cbxLevel = (ItemValue)cbx_Level.SelectedItem; if (!string.IsNullOrEmpty(cbxLevel.Value.ToString())) { if (!string.IsNullOrEmpty(strWhere)) { strWhere += " and "; } strWhere += " Ordpg_SightsLevel ='" + cbxLevel.Value + "' "; } return strWhere; } void BindUserActionData(Dictionary dicList, System.Data.DataTable gridDt,string employeeId) { System.Data.DataRow[] photographList = gridDt.Select(" 摄影师 like '%" + employeeId + "%' "); System.Data.DataRow[] photographAssistantList = gridDt.Select(" 摄影助理 like '%" + employeeId + "%' "); System.Data.DataRow[] MakeupArtistList = gridDt.Select(" 化妆师 like '%" + employeeId + "%' "); System.Data.DataRow[] MakeupAssistantList = gridDt.Select(" 化妆助理 like '%" + employeeId + "%' "); System.Data.DataRow[] BootDivisionList = gridDt.Select(" 引导师 like '%" + employeeId + "%' "); System.Data.DataRow[] BootDivisionAssistantList = gridDt.Select(" 引导助理 like '%" + employeeId + "%' "); System.Data.DataRow[] EarlyRepairNameList = gridDt.Select(" 初修师 like '%" + employeeId + "%' "); System.Data.DataRow[] RefinementNameList = gridDt.Select(" 精修师 like '%" + employeeId + "%' "); System.Data.DataRow[] FilmSelectionNameList = gridDt.Select(" 选片师 like '%" + employeeId + "%' "); System.Data.DataRow[] DesignerNameList = gridDt.Select(" 设计师 like '%" + employeeId + "%' "); dicList.Add("摄影师", photographList.Length); dicList.Add("摄影助理", photographAssistantList.Length); dicList.Add("化妆师", MakeupArtistList.Length); dicList.Add("化妆助理", MakeupAssistantList.Length); dicList.Add("引导师", BootDivisionList.Length); dicList.Add("引导助理", BootDivisionAssistantList.Length); dicList.Add("初修师", EarlyRepairNameList.Length); dicList.Add("精修师", RefinementNameList.Length); dicList.Add("选片师", FilmSelectionNameList.Length); dicList.Add("设计师", DesignerNameList.Length); } void btn_Search_Click(object sender, EventArgs e) { //throw new NotImplementedException();+ BindDataGridRowView(); } } }