using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Globalization; using System.Linq; using System.Text; using System.Windows.Forms; namespace LYFZ.Software.MainBusiness.CameraControlBook.SmallForm { public partial class A_EmployeeScheduleSmallForm : LYFZ.Software.UI.CameraControlBook.SmallForm.A_EmployeeScheduleSmallForm { LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder(); public A_EmployeeScheduleSmallForm() { this.Load += A_EmployeeScheduleSmallForm_Load; this.Shown += A_EmployeeScheduleSmallForm_Shown; this.btnLastWeek.Click += btnLastWeek_Click; this.btnNextWeek.Click += btnNextWeek_Click; this.btnQuery.Click += btnQuery_Click; this.btnClose.Click += btnClose_Click; this.dtpYearMonth.ClickChengedValue += dtpYearMonth_ClickChengedValue; this.dtpYearMonth.KeyDown += dtpYearMonth_KeyDown; this.chkWeekMode.Click += chkWeekMode_Click; this.cmbtreevDepartment.ComboBoxTree_NodeMouseClick += cmbtreevDepartment_ComboBoxTree_NodeMouseClick; this.dgvData.CellMouseDown += dgvData_CellMouseDown; this.dgvData.DataGridViewConMenu_ItemClicked += dgvData_DataGridViewConMenu_ItemClicked; this.dgvData.CellMouseDoubleClick += dgvData_CellMouseDoubleClick; } /// /// 分店数据 /// DataTable dtStore = new DataTable(); /// /// 部门数据 /// DataTable dtDepartment = new DataTable(); /// /// 周的开始 /// DateTime WeekStartDate; /// /// 周的结束 /// DateTime WeekEndDate; /// /// 有几个影楼的权限 /// int StoreNameCount = 0; /// /// 窗体加载事件 /// /// /// void A_EmployeeScheduleSmallForm_Load(object sender, EventArgs e) { dtStore = orbll.GetView_Custom("tb_ErpCompanyInfo", StrWhere: "", ShowColumnName: "Company_DividedShop,Company_Name").Tables[0]; dtStore.PrimaryKey = new DataColumn[] { dtStore.Columns["Company_DividedShop"] }; dtDepartment = orbll.GetView_Custom("tb_ErpDepartment", StrWhere: "", ShowColumnName: "ID,Dt_Name").Tables[0]; dtDepartment.PrimaryKey = new DataColumn[] { dtDepartment.Columns["ID"] }; } /// /// 人员绑定 /// void PublicPerson() { this.cmbtreevDepartment.Nodes.Clear(); DataTable dtStoreName = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindGroupStoreName("pb002", StrGroupKeyCode: "st064"); DataTable dtDepartment = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.Tbl_Department; DataTable dtUser = LYFZ.Software.MainBusiness.DoorCityProcess.PublicGetVersionDataTable.GetUserTable(IsShowResign: false, IsShowAdmin: false); this.StoreNameCount = dtStoreName.Rows.Count; for (int k = 0; k < dtStoreName.Rows.Count; k++) { TreeNode rootStore = null; if (dtStoreName.Rows.Count == 1 && k == 0) { TreeNode rootNull = new TreeNode(); rootNull.Text = " "; rootNull.Tag = ""; rootNull.Name = ""; this.cmbtreevDepartment.Nodes.Add(rootNull); } else { rootStore = new TreeNode(); rootStore.Text = dtStoreName.Rows[k]["Company_Name"].ToString().Trim(); rootStore.Tag = dtStoreName.Rows[k]["Company_DividedShop"].ToString().Trim(); rootStore.Name = "StoreName"; } for (int i = 0; i < dtDepartment.Rows.Count; i++) { DataRow[] dtRow = dtUser.Select("User_Department='" + dtDepartment.Rows[i]["ID"].ToString().Trim() + "' And User_DividedShop = '" + dtStoreName.Rows[k]["Company_DividedShop"].ToString().Trim() + "'"); if (dtRow.Length <= 0) { continue; } TreeNode nodes = new TreeNode(); nodes.Text = dtDepartment.Rows[i]["Dt_Name"].ToString(); nodes.Tag = dtDepartment.Rows[i]["ID"].ToString().Trim(); nodes.Name = "Department"; TreeNode node; for (int j = 0; j < dtRow.Length; j++) { node = new TreeNode(); node.Text = dtRow[j]["User_Name"].ToString(); node.Tag = dtRow[j]["User_EmployeeID"].ToString(); node.Name = "User"; nodes.Nodes.Add(node); } if (rootStore == null) { this.cmbtreevDepartment.TreeView.Nodes.Add(nodes); } else { rootStore.Nodes.Add(nodes); } } if (rootStore != null) { this.cmbtreevDepartment.TreeView.Nodes.Add(rootStore); } } this.cmbtreevDepartment.Nodes[0].Expand(); this.cmbtreevDepartment.TextFindTag(this.cmbtreevDepartment.Nodes[0].Text.Trim()); //this.cmbtreevDepartment.SelectedNode = this.cmbtreevDepartment.GetNodeItem_TextToTag(this.cmbtreevDepartment.Nodes[0].Text.Trim()); } /// /// 窗体加载事件 /// /// /// void A_EmployeeScheduleSmallForm_Shown(object sender, EventArgs e) { this.dtpYearMonth.StrDateValue = SDateTime.Now.ToString("yyyy-MM"); this.PublicPerson(); this.chkWeekMode_Click(null, null); bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion( LYFZ.Software.MainBusiness.VersionControl.VersionFunctionEnum.员工考勤员工档期); if (!b) { this.Close(); } } /// /// 上星期 /// /// /// void btnLastWeek_Click(object sender, EventArgs e) { this.WeekStartDate = this.WeekStartDate.AddDays(-7); this.WeekEndDate = this.WeekEndDate.AddDays(-7); this.lblWhichWeek.Text = "第" + new GregorianCalendar().GetWeekOfYear(this.WeekStartDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday) + "周"; this.PublicFunctionRows1(); } /// /// 下星期 /// /// /// void btnNextWeek_Click(object sender, EventArgs e) { this.WeekStartDate = this.WeekStartDate.AddDays(7); this.WeekEndDate = this.WeekEndDate.AddDays(7); this.lblWhichWeek.Text = "第" + new GregorianCalendar().GetWeekOfYear(this.WeekStartDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday) + "周"; this.PublicFunctionRows1(); } /// /// 查询 /// /// /// void btnQuery_Click(object sender, EventArgs e) { if (this.chkWeekMode.Checked == true) { PublicFunctionRows1(); } else { PublicFunctionRows(); } } /// /// 关闭 /// /// /// void btnClose_Click(object sender, EventArgs e) { this.Close(); } /// /// 选择Value值更改事件 /// /// void dtpYearMonth_ClickChengedValue(string SelectValue) { PublicFunctionRows(); } /// /// 回车事件 /// void dtpYearMonth_KeyDown() { PublicFunctionRows(); } /// /// 周月选择 /// /// /// void chkWeekMode_Click(object sender, EventArgs e) { if (this.chkWeekMode.Checked == true) { this.panelLastNextWeek.Visible = true; this.dtpYearMonth.Visible = false; this.lblWhichWeek.Visible = true; this.WeekStartDate = DateTime.Now.AddDays((-1) * Convert.ToInt32(DateTime.Now.DayOfWeek)); this.WeekEndDate = WeekStartDate.AddDays(6); this.lblWhichWeek.Text = "第" + new GregorianCalendar().GetWeekOfYear(WeekStartDate, CalendarWeekRule.FirstDay, DayOfWeek.Monday) + "周"; this.PublicFunctionRows1(); } else { this.panelLastNextWeek.Visible = false; this.dtpYearMonth.Visible = true; this.lblWhichWeek.Visible = false; this.PublicFunctionRows(); } } /// /// 部门下拉框 /// /// /// void cmbtreevDepartment_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { //this.btnQuery_Click(this, null); } /// /// 右键弹出菜单 /// /// /// void dgvData_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right) { ToolStripMenuItem item = null; if (e.ColumnIndex != this.dgvData.Columns["影楼名称"].Index && e.ColumnIndex != this.dgvData.Columns["部门"].Index && e.ColumnIndex != this.dgvData.Columns["姓名"].Index) { if (this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Trim() != "休息!") { this.dgvData.conMenu.Items.Clear(); item = new ToolStripMenuItem(); item.Height = item.Height * 2; item.Text = "安排拍照\r\n"; item.Tag = "0"; this.dgvData.conMenu.Items.Add(item); item = new ToolStripMenuItem(); item.Height = item.Height * 2; item.Text = "安排选片\r\n"; item.Tag = "1"; this.dgvData.conMenu.Items.Add(item); item = new ToolStripMenuItem(); item.Height = item.Height * 2; item.Text = "安排看设计\r\n"; item.Tag = "2"; this.dgvData.conMenu.Items.Add(item); item = new ToolStripMenuItem(); item.Height = item.Height * 2; item.Text = "安排取件\r\n"; item.Tag = "3"; this.dgvData.conMenu.Items.Add(item); item = new ToolStripMenuItem(); item.Height = item.Height * 2; item.Text = "安排服务\r\n"; item.Tag = "4"; this.dgvData.conMenu.Items.Add(item); item = new ToolStripMenuItem(); item.Height = item.Height * 2; item.Text = "安排选礼服\r\n"; item.Tag = "5"; this.dgvData.conMenu.Items.Add(item); } } } } /// /// 右键菜单选择项事件 /// /// /// void dgvData_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { ToolStripItem item = e.ClickedItem; if (LYFZ.Software.MainBusiness.CameraControlBook.PublicClass.LoadForm(item.Tag.ToString().Trim())) { this.btnQuery_Click(this, null); } } /// /// 单元格双击事件 /// /// /// void dgvData_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { if (e.ColumnIndex >= 4) { if (string.IsNullOrEmpty(this.dgvData.CurrentCell.Value.ToString().Trim())) { MessageBoxCustom.Show("该员工当前尚未安排!"); return; } if (this.dgvData.CurrentCell.Value.ToString().Trim() == "休息!") { MessageBoxCustom.Show("该员工当天休息!"); return; } Hashtable htData = (Hashtable)this.dgvData.CurrentCell.Tag; LYFZ.Software.MainBusiness.TimeAndAttendance.A_EmployeeScheduleSmallFlighting frm = new TimeAndAttendance.A_EmployeeScheduleSmallFlighting(); frm.StrJobsID = htData["StrJobsID"].ToString().Trim(); frm.StrJobsText = htData["StrJobsText"].ToString().Trim(); frm.StrDateTime = htData["StrDateDay"].ToString().Trim(); frm.StrShowText = dgvData.CurrentRow.Cells[1].Value.ToString() + "" + dgvData.CurrentRow.Cells[2].Value.ToString() + " " + dgvData.CurrentRow.Cells[3].Value.ToString(); frm.Show(); } } } /// /// 获取查询条件 /// /// 查询条件 /// Hashtable GetSelectQueryWhere(ref string StrWherePerson) { Hashtable htData = new Hashtable(); if (this.cmbtreevDepartment.StrGetName.Trim() == "User") { StrWherePerson += " And 员工编号 = '" + this.cmbtreevDepartment.Tag.ToString().Trim() + "'"; DataRow dtRow = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(this.cmbtreevDepartment.Tag.ToString().Trim()); if (dtRow != null) { htData[dtRow["User_EmployeeID"].ToString().Trim() + "|" + dtRow["User_Name"].ToString().Trim() + "|" + dtStore.Rows.Find(dtRow["User_DividedShop"].ToString().Trim())["Company_Name"].ToString().Trim()] = this.cmbtreevDepartment.SelectedNode.Parent.Text.Trim(); } } else if (this.cmbtreevDepartment.StrGetName.Trim() == "Department") { string StrPerson = ""; for (int i = 0; i < this.cmbtreevDepartment.SelectedNode.Nodes.Count; i++) { StrPerson += "'" + this.cmbtreevDepartment.SelectedNode.Nodes[i].Tag.ToString().Trim() + "',"; DataRow dtRow = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(this.cmbtreevDepartment.SelectedNode.Nodes[i].Tag.ToString().Trim()); if (dtRow != null) { htData[dtRow["User_EmployeeID"].ToString().Trim() + "|" + dtRow["User_Name"].ToString().Trim() + "|" + dtStore.Rows.Find(dtRow["User_DividedShop"].ToString().Trim())["Company_Name"].ToString().Trim()] = this.cmbtreevDepartment.SelectedNode.Text.Trim(); } } if (!string.IsNullOrEmpty(StrPerson)) { StrWherePerson += " And 员工编号 in (" + StrPerson.TrimEnd(',') + ")"; } } else if (this.cmbtreevDepartment.StrGetName.Trim() == "StoreName") { string StrPerson = ""; for (int i = 0; i < this.cmbtreevDepartment.SelectedNode.Nodes.Count; i++) { if (this.cmbtreevDepartment.SelectedNode.Nodes[i].Name.Trim() == "Department") { for (int j = 0; j < this.cmbtreevDepartment.SelectedNode.Nodes[i].Nodes.Count; j++) { if (this.cmbtreevDepartment.SelectedNode.Nodes[i].Nodes[j].Name.Trim() == "User") { StrPerson += "'" + this.cmbtreevDepartment.SelectedNode.Nodes[i].Nodes[j].Tag.ToString().Trim() + "',"; DataRow dtRow = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(this.cmbtreevDepartment.SelectedNode.Nodes[i].Nodes[j].Tag.ToString().Trim()); if (dtRow != null) { htData[dtRow["User_EmployeeID"].ToString().Trim() + "|" + dtRow["User_Name"].ToString().Trim() + "|" + dtStore.Rows.Find(dtRow["User_DividedShop"].ToString().Trim())["Company_Name"].ToString().Trim()] = this.cmbtreevDepartment.SelectedNode.Nodes[i].Text.Trim(); } } } } } if (!string.IsNullOrEmpty(StrPerson)) { StrWherePerson += " And 员工编号 in (" + StrPerson.TrimEnd(',') + ")"; } } else { DataRow[] dtRows = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Select("User_Status <> '离职'"); string StrPerson = ""; for (int i = 0; i < dtRows.Length; i++) { StrPerson += "'" + dtRows[i]["User_EmployeeID"].ToString().Trim() + "',"; DataRow dtRow = dtDepartment.Rows.Find(dtRows[i]["User_Department"].ToString().Trim()); if (dtRow != null) { htData[dtRows[i]["User_EmployeeID"].ToString().Trim() + "|" + dtRows[i]["User_Name"].ToString().Trim() + "|" + dtStore.Rows.Find(dtRows[i]["User_DividedShop"].ToString().Trim())["Company_Name"].ToString().Trim()] = dtRow["Dt_Name"].ToString().Trim(); } } if (!string.IsNullOrEmpty(StrPerson)) { StrWherePerson += " And 员工编号 in (" + StrPerson.TrimEnd(',') + ")"; } } return htData; } /// /// 获取工作数据 /// /// /// /// DataSet GetDataSetData(string StrWherePerson, string StrWhere2) { string GetColumn = "员工姓名,员工编号,工作时间,ID"; DataSet dtSet = new DataSet(); LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker) { string ExecuteSql = orbll.GetView_CustomReturnExecuteSql("BView_MyWorkClothing_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkMakeupArtist_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkMakeupAssistant_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkPhotographyName_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkPhotographyAssistant_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkBootDivision_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkEarlyRepairName_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkFilmSelection_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkRefinement_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkDesigner_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkLookDesign_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkPickup_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkService_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("BView_MyWorkSendPhoto_No", StrWhere: StrWherePerson, ShowColumnName: GetColumn); ExecuteSql += ";" + orbll.GetView_CustomReturnExecuteSql("loninbansets", StrWhere: StrWhere2, ShowColumnName: "User_ID,Time,fixed"); dtSet = orbll.GetView_Custom(ExecuteSql); }); return dtSet; } /// /// 周查询 /// void PublicFunctionRows1() { this.dgvData.Rows.Clear(); DateTime CurrentDateValue = Convert.ToDateTime(LYFZ.Command.Command_Validate.DateTimeToString(WeekStartDate, "yyyy-MM-dd")); string StrWherePerson = "(工作时间查询 between '" + LYFZ.Command.Command_Validate.DateTimeToString(CurrentDateValue, "yyyy-MM-dd HH:mm:ss") + "' and '" + LYFZ.Command.Command_Validate.DateTimeToString(WeekEndDate, "yyyy-MM-dd HH:mm:ss") + "')"; string StrWhere2 = "(Time between '" + LYFZ.Command.Command_Validate.DateTimeToString(CurrentDateValue, "yyyy-MM-dd HH:mm:ss") + "' and '" + LYFZ.Command.Command_Validate.DateTimeToString(WeekEndDate, "yyyy-MM-dd HH:mm:ss") + "')"; Hashtable htData = this.GetSelectQueryWhere(ref StrWherePerson); DataSet dtSet = this.GetDataSetData(StrWherePerson, StrWhere2); DataTable newTable = new DataTable(); newTable.Columns.Add("员工编号", typeof(string)); newTable.Columns.Add("影楼名称", typeof(string)); newTable.Columns.Add("部门", typeof(string)); newTable.Columns.Add("姓名", typeof(string)); for (int i = 1; i < 8; i++) { newTable.Columns.Add(i + "日", typeof(object)); } foreach (DictionaryEntry items in htData) { string[] StrArray = items.Key.ToString().Trim().Split('|'); DataRow newRow = newTable.NewRow(); newRow["员工编号"] = StrArray[0].Trim(); newRow["影楼名称"] = StrArray[2].Trim(); newRow["部门"] = items.Value.ToString().Trim(); newRow["姓名"] = StrArray[1].Trim(); #region 获取日期数据 for (int i = 0; i < 7; i++) { string StrDateDay = LYFZ.Command.Command_Validate.DateTimeToString(WeekStartDate.AddDays(i)); DataRow[] dtRows = dtSet.Tables[14].Select("User_ID = '" + StrArray[0].Trim() + "' and Time = '" + StrDateDay + "'"); string StrShowText = ""; string StrToolTipText = ""; string StrJobsID = ""; string StrJobsText = ""; if (dtRows.Length > 0) { if (dtRows[0]["fixed"].ToString().Trim() == "休息") { StrShowText = "休息!"; } } if (string.IsNullOrEmpty(StrShowText)) { string StrdtRowWhere = "员工编号 = '" + StrArray[0].Trim() + "' and 工作时间 = '" + StrDateDay + "'"; DataRow[] dtRow0 = dtSet.Tables[0].Select(StrdtRowWhere); DataRow[] dtRow1 = dtSet.Tables[1].Select(StrdtRowWhere); DataRow[] dtRow2 = dtSet.Tables[2].Select(StrdtRowWhere); DataRow[] dtRow3 = dtSet.Tables[3].Select(StrdtRowWhere); DataRow[] dtRow4 = dtSet.Tables[4].Select(StrdtRowWhere); DataRow[] dtRow5 = dtSet.Tables[5].Select(StrdtRowWhere); DataRow[] dtRow6 = dtSet.Tables[6].Select(StrdtRowWhere); DataRow[] dtRow7 = dtSet.Tables[7].Select(StrdtRowWhere); DataRow[] dtRow8 = dtSet.Tables[8].Select(StrdtRowWhere); DataRow[] dtRow9 = dtSet.Tables[9].Select(StrdtRowWhere); DataRow[] dtRow10 = dtSet.Tables[10].Select(StrdtRowWhere); DataRow[] dtRow11 = dtSet.Tables[11].Select(StrdtRowWhere); DataRow[] dtRow12 = dtSet.Tables[12].Select(StrdtRowWhere); DataRow[] dtRow13 = dtSet.Tables[13].Select(StrdtRowWhere); int GroupCount = 0; if (dtRow0.Length > 0) { GroupCount += dtRow0.Length; StrToolTipText += "选衣:" + dtRow0.Length + "组\r\n"; for (int y = 0; y < dtRow0.Length; y++) { StrJobsID += dtRow0[y][3].ToString().Trim() + ","; StrJobsText += "选衣,"; } } if (dtRow1.Length > 0) { GroupCount += dtRow1.Length; StrToolTipText += "化妆师:" + dtRow1.Length + "组\r\n"; for (int y = 0; y < dtRow1.Length; y++) { StrJobsID += dtRow1[y][3].ToString().Trim() + ","; StrJobsText += "化妆师,"; } } if (dtRow2.Length > 0) { GroupCount += dtRow2.Length; StrToolTipText += "化妆助理:" + dtRow2.Length + "组\r\n"; for (int y = 0; y < dtRow2.Length; y++) { StrJobsID += dtRow2[y][3].ToString().Trim() + ","; StrJobsText += "化妆助理,"; } } if (dtRow3.Length > 0) { GroupCount += dtRow3.Length; StrToolTipText += "摄影师:" + dtRow3.Length + "组\r\n"; for (int y = 0; y < dtRow3.Length; y++) { StrJobsID += dtRow3[y][3].ToString().Trim() + ","; StrJobsText += "摄影师,"; } } if (dtRow4.Length > 0) { GroupCount += dtRow4.Length; StrToolTipText += "摄影助理:" + dtRow4.Length + "组\r\n"; for (int y = 0; y < dtRow4.Length; y++) { StrJobsID += dtRow4[y][3].ToString().Trim() + ","; StrJobsText += "摄影助理,"; } } if (dtRow5.Length > 0) { GroupCount += dtRow5.Length; StrToolTipText += "引导:" + dtRow5.Length + "组\r\n"; for (int y = 0; y < dtRow5.Length; y++) { StrJobsID += dtRow5[y][3].ToString().Trim() + ","; StrJobsText += "引导,"; } } if (dtRow6.Length > 0) { GroupCount += dtRow6.Length; StrToolTipText += "初修:" + dtRow6.Length + "组\r\n"; for (int y = 0; y < dtRow6.Length; y++) { StrJobsID += dtRow6[y][3].ToString().Trim() + ","; StrJobsText += "初修,"; } } if (dtRow7.Length > 0) { GroupCount += dtRow7.Length; StrToolTipText += "选片:" + dtRow7.Length + "组\r\n"; for (int y = 0; y < dtRow7.Length; y++) { StrJobsID += dtRow7[y][3].ToString().Trim() + ","; StrJobsText += "选片,"; } } if (dtRow8.Length > 0) { GroupCount += dtRow8.Length; StrToolTipText += "精修:" + dtRow8.Length + "组\r\n"; for (int y = 0; y < dtRow8.Length; y++) { StrJobsID += dtRow8[y][3].ToString().Trim() + ","; StrJobsText += "精修,"; } } if (dtRow9.Length > 0) { GroupCount += dtRow9.Length; StrToolTipText += "设计:" + dtRow9.Length + "组\r\n"; for (int y = 0; y < dtRow9.Length; y++) { StrJobsID += dtRow9[y][3].ToString().Trim() + ","; StrJobsText += "设计,"; } } if (dtRow10.Length > 0) { GroupCount += dtRow10.Length; StrToolTipText += "看设计:" + dtRow10.Length + "组\r\n"; for (int y = 0; y < dtRow10.Length; y++) { StrJobsID += dtRow10[y][3].ToString().Trim() + ","; StrJobsText += "看设计,"; } } if (dtRow11.Length > 0) { GroupCount += dtRow11.Length; StrToolTipText += "取件:" + dtRow11.Length + "组\r\n"; for (int y = 0; y < dtRow11.Length; y++) { StrJobsID += dtRow11[y][3].ToString().Trim() + ","; StrJobsText += "取件,"; } } if (dtRow12.Length > 0) { GroupCount += dtRow12.Length; StrToolTipText += "服务:" + dtRow12.Length + "组\r\n"; for (int y = 0; y < dtRow12.Length; y++) { StrJobsID += dtRow12[y][3].ToString().Trim() + ","; StrJobsText += "服务,"; } } if (dtRow13.Length > 0) { GroupCount += dtRow13.Length; StrToolTipText += "发片:" + dtRow13.Length + "组\r\n"; for (int y = 0; y < dtRow13.Length; y++) { StrJobsID += dtRow13[y][3].ToString().Trim() + ","; StrJobsText += "发片,"; } } if (GroupCount > 0) { StrShowText = GroupCount + "组"; } } Hashtable htdataDay = new Hashtable(); htdataDay["StrShowText"] = StrShowText.TrimEnd(','); htdataDay["StrToolTipText"] = StrToolTipText.TrimEnd(','); htdataDay["StrDateDay"] = StrDateDay.TrimEnd(','); htdataDay["StrJobsID"] = StrJobsID.TrimEnd(','); htdataDay["StrJobsText"] = StrJobsText.TrimEnd(','); newRow[(i + 1) + "日"] = htdataDay; } #endregion newTable.Rows.Add(newRow); } string strColumn = "员工编号,影楼名称,部门,姓名"; for (int i = 0; i < 7; i++) { strColumn += "," + this.WeekStartDate.AddDays(i).ToString("dddd") + "\r\n" + this.WeekStartDate.AddDays(i).ToString("MM月dd日") + ""; } string strHideField = "员工编号"; if (this.StoreNameCount <= 1) { strHideField += ",影楼名称"; } this.dgvData.DataColumns(strColumn, strHideField: strHideField); this.dgvData.dgvColumnHeadersHeight = 45; this.dgvData.Columns["姓名"].Frozen = true; int IntdgvDataColumnsCount = this.dgvData.Columns.GetColumnCount(DataGridViewElementStates.Visible); int intThisWidth = this.dgvData.Width - 50; if (this.StoreNameCount <= 1) { IntdgvDataColumnsCount--; intThisWidth -= 150; } int intdgvDataWidth = intThisWidth / IntdgvDataColumnsCount; for (int i = 0; i < this.dgvData.Columns.Count; i++) { if (this.dgvData.Columns[i].Name.Trim() == "影楼名称") { this.dgvData.Columns[i].Width = 150; } else { this.dgvData.Columns[i].Width = intdgvDataWidth; } } DataGridViewRow dgvr = null; DataGridViewCell cell = null; for (int i = 0; i < newTable.Rows.Count; i++) { dgvr = new DataGridViewRow(); for (int j = 0; j < newTable.Columns.Count; j++) { if (j > 3) { Hashtable htDataRow = (Hashtable)newTable.Rows[i][j]; cell = new DataGridViewTextBoxCell(); cell.Value = htDataRow["StrShowText"].ToString().Trim(); cell.ToolTipText = htDataRow["StrToolTipText"].ToString().Trim(); cell.Tag = htDataRow; dgvr.Cells.Add(cell); } else { cell = new DataGridViewTextBoxCell(); cell.Value = newTable.Rows[i][j].ToString().Trim(); dgvr.Cells.Add(cell); } } this.dgvData.Rows.Add(dgvr); } } /// /// 月查询 /// void PublicFunctionRows() { this.dgvData.Rows.Clear(); int intDayCount = System.Threading.Thread.CurrentThread.CurrentUICulture.Calendar.GetDaysInMonth(this.dtpYearMonth.StrYear, this.dtpYearMonth.StrMonth); string StrYearMonnth = this.dtpYearMonth.StrDateValue.Trim(); DateTime CurrentDateValue = Convert.ToDateTime(StrYearMonnth + "-01"); string StrWherePerson = "(工作时间查询 between '" + CurrentDateValue.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + CurrentDateValue.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") + "')"; string StrWhere2 = "(Time between '" + CurrentDateValue.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + CurrentDateValue.AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd HH:mm:ss") + "')"; Hashtable htData = this.GetSelectQueryWhere(ref StrWherePerson); DataSet dtSet = this.GetDataSetData(StrWherePerson, StrWhere2); DataTable newTable = new DataTable(); newTable.Columns.Add("员工编号", typeof(string)); newTable.Columns.Add("影楼名称", typeof(string)); newTable.Columns.Add("部门", typeof(string)); newTable.Columns.Add("姓名", typeof(string)); for (int i = 1; i <= intDayCount; i++) { newTable.Columns.Add(i + "日", typeof(object)); } foreach (DictionaryEntry items in htData) { string[] StrArray = items.Key.ToString().Trim().Split('|'); DataRow newRow = newTable.NewRow(); newRow["员工编号"] = StrArray[0].Trim(); newRow["影楼名称"] = StrArray[2].Trim(); newRow["部门"] = items.Value.ToString().Trim(); newRow["姓名"] = StrArray[1].Trim(); #region 获取日期数据 for (int i = 0; i < intDayCount; i++) { string StrDateDay = StrYearMonnth + "-" + (i + 1).ToString("d2"); DataRow[] dtRows = dtSet.Tables[14].Select("User_ID = '" + StrArray[0].Trim() + "' and Time = '" + StrDateDay + "'"); string StrShowText = ""; string StrToolTipText = ""; string StrJobsID = ""; string StrJobsText = ""; if (dtRows.Length > 0) { if (dtRows[0]["fixed"].ToString().Trim() == "休息") { StrShowText = "休息!"; } } if (string.IsNullOrEmpty(StrShowText)) { string StrdtRowWhere = "员工编号 = '" + StrArray[0].Trim() + "' and 工作时间 = '" + StrDateDay + "'"; DataRow[] dtRow0 = dtSet.Tables[0].Select(StrdtRowWhere); DataRow[] dtRow1 = dtSet.Tables[1].Select(StrdtRowWhere); DataRow[] dtRow2 = dtSet.Tables[2].Select(StrdtRowWhere); DataRow[] dtRow3 = dtSet.Tables[3].Select(StrdtRowWhere); DataRow[] dtRow4 = dtSet.Tables[4].Select(StrdtRowWhere); DataRow[] dtRow5 = dtSet.Tables[5].Select(StrdtRowWhere); DataRow[] dtRow6 = dtSet.Tables[6].Select(StrdtRowWhere); DataRow[] dtRow7 = dtSet.Tables[7].Select(StrdtRowWhere); DataRow[] dtRow8 = dtSet.Tables[8].Select(StrdtRowWhere); DataRow[] dtRow9 = dtSet.Tables[9].Select(StrdtRowWhere); DataRow[] dtRow10 = dtSet.Tables[10].Select(StrdtRowWhere); DataRow[] dtRow11 = dtSet.Tables[11].Select(StrdtRowWhere); DataRow[] dtRow12 = dtSet.Tables[12].Select(StrdtRowWhere); DataRow[] dtRow13 = dtSet.Tables[13].Select(StrdtRowWhere); int GroupCount = 0; if (dtRow0.Length > 0) { GroupCount += dtRow0.Length; StrToolTipText += "选衣:" + dtRow0.Length + "组\r\n"; for (int y = 0; y < dtRow0.Length; y++) { StrJobsID += dtRow0[y][3].ToString().Trim() + ","; StrJobsText += "选衣,"; } } if (dtRow1.Length > 0) { GroupCount += dtRow1.Length; StrToolTipText += "化妆师:" + dtRow1.Length + "组\r\n"; for (int y = 0; y < dtRow1.Length; y++) { StrJobsID += dtRow1[y][3].ToString().Trim() + ","; StrJobsText += "化妆师,"; } } if (dtRow2.Length > 0) { GroupCount += dtRow2.Length; StrToolTipText += "化妆助理:" + dtRow2.Length + "组\r\n"; for (int y = 0; y < dtRow2.Length; y++) { StrJobsID += dtRow2[y][3].ToString().Trim() + ","; StrJobsText += "化妆助理,"; } } if (dtRow3.Length > 0) { GroupCount += dtRow3.Length; StrToolTipText += "摄影师:" + dtRow3.Length + "组\r\n"; for (int y = 0; y < dtRow3.Length; y++) { StrJobsID += dtRow3[y][3].ToString().Trim() + ","; StrJobsText += "摄影师,"; } } if (dtRow4.Length > 0) { GroupCount += dtRow4.Length; StrToolTipText += "摄影助理:" + dtRow4.Length + "组\r\n"; for (int y = 0; y < dtRow4.Length; y++) { StrJobsID += dtRow4[y][3].ToString().Trim() + ","; StrJobsText += "摄影助理,"; } } if (dtRow5.Length > 0) { GroupCount += dtRow5.Length; StrToolTipText += "引导:" + dtRow5.Length + "组\r\n"; for (int y = 0; y < dtRow5.Length; y++) { StrJobsID += dtRow5[y][3].ToString().Trim() + ","; StrJobsText += "引导,"; } } if (dtRow6.Length > 0) { GroupCount += dtRow6.Length; StrToolTipText += "初修:" + dtRow6.Length + "组\r\n"; for (int y = 0; y < dtRow6.Length; y++) { StrJobsID += dtRow6[y][3].ToString().Trim() + ","; StrJobsText += "初修,"; } } if (dtRow7.Length > 0) { GroupCount += dtRow7.Length; StrToolTipText += "选片:" + dtRow7.Length + "组\r\n"; for (int y = 0; y < dtRow7.Length; y++) { StrJobsID += dtRow7[y][3].ToString().Trim() + ","; StrJobsText += "选片,"; } } if (dtRow8.Length > 0) { GroupCount += dtRow8.Length; StrToolTipText += "精修:" + dtRow8.Length + "组\r\n"; for (int y = 0; y < dtRow8.Length; y++) { StrJobsID += dtRow8[y][3].ToString().Trim() + ","; StrJobsText += "精修,"; } } if (dtRow9.Length > 0) { GroupCount += dtRow9.Length; StrToolTipText += "设计:" + dtRow9.Length + "组\r\n"; for (int y = 0; y < dtRow9.Length; y++) { StrJobsID += dtRow9[y][3].ToString().Trim() + ","; StrJobsText += "设计,"; } } if (dtRow10.Length > 0) { GroupCount += dtRow10.Length; StrToolTipText += "看设计:" + dtRow10.Length + "组\r\n"; for (int y = 0; y < dtRow10.Length; y++) { StrJobsID += dtRow10[y][3].ToString().Trim() + ","; StrJobsText += "看设计,"; } } if (dtRow11.Length > 0) { GroupCount += dtRow11.Length; StrToolTipText += "取件:" + dtRow11.Length + "组\r\n"; for (int y = 0; y < dtRow11.Length; y++) { StrJobsID += dtRow11[y][3].ToString().Trim() + ","; StrJobsText += "取件,"; } } if (dtRow12.Length > 0) { GroupCount += dtRow12.Length; StrToolTipText += "服务:" + dtRow12.Length + "组\r\n"; for (int y = 0; y < dtRow12.Length; y++) { StrJobsID += dtRow12[y][3].ToString().Trim() + ","; StrJobsText += "服务,"; } } if (dtRow13.Length > 0) { GroupCount += dtRow13.Length; StrToolTipText += "发片:" + dtRow13.Length + "组\r\n"; for (int y = 0; y < dtRow13.Length; y++) { StrJobsID += dtRow13[y][3].ToString().Trim() + ","; StrJobsText += "发片,"; } } if (GroupCount > 0) { StrShowText = GroupCount + "组"; } } Hashtable htdataDay = new Hashtable(); htdataDay["StrShowText"] = StrShowText.TrimEnd(','); htdataDay["StrToolTipText"] = StrToolTipText.TrimEnd(','); htdataDay["StrDateDay"] = StrDateDay.TrimEnd(','); htdataDay["StrJobsID"] = StrJobsID.TrimEnd(','); htdataDay["StrJobsText"] = StrJobsText.TrimEnd(','); newRow[(i + 1) + "日"] = htdataDay; } #endregion newTable.Rows.Add(newRow); } this.dgvData.Columns.Clear(); string strColumn = "员工编号,影楼名称,部门,姓名"; for (int i = 1; i <= intDayCount; i++) { strColumn += "," + i.ToString() + "日\r\n" + Convert.ToDateTime(CurrentDateValue).AddDays(i - 1).ToString("dddd"); } string strHideField = "员工编号"; if (this.StoreNameCount <= 1) { strHideField += ",影楼名称"; } this.dgvData.DataColumns(strColumn, strHideField: strHideField); this.dgvData.dgvColumnHeadersHeight = 45; this.dgvData.Columns["姓名"].Frozen = true; for (int i = 0; i < this.dgvData.Columns.Count; i++) { switch (this.dgvData.Columns[i].Name.Trim()) { case "影楼名称": this.dgvData.Columns[i].Width = 150; break; case "姓名": case "部门": this.dgvData.Columns[i].Width = 80; break; default: this.dgvData.Columns[i].Width = 60; break; } } DataGridViewRow dgvr = null; DataGridViewCell cell = null; for (int i = 0; i < newTable.Rows.Count; i++) { dgvr = new DataGridViewRow(); for (int j = 0; j < newTable.Columns.Count; j++) { if (j > 3) { Hashtable htDataRow = (Hashtable)newTable.Rows[i][j]; cell = new DataGridViewTextBoxCell(); cell.Value = htDataRow["StrShowText"].ToString().Trim(); cell.ToolTipText = htDataRow["StrToolTipText"].ToString().Trim(); cell.Tag = htDataRow; dgvr.Cells.Add(cell); } else { cell = new DataGridViewTextBoxCell(); cell.Value = newTable.Rows[i][j].ToString().Trim(); dgvr.Cells.Add(cell); } } this.dgvData.Rows.Add(dgvr); } } } }