/// <summary> /// 窗体初始化处理 /// </summary> public override void SetFormValue() { try { dtCallDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); dtSetDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); txtMemo.Properties.ReadOnly = false; txtMemo.Enabled = true; //离职类型 SysParam.m_daoCommon.SetLoopUpEdit(TableNames.Attend_LeaveType, this.cboLeaveType, true, EnumDefine.DefalutItemAllNo, EnumDefine.DefalutItemAllText); //离职原因 SysParam.m_daoCommon.SetLoopUpEdit("Attend_LeaveReason", this.comboBoxEditReason, true, EnumDefine.DefalutItemAllNo, EnumDefine.DefalutItemAllText); } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("画面初始化失败!" + ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 窗体初始化处理 /// </summary> public override void SetFormValue() { try { //申请事由 string str = string.Format(@"select * from P_OTApply "); m_tblOTApply = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str); lookUpEditOTApply.Properties.DataSource = m_tblOTApply; lookUpEditOTApply.Properties.ValueMember = "ID"; lookUpEditOTApply.Properties.DisplayMember = "OTApply"; SysParam.m_daoCommon.SetLoopUpEdit(TableNames.P_OTType, lookOTKind, true, EnumDefine.DefalutItemAllNo, EnumDefine.DefalutItemAllText); dtStartTime.Text = DateTime.Now.ToString("yyyy-MM-dd");// HH:mm dtEndTime2.Text = DateTime.Now.ToString("HH:mm");//yyyy-MM-dd dtEndTime.Text = DateTime.Now.ToString("HH:mm");//yyyy-MM-dd } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("画面初始化失败!"); FrmDialog.ShowDialog(); } }
/// <summary> /// 离职登记 /// </summary> private void btnTurnover_Click(object sender, EventArgs e) { //this.TopMost = false; //this.timer1.Enabled = false; frmTurnover frm = new frmTurnover(); DataTable dt_temp = new DataTable(); GetFormList(ref dt_temp); if (dt_temp.Rows.Count == 0) { FrmAttendDialog FrmDialog = new FrmAttendDialog("未选中任何人员信息!"); FrmDialog.ShowDialog(); Application.DoEvents(); return; } frm.m_tblDataList = dt_temp; frm.m_DataTime = DateTime.Parse(dateOperDate1.Text.Trim()); if (frm.ShowDialog() == DialogResult.OK) { frm.Hide(); Application.DoEvents(); //自动刷新 btnRef(); } }
/// <summary> /// 选择班种 /// </summary> private void lookTeamType_EditValueChanged(object sender, EventArgs e) { try { if (lookTeamType.EditValue.ToString() != "-1") { GetDspDataList(); } } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog( "数据加载失败!"+ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 执行存储过程(调用存储过程重新统计) /// </summary> public void SetExecuteAttendResult() { this.Cursor = Cursors.WaitCursor; Stopwatch s = new Stopwatch(); Program.logFlagStart(log, s, "执行存储过程。"); if (lookmyteamName.Text.ToString() == "" || dateOperDate1.Text.Trim() == "") { return; } //根据向别-班别查出JobForID,ProjectID,LineID,TeamID m_tblAllList = new DataTable(); string str_sql = string.Format(@"select distinct JobForID,ProjectID,LineID,TeamID from V_Produce_para where myTeamName='{0}' ", lookmyteamName.Text.Trim()); m_tblAllList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); try { SqlParameter[] paraList = new SqlParameter[7]; paraList[0] = new SqlParameter("@SetDate", SqlDbType.VarChar, 16); if (dateOperDate1.EditValue.ToString() != "") { DateTime dt = DateTime.Parse(dateOperDate1.EditValue.ToString()); paraList[0].Value = dt.ToString("yyyy-MM-dd HH:mm"); } else { paraList[0].Value = ""; } m_dicItemData.Clear(); if (m_tblAllList.Rows.Count == 1) { m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); } else { m_dicItemData["JobForID"] = "0"; m_dicItemData["ProjectID"] = "0"; m_dicItemData["LineID"] = "0"; m_dicItemData["TeamID"] = "0"; } paraList[1] = new SqlParameter("@JobForID", SqlDbType.VarChar, 10); paraList[1].Value = m_dicItemData["JobForID"].ToString(); paraList[2] = new SqlParameter("@ProjectID", SqlDbType.VarChar, 10); paraList[2].Value = m_dicItemData["ProjectID"].ToString(); paraList[3] = new SqlParameter("@LineID", SqlDbType.VarChar, 10); paraList[3].Value = m_dicItemData["LineID"].ToString(); paraList[4] = new SqlParameter("@TeamID", SqlDbType.VarChar, 10); paraList[4].Value = m_dicItemData["TeamID"].ToString(); paraList[5] = new SqlParameter("@OperID", SqlDbType.VarChar, 10); if (Common._personid.ToString() != "") { paraList[5].Value = Common._personid; } else { paraList[5].Value = "0"; } //执行存储过程1 Common.AdoConnect.Connect.SetExecuteSP("PROC_Attend_Total_Result", Common.Choose.OnlyExecSp, paraList); //GridCommon.SetTeamChangeAttendResult(paraList[0].Value.ToString(), m_dicItemData["JobForID"], m_dicItemData["ProjectID"], m_dicItemData["LineID"], m_dicItemData["TeamID"], userid, pFlag); SqlParameter[] paraListCardData = new SqlParameter[1]; paraListCardData[0] = new SqlParameter("@SetDate", SqlDbType.VarChar, 10); if (dateOperDate1.EditValue.ToString() != "") { DateTime dt = DateTime.Parse(dateOperDate1.EditValue.ToString()); paraListCardData[0].Value = dt.ToString("yyyy-MM-dd HH:mm"); } else { paraListCardData[0].Value = ""; } //执行存储过程2,打卡时间 Common.AdoConnect.Connect.SetExecuteSP("PROC_CardData_Attend_Result", Common.Choose.OnlyExecSp, paraListCardData); Program.logFlagEnd(log, s, "执行存储过程。"); ////重新取得页面数据 GetDspDataList();//考勤数据 GetDspProductList();//未定义人员数据 GetSupportList();//支援人员数据 //ThreadPool.QueueUserWorkItem(btnRefleash, "执行存储过程"); } catch (Exception ex) { log.Error(ex); FrmAttendDialog FrmDialog = new FrmAttendDialog("存储过程执行失败!" + ex); FrmDialog.ShowDialog(); } finally { this.Cursor = Cursors.Default; isEditValue = false; } }
/// <summary> /// 人员对象双击事件,查看人员免许详细 /// </summary> void m_Person_DoubleClick(object sender, EventArgs e) { //this.TopMost = false; UserPerson col = sender as UserPerson; frmLicense_RecAdd frm = new frmLicense_RecAdd(); frm.TopMost = true; frm.ScanMode = Common.DataModifyMode.upd; string str = string.Format(@" select * from V_License_Rec_i where UserID='{0}'", col.UserID); DataTable dt = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str); if (dt.Rows.Count > 0) { frm.dr = dt.Rows[0]; frm.m_isPad = "true"; frm.ShowDialog(); } else { FrmAttendDialog FrmDialog = new FrmAttendDialog("当前人员无免许信息!"); FrmDialog.ShowDialog(); } this.TopMost = true; }
/// <summary> /// 获取支援的人员 /// </summary> public void GetSupportList() { Stopwatch s = new Stopwatch(); Program.logFlagStart(log, s, "获取支援的人员"); try { this.SuspendLayout(); //this.TopMost = false; panelSupport.Controls.Clear(); //JobForID,ProjectID,LineID,TeamID //panelSupport.AutoScroll = false; string str_sql = string.Empty; if (m_tblAllList.Rows.Count == 0) { str_sql = string.Format(@"select distinct JobForID,ProjectID,LineID,TeamID from V_Produce_Para where myTeamName='{0}' order by JobForID,ProjectID,LineID,TeamID", lookmyteamName.Text.Trim()); m_tblAllList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); if (m_tblAllList.Rows.Count == 0) { panelSupport.Controls.Clear(); return; } } str_sql = string.Format(@"select distinct * from V_Attend_Support where 1=1 and AttendMemo LIKE '%支援调出%' "); if (txtSupportID.Text.Trim() != "") { str_sql += " and UserID like'%" + txtSupportID.Text.Trim() + "%'"; } str_sql += " and AttendDate=convert(varChar(10),'" + dateOperDate1.EditValue.ToString() + "',120)"; //str_sql += " order by AttendMemo ,t1.UserID ";//2015-11-23 m_tblSupportList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); //循环把人员信息放入panel Point _point;//控件坐标 int lint_Left = 0;//左边距 int lint_Top = 0;//上边距 int lint_TopCount = 0;//当前Top有几行 //if (m_tblDataList.Rows.Count == 0) return;//2015-11-23 var tmpcount = m_tblSupportList.Rows.Count; var listCL = new Control[tmpcount + 1]; panelSupport.Width = 2 * (m_Person.Width + 15); panelSupport.Height = ((tmpcount + 5) / 2) * m_Person.Height; for (int i = 0; i < tmpcount; i++) { //if (i % 2 == 0 && i != 0) //{ // lint_TopCount++; // lint_Left = 0; //} //人员信息 m_Person = new UserPerson(); m_Person.Name = ("person" + (i + 1)).ToString(); Color cl = Color.FromName(m_tblSupportList.Rows[i]["warnColor"].ToString()); m_Person.TitleName = "(支)-" + m_tblSupportList.Rows[i]["GuanweiNM"].ToString(); m_Person.lblTitle.BackColor = cl; if (m_tblSupportList.Rows[i]["AttendMemo"].ToString() == "支援调入") { //已经调入:绿色,不可选择 m_Person.GuanweiColor = GreenColor; } else { //已经调出:黄色,不可选择 m_Person.GuanweiColor = YellowColor; } m_Person.GuanweiID = m_tblSupportList.Rows[i]["GuanweiID"].ToString(); m_Person.GuanweiNM = m_tblSupportList.Rows[i]["GuanweiNM"].ToString(); m_Person.Status = m_tblSupportList.Rows[i]["StatusName"].ToString(); m_Person.StatusColor = m_tblSupportList.Rows[i]["StatusColor"].ToString(); m_Person.Time = m_tblSupportList.Rows[i]["CardTime"].ToString(); m_Person.TimeColor = m_tblSupportList.Rows[i]["CardTimeColor"].ToString(); m_Person.Remind = m_tblSupportList.Rows[i]["AttendMemo"].ToString().Substring(2, 2);//支援调入,支援调出 m_Person.JobForID = m_tblSupportList.Rows[i]["JobForID"].ToString(); m_Person.ProjectID = m_tblSupportList.Rows[i]["ProjectID"].ToString(); m_Person.LineID = m_tblSupportList.Rows[i]["LineID"].ToString(); m_Person.RemindColor = m_tblSupportList.Rows[i]["warnColor"].ToString(); m_Person.LicenseType = m_tblSupportList.Rows[i]["LicenseType"].ToString(); m_Person.LicenseColor = m_tblSupportList.Rows[i]["LicenseColor"].ToString(); m_Person.UserID = m_tblSupportList.Rows[i]["UserID"].ToString(); m_Person.UserName = m_tblSupportList.Rows[i]["UserNM"].ToString(); m_Person.Tag = "0"; m_Person.UserIdNmColor = GreenColor; m_Person.Tag = "0";//选中为1,未选中为0 m_Person.AllEventClick += new UserPerson.AllEvent(m_Person_SupportAllEventClick); m_Person.ImageUrl = GridCommon.GetUserImage(SysParam.m_daoCommon, m_tblSupportList.Rows[i]["UserID"].ToString()); //panelSupport.Controls.Add(m_Person); //lint_Top = lint_TopCount * m_Person.Height; //_point = new Point(lint_Left + 10, lint_Top + 10); //lint_Left = m_Person.Width; //m_Person.Location = _point; Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); m_Person.Visible = true; })); listCL[i] = m_Person; } //if (m_tblSupportList.Rows.Count % 2 == 0 && m_tblSupportList.Rows.Count != 0) //{ // lint_TopCount++; // lint_Left = 0; //} //人员信息 m_PersonNull = new UserPersonNull(); m_PersonNull.Name = ("person" + m_tblSupportList.Rows.Count + 1).ToString(); m_PersonNull.TitleName = "支援调出"; m_PersonNull.Tag = "0";//选中为1,未选中为0 m_PersonNull.GuanweiColor = YellowColor; m_PersonNull.UserIdNmColor = GreenColor; m_PersonNull.AllEventClick += new UserPersonNull.AllEvent(m_SupperNull_AllEventClick); m_PersonNull.ImageUrl = ""; Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); m_PersonNull.Visible = true; })); listCL[tmpcount] = m_PersonNull; //panelSupport.Controls.Add(m_PersonNull); //lint_Top = lint_TopCount * m_PersonNull.Height; //_point = new Point(lint_Left + 10, lint_Top + 5); //m_PersonNull.Location = _point; panelSupport.Controls.AddRange(listCL); this.ResumeLayout(false); this.PerformLayout(); } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("支援数据检索失败!" + ex); FrmDialog.ShowDialog(); log.Error(ex); } finally { //panelSupport.AutoScroll = true; Program.logFlagEnd(log, s, "获取支援的人员"); this.TopMost = true; } }
/// <summary> /// 获取系统中未定义人员 /// </summary> public void GetDspProductList() { Stopwatch s = new Stopwatch(); Program.logFlagStart(log, s, "获取系统中未定义人员"); try { this.SuspendLayout(); //this.TopMost = false; panelProduct.Controls.Clear(); //panelProduct.AutoScroll = false; string str_sql = ""; if (m_tblAllList.Rows.Count == 0) { str_sql = string.Format(@"select distinct JobForID,ProjectID,LineID,TeamID from V_Produce_Para where myTeamName='{0}' order by JobForID,ProjectID,LineID,TeamID", lookmyteamName.Text.Trim()); m_tblAllList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); if (m_tblAllList.Rows.Count == 0) { panelProduct.Controls.Clear(); return; } } str_sql = string.Format(@"select distinct TOP 20 UserID,UserName from V_Produce_User where JobForID ='0' and ProjectID ='0' and LineID ='0' and TeamID='0' and GuanweiID='0' and User_Status='在职' and UserID not in( select UserID from Attend_Move where PFlag=2--人员调出 group by UserID having max(StrDate)>convert(VARCHAR(16),'{0}',120) )", dateOperDate1.Text.Trim()); if (txtProductUserID.Text.Trim() != "") { str_sql += " and UserID like'%" + txtProductUserID.Text.Trim() + "%'"; } str_sql += " order by UserID"; m_tblProduceList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); Point _point;//控件坐标 int lint_Left = 0;//左边距 int lint_Top = 0;//上边距 int lint_TopCount = 0;//当前Top有几行 var tmpcount = m_tblProduceList.Rows.Count; panelProduct.Width = 2 * (m_Person.Width + 15); panelProduct.Height = ((tmpcount + 5) / 2) * m_Person.Height; Control[] tmpCl = new Control[tmpcount + 1]; for (int i = 0; i < tmpcount; i++) { //if (i % 2 == 0 && i != 0) //{ // lint_TopCount++; // lint_Left = 0; //} //人员信息 m_Person = new UserPerson(); m_Person.Name = ("person_" + (i + 1)).ToString(); m_Person.TitleName = "未定义人员"; m_Person.UserID = m_tblProduceList.Rows[i]["UserID"].ToString(); m_Person.UserName = m_tblProduceList.Rows[i]["UserName"].ToString(); m_Person.GuanweiColor = YellowColor; m_Person.UserIdNmColor = GreenColor; m_Person.Tag = "0";//选中为1,未选中为0 m_Person.AllEventClick += new UserPerson.AllEvent(m_Person_ProductAllEventClick); m_Person.ImageUrl = GridCommon.GetUserImage(SysParam.m_daoCommon, m_tblProduceList.Rows[i]["UserID"].ToString()); tmpCl[i] = m_Person; //panelProduct.Controls.Add(m_Person); //lint_Top = lint_TopCount * m_Person.Height; //_point = new Point(lint_Left + 10, lint_Top + 5); //m_Person.Location = _point; //lint_Left += m_Person.Width + 5; } //if (m_tblProduceList.Rows.Count % 2 == 0 && m_tblProduceList.Rows.Count != 0) //{ // lint_TopCount++; // lint_Left = 0; //} //未定义-人员信息空位 m_PersonNull = new UserPersonNull(); m_PersonNull.Name = ("person_" + m_tblProduceList.Rows.Count + 1).ToString(); ; m_PersonNull.TitleName = "未定义人员"; m_PersonNull.GuanweiColor = YellowColor; m_PersonNull.UserIdNmColor = GreenColor; m_PersonNull.Tag = "0"; m_PersonNull.AllEventClick += new UserPersonNull.AllEvent(m_ProjectNull_AllEventClick); m_PersonNull.ImageUrl = ""; tmpCl[tmpcount] = m_PersonNull; //panelProduct.Controls.Add(m_PersonNull); //lint_Top = lint_TopCount * m_PersonNull.Height; //_point = new Point(lint_Left + 10, lint_Top + 5); //m_PersonNull.Location = _point; Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); panelProduct.Controls.AddRange(tmpCl); })); this.TopMost = true; this.ResumeLayout(false); this.PerformLayout(); btnCanel_Click(null, null); } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("未定义数据检索失败!" + ex); FrmDialog.ShowDialog(); log.Error(ex); //panelProduct.AutoScroll = true; } finally { Program.logFlagEnd(log, s, "获取系统中未定义人员"); } }
/// <summary> /// 获取表格信息一览 /// </summary> protected string GetDspDataListThread(string o) { try { Program._frmMain.Invoke(new Action(delegate() { //this.TopMost = false; })); _iUserNum = 0; m_tblDataList = new DataTable(); ////获取人员头像文件夹 string str_sql = string.Format(@"select * from V_User_TotalShow_Image WHERE (JobForID <> 0) AND (ProjectID <> 0) AND (LineID <> 0) AND (TeamID <> 0) AND (GuanweiID <> 0) "); if (lookmyteamName.Text.Trim() != "") { str_sql += " and myTeamName='" + lookmyteamName.Text.Trim() + "'"; } str_sql += " and AttendDate=CONVERT(VARCHAR(10),'" + dateOperDate1.Text.Trim() + "',120) "; str_sql += @" group by JobForID,ProjectID,LineID,TeamID,GuanweiID,GuanweiSite,AttendDate,UserID,UserIdColor,UserNM,UserNmColor, Sex,JobForNM,ProjectNM,LineNM,TeamNM,myTeamName,OrgName,GuanweiNM,GuanweiColor,TeamSetID,TeamSetNM,AttendType,tiguanGuanweiID, tiguanGuanweiNM,LicenseType,LicenseColor,AttendMemo,warnMemo,warnColor,CardTime,ConfirmFlag,CardTimeColor,AttendWork,StatusID, StatusColor,StatusName ORDER BY GuanweiID,GuanweiSite "; m_tblDataList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); Point _point;//控件坐标 int lint_Left = 0;//左边距 int lint_width = 0; int lint_Top = 0;//上边距 int lint_TopCount = 0;//当前Top有几行 int lint_Person = 0;//当前有多少人员 for (int i = 0; i < m_tblDataList.Rows.Count; i++) { //人员信息 Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); var m_Person = (UserPerson)_tmPersonControl[_iUserNum]; _iUserNum++; m_Person.Name = ("person" + i).ToString(); m_Person.TitleName = m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); if (m_tblDataList.Rows[i]["AttendType"].ToString() == "支援") { m_Person.TitleName = "(支)" + m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); } if (m_tblDataList.Rows[i]["AttendType"].ToString() == "替关") { m_Person.TitleName = "(替)" + m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); } m_Person.GuanweiID = m_tblDataList.Rows[i]["GuanweiID"].ToString(); m_Person.GuanweiColor = m_tblDataList.Rows[i]["GuanweiColor"].ToString(); m_Person.Status = m_tblDataList.Rows[i]["StatusName"].ToString(); m_Person.StatusColor = m_tblDataList.Rows[i]["StatusColor"].ToString(); m_Person.Time = m_tblDataList.Rows[i]["CardTime"].ToString(); m_Person.TimeColor = m_tblDataList.Rows[i]["CardTimeColor"].ToString(); m_Person.Remind = m_tblDataList.Rows[i]["warnMemo"].ToString(); m_Person.RemindColor = m_tblDataList.Rows[i]["warnColor"].ToString(); m_Person.LicenseType = m_tblDataList.Rows[i]["LicenseType"].ToString(); m_Person.LicenseColor = m_tblDataList.Rows[i]["LicenseColor"].ToString(); m_Person.UserID = m_tblDataList.Rows[i]["UserID"].ToString(); m_Person.UserName = m_tblDataList.Rows[i]["UserNM"].ToString(); m_Person.UserIdNmColor = m_tblDataList.Rows[i]["UserIdColor"].ToString(); m_Person.Tag = "0"; try { m_Person.AllEventClick -= new UserPerson.AllEvent(m_Person_AllEventClick); m_Person.DoubleClick -= new UserPerson.DoubleEvent(m_Person_DoubleClick); } catch (Exception ex) { log.Error("AllEventClick Error:" + m_Person.UserID); } m_Person.AllEventClick += new UserPerson.AllEvent(m_Person_AllEventClick); m_Person.DoubleClick += new UserPerson.DoubleEvent(m_Person_DoubleClick); m_Person.ImageUrl = GridCommon.GetUserImage(SysParam.m_daoCommon, m_tblDataList.Rows[i]["UserID"].ToString()); //Top lint_width = m_Person.Height; lint_Top = lint_TopCount * (lint_width + 10); _point = new Point(lint_Left + 10, lint_Top); //panelContent.Controls.Add(m_Person); m_Person.Location = _point; m_Person.Visible = true; lint_Person++; lint_Left += lint_width + 10; if (lint_Person % 13 == 0) {//如果画的数量大于十个,则换行 lint_Left = 0; lint_TopCount++; } })); } return "1"; } catch (Exception ex) { Program._frmMain.Invoke(new Action(delegate() { FrmAttendDialog FrmDialog = new FrmAttendDialog("数据加载失败!" + ex); FrmDialog.ShowDialog(); })); } return "0"; }
/// <summary> /// 保存加班登记 /// </summary> private void btnSave_Click(object sender, EventArgs e) { try { if (lookOTKind.EditValue.ToString() == "-1") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择加班类型!"); FrmDialog.ShowDialog(); return; } if (lookUpEditOTApply.EditValue.ToString() == "-1") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择申请事由!"); FrmDialog.ShowDialog(); return; } if (dtStartTime.Text.Trim() == "") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择加班开始日期!"); FrmDialog.ShowDialog(); return; } if (dtEndTime.Text.Trim() == "") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择开始时间!"); FrmDialog.ShowDialog(); return; } if (dtEndTime2.Text.Trim() == "") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择结束时间!"); FrmDialog.ShowDialog(); return; } if (txtNum.Text.Trim() == "") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择加班时数!"); FrmDialog.ShowDialog(); return; } //if (DateTime.Parse(dtEndTime.Text.Trim()) >= DateTime.Parse(dtEndTime2.Text.Trim())) //{ // FrmAttendDialog FrmDialog = new FrmAttendDialog("开始时间不能大于等于结束时间!"); // FrmDialog.ShowDialog(); // return; //} //int s = Convert.ToDateTime(dtEndTime.Text).Hour; //int n = Convert.ToDateTime(dtStartTime.Text).Hour; // double time = Convert.ToDateTime(dtEndTime.Text).Hour - Convert.ToDateTime(dtStartTime.Text).Hour; //if (double.Parse(txtNum.Text.Trim()) > time) //{ // FrmAttendDialog FrmDialog = new FrmAttendDialog("加班时数大于输入时间段!"); // FrmDialog.ShowDialog(); // return; //} int result = 0; int count = 0; m_dicItemData.Clear(); Common.AdoConnect.Connect.CreateSqlTransaction(); //DataTable dt_temp = ((DataView)this.gridView1.DataSource).Table.Copy(); for (int i = 0; i < m_tblDataList.Rows.Count; i++) { #region remove by xlg, 2015-12-04 ////已经存在这个人的加班信息 //string str_sql = "select a.myUserID from V_Attend_OT_Set as a where 1=1 "; //str_sql += " AND myUserID='" + m_tblDataList.Rows[i]["UserID"].ToString() + "' ";//用户编号 // 赵杰 2015-12-02 删除开始 // 判断时间包含逻辑错误 //str_sql += " AND (OTStrDateSel between '" + dtStartTime.Text.ToString() // + "' and '" + dtEndTime.Text.ToString();//加班日期 //str_sql += "' or OTEndTimeSel between '" + dtStartTime.Text.ToString() // + "' and '" + dtEndTime.Text.ToString()+ "')";//加班日期 // 赵杰 2015-12-02 删除结束 //// 赵杰 2015-12-02 新增开始 //str_sql += " AND ((OTStrDateSel <= '" + dtStartTime.Text.ToString() + "' and OTEndTimeSel >= '" + dtStartTime.Text.ToString() + "') or " // + "(OTStrDateSel <= '" + dtEndTime.Text.ToString() + "' and OTEndTimeSel >= '" + dtEndTime.Text.ToString() + "'))"; //// 赵杰 2015-12-02 新增结束 //str_sql += " AND OtDate='" + dtStartTime.Text.ToString() + "' ";//加班日期 //if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) //{ // Common.AdoConnect.Connect.TransactionRollback(); // FrmAttendDialog FrmDialog = new FrmAttendDialog(m_tblDataList.Rows[i]["UserNM"].ToString() + "\n已经存在" + // dtStartTime.Text.ToString() + "的 加班信息,\n不需要登记加班信息!"); // FrmDialog.ShowDialog(); // return; //} ////已经存在这个人的欠勤信息 //str_sql = "select * from V_Attend_NoAttend_i as a where 1=1 "; //str_sql += " AND myUserID='" + m_tblDataList.Rows[i]["UserID"].ToString() + "' ";//用户编号 //str_sql += " AND CONVERT(varchar(10),NoAttendDate,120) between '" + dtStartTime.Text.ToString() // + "' and '" + dtEndTime.Text.Trim() + "'";//欠勤日期 //if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) //{ // Common.AdoConnect.Connect.TransactionRollback(); // FrmAttendDialog FrmDialog = new FrmAttendDialog(m_tblDataList.Rows[i]["UserNM"].ToString() + "\n已经存在" + // dtStartTime.Text.ToString() + "至" + dtEndTime.Text.Trim() + "的时间内有欠勤信息,\n不能登记加班信息!"); // FrmDialog.ShowDialog(); // return; //} ////是否存在这个人的请假信息 2015-11-23 //str_sql = string.Format(@"select * from Attend_Vacation where UserID='{0}' AND ((BgnDate between '{1}' and '{2}') or(EndDate between '{3}' and '{4}')) ", // m_tblDataList.Rows[i]["UserID"].ToString(), dtStartTime.Text.ToString(), dtEndTime.Text.Trim(), dtStartTime.Text.ToString(), dtEndTime.Text.Trim()); //if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) //{ // Common.AdoConnect.Connect.TransactionRollback(); // FrmAttendDialog FrmDialog = new FrmAttendDialog(m_tblDataList.Rows[i]["UserNM"].ToString() + "\n已经存在" + // dtStartTime.Text.ToString() + "至" + dtEndTime.Text.Trim() + "的时间内有请假信息,\n不能登记加班信息!"); // FrmDialog.ShowDialog(); // return; //} #endregion m_dicItemData.Clear(); m_dicItemData["UserID"] = m_tblDataList.Rows[i]["UserID"].ToString(); m_dicItemData["OtDate"] = dtStartTime.Text.Trim(); m_dicItemData["StartTime"] = dtEndTime.Text.Trim(); m_dicItemData["EndTime"] = dtEndTime2.Text.Trim(); m_dicItemData["OTNum"] = txtNum.Text.Trim(); m_dicItemData["OTApplyID"] = lookUpEditOTApply.EditValue.ToString(); m_dicItemData["OTType"] = lookOTKind.EditValue.ToString(); m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem("Attend_OT_Set", m_dicItemData); if (result > 0) count++; //日志 SysParam.m_daoCommon.WriteLog("加班登记", "新增", m_tblDataList.Rows[i]["UserID"].ToString()); } if (m_tblDataList.Rows.Count == count) { Common.AdoConnect.Connect.TransactionCommit(); FrmAttendDialog FrmDialog = new FrmAttendDialog("保存数据成功!"); FrmDialog.ShowDialog(); this.Close(); } else { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog("保存数据失败!"); FrmDialog.ShowDialog(); } } catch (Exception ex) { Common.AdoConnect.Connect.TransactionRollback(); log.Error(ex); FrmAttendDialog FrmDialog = new FrmAttendDialog("保存数据失败!" + ex); FrmDialog.ShowDialog(); } }
} //防止闪烁 private void frmOvertime_Load(object sender, EventArgs e) { try { //循环把人员信息放入panel panelContent.Controls.Clear(); Point _point;//控件坐标 int lint_Left = 0;//左边距 int lint_Top = 0;//上边距 int lint_TopCount = 0;//当前Top有几行 int lint_Person = 0;//当前有多少人员 for (int i = 0; i < m_tblDataList.Rows.Count; i++) { //人员信息 UserPerson m_Person = new UserPerson(); m_Person.Name = ("person" + i).ToString(); m_Person.TitleName = m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); if (m_tblDataList.Rows[i]["AttendType"].ToString() == "支援") { m_Person.TitleName = "(支)" + m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); } if (m_tblDataList.Rows[i]["AttendType"].ToString() == "替关") { m_Person.TitleName = "(替)" + m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); } m_Person.GuanweiID = m_tblDataList.Rows[i]["GuanweiID"].ToString(); m_Person.GuanweiColor = m_tblDataList.Rows[i]["GuanweiColor"].ToString(); m_Person.Status = m_tblDataList.Rows[i]["StatusName"].ToString(); m_Person.StatusColor = m_tblDataList.Rows[i]["StatusColor"].ToString(); m_Person.Time = m_tblDataList.Rows[i]["CardTime"].ToString(); m_Person.TimeColor = m_tblDataList.Rows[i]["CardTimeColor"].ToString(); m_Person.Remind = m_tblDataList.Rows[i]["warnMemo"].ToString(); m_Person.RemindColor = m_tblDataList.Rows[i]["warnColor"].ToString(); m_Person.LicenseType = m_tblDataList.Rows[i]["LicenseType"].ToString(); m_Person.LicenseColor = m_tblDataList.Rows[i]["LicenseColor"].ToString(); m_Person.UserID = m_tblDataList.Rows[i]["UserID"].ToString(); m_Person.UserName = m_tblDataList.Rows[i]["UserNM"].ToString(); m_Person.UserIdNmColor = m_tblDataList.Rows[i]["UserIdColor"].ToString(); m_Person.Tag = "0"; //m_Person.AllEventClick += new UserPerson.AllEvent(m_Person_AllEventClick); //m_Person.DoubleClick += new UserPerson.DoubleEvent(m_Person_DoubleClick); m_Person.ImageUrl = GridCommon.GetUserImage(SysParam.m_daoCommon, m_tblDataList.Rows[i]["UserID"].ToString()); panelContent.Controls.Add(m_Person); lint_Person++; //Top lint_Top = lint_TopCount * (m_Person.Height + 10); _point = new Point(lint_Left + 10, lint_Top); m_Person.Location = _point; lint_Left += m_Person.Width + 10; if (lint_Person % 10 == 0) {//如果画的数量大于十个,则换行 lint_Left = 0; lint_TopCount++; } } } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("画面加载失败!"); FrmDialog.ShowDialog(); } }
/// <summary> /// 保存离职登记 /// </summary> private void btnSave_Click(object sender, EventArgs e) { try { if (cboLeaveType.EditValue.ToString()=="-1") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择离职类型!"); FrmDialog.ShowDialog(); return; } if (comboBoxEditReason.EditValue.ToString() == "-1") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择离职原因!"); FrmDialog.ShowDialog(); return; } if (dtSetDate.Text.Trim() == "") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择最后上班日!"); FrmDialog.ShowDialog(); return; } if (dtCallDate.Text.Trim() == "") { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择离职提出日!"); FrmDialog.ShowDialog(); return; } int result = 0; int count = 0; m_dicItemData.Clear(); Common.AdoConnect.Connect.CreateSqlTransaction(); //DataTable dt_temp = ((DataView)this.gridView1.DataSource).Table.Copy(); for (int i = 0; i < m_tblDataList.Rows.Count; i++) { //已经存在这个人的欠勤信息 string str_sql = "select * from V_Attend_Leave as a where 1=1 "; str_sql += " AND UserID='" + m_tblDataList.Rows[i]["UserID"].ToString() + "' ";//用户编号 //str_sql += " AND CONVERT(varchar(10),SetDate,120) = '" + dtSetDate.Text.ToString() + "'";//最后上班日期 if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) { FrmAttendDialog FrmDialog = new FrmAttendDialog( m_tblDataList.Rows[i]["UserID"].ToString() + ":" + m_tblDataList.Rows[i]["UserNM"].ToString() + ",\n已经登记了离职信息!"); FrmDialog.ShowDialog(); Common.AdoConnect.Connect.TransactionRollback(); return; } m_dicItemData.Clear(); m_dicItemData["UserID"] = m_tblDataList.Rows[i]["UserID"].ToString(); m_dicItemData["CallDate"] = dtCallDate.Text.Trim();//离职提出日 m_dicItemData["SetDate"] = dtSetDate.Text.Trim();//最后上班日 m_dicItemData["Flag"] = "0"; m_dicItemData["Memo"] = txtMemo.Text.Trim();//离职说明 m_dicItemData["LeaveTypeID"] = cboLeaveType.EditValue.ToString();//离职类型 m_dicItemData["ReasonID"] = comboBoxEditReason.EditValue.ToString();//离职原因 m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem("Attend_Leave", m_dicItemData); if (result > 0) count++; //日志 SysParam.m_daoCommon.WriteLog("离职登记", "新增", m_tblDataList.Rows[i]["UserNM"].ToString() + ":" + dtCallDate.Text.Trim()); } if (m_tblDataList.Rows.Count == count) { FrmAttendDialog FrmDialog = new FrmAttendDialog(count+"人的离职登记信息,成功提交!"); FrmDialog.ShowDialog(); Common.AdoConnect.Connect.TransactionCommit(); this.Close(); } else { FrmAttendDialog FrmDialog = new FrmAttendDialog("离职登记提交失败!"); FrmDialog.ShowDialog(); Common.AdoConnect.Connect.TransactionRollback(); } } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("离职登记提交失败!"); FrmDialog.ShowDialog(); Common.AdoConnect.Connect.TransactionRollback(); log.Error(ex); } }
} //防止闪烁 /// <summary> /// 窗体初始化处理 /// </summary> public override void SetFormValue() { try { repositoryItemDateEdit2.EditMask = "yyyy-MM-dd HH:mm"; repositoryItemDateEdit2.Mask.UseMaskAsDisplayFormat = true; repositoryItemDateEdit3.EditMask = "yyyy-MM-dd HH:mm"; repositoryItemDateEdit3.Mask.UseMaskAsDisplayFormat = true; gridView1.IndicatorWidth =70; //班别 SysParam.m_daoCommon.SetLoopUpEdit(TableNames.P_Produce_Scheduling, lookTeamType, true, EnumDefine.DefalutItemAllNo, EnumDefine.DefalutItemAllText); repositoryItemComboBox2.ParseEditValue += new DevExpress.XtraEditors.Controls.ConvertEditValueEventHandler(repositoryItemComboBox2_ParseEditValue); repositoryItemButtonEdit1.ButtonClick+=new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(repositoryItemButtonEdit1_ButtonClick); if (gridView1 != null) { gridView1.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(gridView1_CustomDrawRowIndicator); } //获取白班晚班 string str_sql = string.Format(@"select ID as pTypeID,pName as TeamSetName from P_Produce_TeamKind "); m_tblTeamType = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); for (int i = 0; i < m_tblTeamType.Rows.Count; i++) { CboItemEntity item = new CboItemEntity(); item.Value = m_tblTeamType.Rows[i]["pTypeID"].ToString(); item.Text = m_tblTeamType.Rows[i]["TeamSetName"].ToString(); repositoryItemComboBox2.Items.Add(item); } if (Common._myTeamName != "") { repositoryItemComboBox2.NullText = Common._myTeamName; } GetDspDataList(); } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog( "画面初始化失败!"+ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 获取表格信息一览 /// </summary> protected override void GetDspDataList() { string str_sql = string.Empty; try { //if (lookTeamType.EditValue.ToString() == "-1") return; //取得排班信息 str_sql = string.Format(@"select BgnDate as StrDate,* from V_Attend_TeamSet_i where myTeamName ='{0}'", m_teamName); m_tblDataList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); if (m_tblDataList.Rows.Count > 0) { lookTeamType.Visible = false; label2.Visible = false; } else { lookTeamType.Visible = true; label2.Visible = true; //如果没有则查询P_Produce_Scheduling_detail表中信息显示 if (lookTeamType.EditValue.ToString()!="-1") { str_sql = string.Format(@"SELECT SchedulingID as ID ,StrDate,EndDate,TypeID as pTypeID,'' AS TeamSetName FROM P_Produce_Scheduling_detail where SchedulingID='{0}'", lookTeamType.EditValue.ToString()); m_tblDataList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); } } if (!m_tblDataList.Columns.Contains("rowStatus")) { m_tblDataList.Columns.Add("rowStatus"); } //白班晚班赋值 DataView view = new DataView(m_tblTeamType.Copy()); for (int i = 0; i < m_tblDataList.Rows.Count; i++) { view.RowFilter = "pTypeID='" + m_tblDataList.Rows[i]["pTypeID"] + "'"; DataTable dt_temp = view.ToTable(); if (dt_temp.Rows.Count > 0) { m_tblDataList.Rows[i]["TeamSetName"] = dt_temp.Rows[0]["TeamSetName"].ToString(); } } DataRow dr = m_tblDataList.NewRow(); m_tblDataList.Rows.Add(dr); gridControl1.DataSource = m_tblDataList; } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog( "画面加载失败!"+ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 人员状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnStatus_Click(object sender, EventArgs e) { //this.TopMost = false; DataTable dt_temp = new DataTable(); GetFormList(ref dt_temp); if (dt_temp.Rows.Count != 1) { FrmAttendDialog FrmDialog = new FrmAttendDialog("当前操作只能选择一人信息!"); FrmDialog.ShowDialog(); return; } else { try { frmEditProduce_User frm = new frmEditProduce_User(); frm.ScanMode = Common.DataModifyMode.del; DataTable dt_data = new DataTable(); dt_data.Columns.Add("Userid"); dt_data.Columns.Add("UserName"); dt_data.Columns.Add("Sex"); dt_data.Columns.Add("StatusIDs"); dt_data.Columns.Add("DutyName"); DataRow row = dt_data.NewRow(); row["Userid"] = dt_temp.Rows[0]["Userid"]; row["UserName"] = dt_temp.Rows[0]["UserNm"]; row["Sex"] = dt_temp.Rows[0]["Sex"]; row["StatusIDs"] = dt_temp.Rows[0]["StatusID"]; row["DutyName"] = ""; frm.dr = row; if (frm.ShowDialog() == DialogResult.OK) { //自动刷新 btnRef(); } } catch (Exception ex) { XtraMsgBox.Show("画面初始化失败!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error, ex, this.GetType()); } } }
/// <summary> /// 刷新页面数据(重新统计) /// </summary> private void btnRef() { this.Cursor = Cursors.WaitCursor; try { this.TopMost = true; SqlParameter[] paraList = new SqlParameter[7]; paraList[0] = new SqlParameter("@SetDate", SqlDbType.VarChar, 10); if (dateOperDate1.EditValue.ToString() != "") { DateTime dt = DateTime.Parse(dateOperDate1.EditValue.ToString()); paraList[0].Value = dt.ToString("yyyy-MM-dd HH:mm"); } else { paraList[0].Value = ""; } String str_sql = string.Format(@"select top 1 JobForID,ProjectID,LineID,TeamID from V_Produce_Para where myTeamName='{0}' Order by id", lookmyteamName.Text); DataTable dt_temp = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); m_dicItemData.Clear(); if (dt_temp.Rows.Count == 1) { m_dicItemData["JobForID"] = dt_temp.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = dt_temp.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = dt_temp.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = dt_temp.Rows[0]["TeamID"].ToString(); } else { m_dicItemData["JobForID"] = "0"; m_dicItemData["ProjectID"] = "0"; m_dicItemData["LineID"] = "0"; m_dicItemData["TeamID"] = "0"; } paraList[1] = new SqlParameter("@JobForID", SqlDbType.VarChar, 10); paraList[1].Value = m_dicItemData["JobForID"].ToString(); paraList[2] = new SqlParameter("@ProjectID", SqlDbType.VarChar, 10); paraList[2].Value = m_dicItemData["ProjectID"].ToString(); paraList[3] = new SqlParameter("@LineID", SqlDbType.VarChar, 10); paraList[3].Value = m_dicItemData["LineID"].ToString(); paraList[4] = new SqlParameter("@TeamID", SqlDbType.VarChar, 10); paraList[4].Value = m_dicItemData["TeamID"].ToString(); paraList[5] = new SqlParameter("@OperID", SqlDbType.VarChar, 10); if (Common._personid.ToString() != "") { paraList[5].Value = Common._personid; } else { paraList[5].Value = "0"; } //执行存储过程1 Common.AdoConnect.Connect.SetExecuteSP("PROC_Attend_Total_Result", Common.Choose.OnlyExecSp, paraList); SqlParameter[] paraListCardData = new SqlParameter[1]; paraListCardData[0] = new SqlParameter("@SetDate", SqlDbType.VarChar, 10); if (dateOperDate1.EditValue.ToString() != "") { DateTime dt = DateTime.Parse(dateOperDate1.EditValue.ToString()); paraListCardData[0].Value = dt.ToString("yyyy-MM-dd"); } else { paraListCardData[0].Value = ""; } //执行存储过程2,打卡时间 Common.AdoConnect.Connect.SetExecuteSP("PROC_CardData_Attend_Result", Common.Choose.OnlyExecSp, paraListCardData); //重新取得页面数据 GetDspDataList(); //ThreadPool.QueueUserWorkItem(btnRefleash, "刷新"); } catch (Exception ex) { log.Error(ex); FrmAttendDialog FrmDialog = new FrmAttendDialog("数据刷新失败!" + ex); FrmDialog.ShowDialog(); } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// 保存请假登记 /// </summary> private void btnSave_Click(object sender, EventArgs e) { try { //请假类型检查:未输入 if (lookVacationType.EditValue.ToString().Equals("-1")) { FrmAttendDialog FrmDialog = new FrmAttendDialog("请假类型必须选择!"); FrmDialog.ShowDialog(); return; } //请假开始时间检查:未输入 if (string.IsNullOrEmpty(dtStartTime.EditValue.ToString())) { FrmAttendDialog FrmDialog = new FrmAttendDialog( "请选择请假开始时间!"); FrmDialog.ShowDialog(); return; } //请假结束时间检查:未输入 if (string.IsNullOrEmpty(dtEndTime.EditValue.ToString())) { FrmAttendDialog FrmDialog = new FrmAttendDialog("请选择请假结束时间!"); FrmDialog.ShowDialog(); return; } DateTime dtBegin = DateTime.Parse(dtStartTime.EditValue.ToString()); DateTime dtEnd = DateTime.Parse(dtEndTime.EditValue.ToString()); //请假结束时间>请假开始时间 if (dtEnd <= dtBegin) { FrmAttendDialog FrmDialog = new FrmAttendDialog("结束时间须大于开始时间!"); FrmDialog.ShowDialog(); return; } int result = 0; int count = 0; Common.AdoConnect.Connect.CreateSqlTransaction(); //DataTable dt_temp = ((DataView)this.gridView1.DataSource).Table.Copy(); for (int i = 0; i < m_tblDataList.Rows.Count; i++) { //已经存在这个人的请假信息 string str_sql = "select * from V_Attend_Vacation_i as a where 1=1 "; str_sql += " AND myUserID='" + m_tblDataList.Rows[i]["UserID"].ToString() + "' ";//用户编号 str_sql += " AND ('" + DateTime.Parse(dtStartTime.EditValue.ToString()).ToString("yyyy-MM-dd hh:mm") + "' between CONVERT(VARCHAR(16),VacationBgnDate,120) and CONVERT(VARCHAR(16),VacationEndDate,120) ";//请假开始时间 str_sql += " OR '" + DateTime.Parse(dtEndTime.EditValue.ToString()).ToString("yyyy-MM-dd hh:mm") + "' between CONVERT(VARCHAR(16),VacationBgnDate,120) and CONVERT(VARCHAR(16),VacationEndDate,120))";//请假结束时间 if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog( m_tblDataList.Rows[i]["UserID"].ToString() + ":" + m_tblDataList.Rows[i]["UserNM"].ToString() +",\n已经登记了请假信息!"); FrmDialog.ShowDialog(); return; } //请假时间不在排班的上班范围内 str_sql = "select * from V_Attend_TeamSet_i as a where 1=1 "; str_sql += " AND myTeamName='" + m_tblDataList.Rows[i]["myTeamName"].ToString() + "' ";//向别-班别 str_sql += " AND ('" + DateTime.Parse(dtStartTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm") + "' between CONVERT(VARCHAR(16),BgnDate,120) and CONVERT(VARCHAR(16),EndDate,120) ";//请假开始时间 str_sql += " OR '" + DateTime.Parse(dtEndTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm") + "' between CONVERT(VARCHAR(16),BgnDate,120) and CONVERT(VARCHAR(16),EndDate,120))";//请假结束时间 if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count <= 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog( m_tblDataList.Rows[i]["UserID"].ToString() + ":" + m_tblDataList.Rows[i]["UserNM"].ToString() + "\n 在此时间段内不上班,不需要请假!"); FrmDialog.ShowDialog(); return; } //已经存在了欠勤信息 str_sql = "select * from V_Attend_NoAttend_i as a where 1=1 "; str_sql += " AND myTeamName='" + m_tblDataList.Rows[i]["UserID"].ToString() + "' ";//向别-班别 str_sql += " AND (CONVERT(VARCHAR(10),NoAttendDate,120) between '" + DateTime.Parse(dtStartTime.EditValue.ToString()).ToString("yyyy-MM-dd") + "' and ";//请假开始时间 str_sql += " '" + DateTime.Parse(dtEndTime.EditValue.ToString()).ToString("yyyy-MM-dd") + "')";//请假结束时间 if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog( m_tblDataList.Rows[i]["UserID"].ToString() + ":" + m_tblDataList.Rows[i]["UserNM"].ToString() + "\n 在此时间段内有欠勤记录,不能登记请假!"); FrmDialog.ShowDialog(); return; } m_dicItemData.Clear(); m_dicItemData["UserID"] = m_tblDataList.Rows[i]["UserID"].ToString(); m_dicItemData["VacationType"] = lookVacationType.EditValue.ToString(); m_dicItemData["BgnDate"] = DateTime.Parse(dtStartTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm"); m_dicItemData["EndDate"] = DateTime.Parse(dtEndTime.EditValue.ToString()).ToString("yyyy-MM-dd HH:mm"); m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); m_dicItemData["Memo"] = txtMemo.Text.Trim(); result = SysParam.m_daoCommon.SetInsertDataItem("Attend_Vacation", m_dicItemData); if (result > 0) count++; //日志 SysParam.m_daoCommon.WriteLog("请假登记", "新增", m_tblDataList.Rows[i]["UserID"].ToString()); } if (m_tblDataList.Rows.Count == count) { Common.AdoConnect.Connect.TransactionCommit(); FrmAttendDialog FrmDialog = new FrmAttendDialog(count + "人的请假登记成功!"); FrmDialog.ShowDialog(); this.Close(); } else { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog("请假登记失败!"); FrmDialog.ShowDialog(); } } catch (Exception ex) { Common.AdoConnect.Connect.TransactionRollback(); log.Error(ex); FrmAttendDialog FrmDialog = new FrmAttendDialog("请假登记失败!" + ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 获取表格信息一览 /// </summary> protected override void GetDspDataList() { try { if (isRun) { return; } isRun = true; chkAll.Checked = false; //panelContent.Controls.Clear(); //this.TopMost = false; _iUserNum = 0; m_tblDataList = new DataTable(); ////获取人员头像文件夹 string str_sql = string.Format(@"select * from V_User_TotalShow_Image WHERE (JobForID <> 0) AND (ProjectID <> 0) AND (LineID <> 0) AND (TeamID <> 0) AND (GuanweiID <> 0) "); if (lookmyteamName.Text.Trim() != "") { str_sql += " and myTeamName='" + lookmyteamName.Text.Trim() + "'"; } str_sql += " and AttendDate=CONVERT(VARCHAR(10),'" + dateOperDate1.Text.Trim() + "',120) "; str_sql += @" group by JobForID,ProjectID,LineID,TeamID,GuanweiID,GuanweiSite,AttendDate,UserID,UserIdColor,UserNM,UserNmColor, Sex,JobForNM,ProjectNM,LineNM,TeamNM,myTeamName,OrgName,GuanweiNM,GuanweiColor,TeamSetID,TeamSetNM,AttendType,tiguanGuanweiID, tiguanGuanweiNM,LicenseType,LicenseColor,AttendMemo,warnMemo,warnColor,CardTime,ConfirmFlag,CardTimeColor,AttendWork,StatusID, StatusColor,StatusName ORDER BY GuanweiID,GuanweiSite "; m_tblDataList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); Point _point;//控件坐标 int lint_Left = 0;//左边距 int lint_width = 0; int lint_Top = 0;//上边距 int lint_TopCount = 0;//当前Top有几行 int lint_Person = 0;//当前有多少人员 this.SuspendLayout(); _iUserNum = m_tblDataList.Rows.Count; var tmpCLcount = panelContent.Controls.Count; if (tmpCLcount > 0) { if (tmpCLcount < _iUserNum) { var diff = _iUserNum - tmpCLcount; var tmplistcl = new Control[diff]; for (int i = 0; i < diff; i++) { m_Person = new UserPerson(); m_Person.Name = ("person" + (_iUserNum + i)).ToString(); m_Person.Visible = false; tmplistcl[i] = m_Person; } panelContent.Controls.AddRange(tmplistcl); } } else { tmparea = new Control[_iUserNum]; } //panelContent.Width = 15 * (m_Person.Width); panelContent.Height = ((_iUserNum / 14) + 3) * m_Person.Height; for (int i = 0; i < _iUserNum; i++) { //人员信息 if (tmpCLcount <= 0) { m_Person = new UserPerson(); } else { m_Person = (UserPerson)panelContent.Controls[i]; } m_Person.Name = ("person" + i).ToString(); m_Person.TitleName = m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); if (m_tblDataList.Rows[i]["AttendType"].ToString() == "支援") { m_Person.TitleName = "(支)" + m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); } if (m_tblDataList.Rows[i]["AttendType"].ToString() == "替关") { m_Person.TitleName = "(替)" + m_tblDataList.Rows[i]["GuanweiNM"].ToString() + " - " + m_tblDataList.Rows[i]["GuanweiSite"].ToString(); } m_Person.GuanweiID = m_tblDataList.Rows[i]["GuanweiID"].ToString(); m_Person.GuanweiColor = m_tblDataList.Rows[i]["GuanweiColor"].ToString(); m_Person.Status = m_tblDataList.Rows[i]["StatusName"].ToString(); m_Person.StatusColor = m_tblDataList.Rows[i]["StatusColor"].ToString(); m_Person.Time = m_tblDataList.Rows[i]["CardTime"].ToString(); m_Person.TimeColor = m_tblDataList.Rows[i]["CardTimeColor"].ToString(); m_Person.Remind = m_tblDataList.Rows[i]["warnMemo"].ToString(); m_Person.RemindColor = m_tblDataList.Rows[i]["warnColor"].ToString(); m_Person.LicenseType = m_tblDataList.Rows[i]["LicenseType"].ToString(); m_Person.LicenseColor = m_tblDataList.Rows[i]["LicenseColor"].ToString(); m_Person.UserID = m_tblDataList.Rows[i]["UserID"].ToString(); m_Person.UserName = m_tblDataList.Rows[i]["UserNM"].ToString(); m_Person.UserIdNmColor = m_tblDataList.Rows[i]["UserIdColor"].ToString(); m_Person.Tag = "0"; try { m_Person.AllEventClick -= new UserPerson.AllEvent(m_Person_AllEventClick); m_Person.DoubleClick -= new UserPerson.DoubleEvent(m_Person_DoubleClick); } catch (Exception ex) { log.Error("AllEventClick Error:" + m_Person.UserID); } m_Person.AllEventClick += new UserPerson.AllEvent(m_Person_AllEventClick); m_Person.DoubleClick += new UserPerson.DoubleEvent(m_Person_DoubleClick); m_Person.ImageUrl = GridCommon.GetUserImage(SysParam.m_daoCommon, m_tblDataList.Rows[i]["UserID"].ToString()); if (!m_Person.Visible) { m_Person.Visible = true; } if (tmpCLcount <= 0) { tmparea[i] = m_Person; } //Top //lint_width = m_Person.Height; //lint_Top = lint_TopCount * (lint_width + 10); //_point = new Point(lint_Left + 10, lint_Top); ////panelContent.Controls.Add(m_Person); //m_Person.Location = _point; //m_Person.Visible = true; //lint_Person++; //lint_Left += lint_width + 10; //if (lint_Person % 13 == 0) //{//如果画的数量大于十个,则换行 // lint_Left = 0; // lint_TopCount++; //} } if (tmpCLcount <= 0) { panelContent.Controls.AddRange(tmparea); } else { if (_iUserNum < tmpCLcount) { for (int i = _iUserNum; i < tmpCLcount; i++) { panelContent.Controls[i].Visible = false; } } } foreach (Control col in panelContent.Controls) { if (!col.Visible) { continue; } if (!col.Tag.Equals(0)) { col.BackColor = Color.Transparent; col.Tag = 0; } } this.ResumeLayout(false); this.PerformLayout(); } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("数据加载失败!" + ex); FrmDialog.ShowDialog(); } finally { isRun = false; } }
/// <summary> /// 保存欠勤登记 /// </summary> private void btnSave_Click(object sender, EventArgs e) { try { //日期检查:未输入 if (string.IsNullOrEmpty(dtStartTime.EditValue.ToString())) { FrmAttendDialog FrmDialog = new FrmAttendDialog( "请选择欠勤日期!"); FrmDialog.ShowDialog(); return; } int result = 0; int count = 0; Common.AdoConnect.Connect.CreateSqlTransaction(); //DataTable dt_temp = ((DataView)this.gridView1.DataSource).Table.Copy(); for (int i = 0; i < m_tblDataList.Rows.Count; i++) { //已经存在这个人的欠勤信息 string str_sql = "select * from V_Attend_NoAttend_i as a where 1=1 "; str_sql += " AND myUserID='" + m_tblDataList.Rows[i]["UserID"].ToString() + "' ";//用户编号 str_sql += " AND '" + DateTime.Parse(dtStartTime.EditValue.ToString()).ToString("yyyy-MM-dd") + "'= CONVERT(varchar(10),NoAttendDate,120) ";//欠勤日期 if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog( m_tblDataList.Rows[i]["UserID"].ToString() + ":" + m_tblDataList.Rows[i]["UserNM"].ToString() + "\n在【" + dtStartTime.EditValue.ToString() + "】这一天已经登记了欠勤信息!"); FrmDialog.ShowDialog(); return; } //请假时间不在排班的上班范围内 str_sql = "select * from V_Attend_TeamSet_i as a where 1=1 "; str_sql += " AND myTeamName='" + m_tblDataList.Rows[i]["myTeamName"].ToString() + "' ";//向别-班别 str_sql += " AND '" + DateTime.Parse(dtStartTime.EditValue.ToString()).ToString("yyyy-MM-dd") + "' between CONVERT(varchar(10),BgnDate,120) and CONVERT(varchar(10),EndDate,120) ";//开始时间 if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count <= 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog( m_tblDataList.Rows[i]["UserID"].ToString() + ":" + m_tblDataList.Rows[i]["UserNM"].ToString() + "\n在【" + dtStartTime.EditValue.ToString() + "】这一天不上班,\n不需要登记欠勤信息!"); FrmDialog.ShowDialog(); return; } //已经存在了请假信息 str_sql = "select * from V_Attend_Vacation_i as a where 1=1 "; str_sql += " AND myTeamName='" + m_tblDataList.Rows[i]["myTeamName"].ToString() + "' ";//向别-班别 str_sql += " AND myUserID='" + m_tblDataList.Rows[i]["UserID"].ToString() + "' ";//用户编号 str_sql += " AND '" + DateTime.Parse(dtStartTime.EditValue.ToString()).ToString("yyyy-MM-dd") + "' between CONVERT(varchar(10),VacationBgnDate,120) and CONVERT(varchar(10),VacationEndDate,120) ";//开始时间 if (SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql).Rows.Count > 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog( m_tblDataList.Rows[i]["UserID"].ToString() + ":" + m_tblDataList.Rows[i]["UserNM"].ToString() + "\n在【" + dtStartTime.EditValue.ToString() + "】有请假记录,\n不能登记欠勤信息!"); FrmDialog.ShowDialog(); return; } m_dicItemData.Clear(); m_dicItemData["UserID"] = m_tblDataList.Rows[i]["UserID"].ToString(); m_dicItemData["SetDate"] = dtStartTime.Text.Trim(); m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem("Attend_NoAttend", m_dicItemData); if (result > 0) count++; //日志 SysParam.m_daoCommon.WriteLog("欠勤登", "新增", m_tblDataList.Rows[i]["UserID"].ToString()); } if (m_tblDataList.Rows.Count == count) { Common.AdoConnect.Connect.TransactionCommit(); FrmAttendDialog FrmDialog = new FrmAttendDialog( "保存数据成功!"); FrmDialog.ShowDialog(); this.Close(); } else { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog( "保存数据失败!"); FrmDialog.ShowDialog(); } } catch (Exception ex) { Common.AdoConnect.Connect.TransactionRollback(); log.Error(ex); FrmAttendDialog FrmDialog = new FrmAttendDialog( "保存数据失败!"+ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 获取考勤人员信息一览 /// </summary> protected override void GetDspDataList() { Stopwatch s = new Stopwatch(); Program.logFlagStart(log, s, "获取考勤人员信息一览"); try { //this.TopMost = false; row_Cnt = -1;//布局行号归零 m_tblDataList = new DataTable();//人员考勤情况数据 m_tblGuanweiList = new DataTable();//关位信息 //1、取得关位顺序信息 string str_sql = string.Empty; str_sql = string.Format(@" SELECT a.*, IsNull(h.InCount,0) as realityCount FROM (select CONVERT(VARCHAR(10),'{0}',120) as AttendDate, JobForID, ProjectID, LineID, TeamID, myTeamName, orgTeamName, GuanweiID, GuanweiName, GuanweiType, RowID, SetNum FROM V_Produce_Para ) AS a LEFT JOIN (SELECT a1.JobForID, a1.ProjectID, a1.LineID, a1.TeamID, a1.GuanweiID, a1.AttendDate, COUNT(*) AS InCount FROM ( select JobForID, ProjectID, LineID, TeamID, GuanweiID, AttendDate,guanweisite,AttendWork,AttendType,AttendMemo from V_Attend_Result_Info ) AS a1 --考勤汇总报表 WHERE a1.AttendWork > 0 AND ISNULL(a1.AttendMemo,'') <>'支援调出' AND a1.AttendType<>'请假' AND a1.AttendType<>'欠勤' GROUP BY a1.JobForID, a1.ProjectID, a1.LineID, a1.TeamID, a1.GuanweiID,a1.AttendDate ) AS h ON a.JobForID = h.JobForID AND a.ProjectID= h.ProjectID AND a.LineID= h.LineID AND a.TeamID= h.TeamID AND a.GuanweiID= h.GuanweiID AND a.AttendDate= h.AttendDate where a.myTeamName='{1}' and a.AttendDate=CONVERT(VARCHAR(10),'{2}',120) group by RowID,a.AttendDate,a.JobForID,a.ProjectID,a.LineID,a.TeamID,a.myTeamName,a.orgTeamName,a.GuanweiID, a.GuanweiName,a.GuanweiType,a.SetNum,h.InCount order by RowID ", dateOperDate1.Text.Trim(), lookmyteamName.Text.ToString(), dateOperDate1.Text.Trim()); m_tblGuanweiList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); if (m_tblGuanweiList.Rows.Count == 0) { //panelContent.Controls.Clear(); return; } //2、人员考勤情况数据取得 str_sql = string.Format(@"select distinct * from V_User_TotalShow_Image WHERE (JobForID <> 0) AND (ProjectID <> 0) AND (LineID <> 0) AND (TeamID <> 0) AND (GuanweiID <> 0) and ISNULL(AttendMemo,'') <>'支援调出' "); str_sql += " and myTeamName='" + lookmyteamName.Text.ToString() + "'"; str_sql += " and AttendDate=CONVERT(VARCHAR(10),'" + dateOperDate1.Text.Trim() + "',120) "; str_sql += " order by JobForID,ProjectID,LineID,TeamID,GuanweiID,GuanweiSite "; m_tblDataList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); if (m_tblDataList.Rows.Count > 0) { string TeamSetNM = m_tblDataList.Rows[0]["TeamSetNM"].ToString(); //设置调动开始时间、结束时间 if (TeamSetNM == "白班") { dtpStartDate.EditValue = DateTime.Now.ToString("yyyy-MM-dd") + " 08:00"; dtpEndDate.EditValue = DateTime.Now.ToString("yyyy-MM-dd") + " 18:00"; } else { dtpStartDate.EditValue = DateTime.Now.ToString("yyyy-MM-dd") + " 22:00"; dtpEndDate.EditValue = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 07:00"; } } this.SuspendLayout(); //循环把人员信息放入panel //panelContent.Controls.Clear(); isLeftInto = true;//是否考勤区域处理 xtraScrollableControl1.VerticalScroll.Value = 0; var isCheckCL = _lstContr2.Where(m => !m.BackColor.Equals(Color.Transparent) || !m.Tag.Equals("0")).ToList(); foreach (Control item in isCheckCL) { if (item.GetType().ToString() == "MachineSystem.UserControls.UserPerson") { item.BackColor = Color.Transparent; } item.Tag = "0"; //item.Visible = false; } _objcl2.u_gwNum = 0; _objcl2.u_UserPersonNum = _objcl2.gwNum; _objcl2.u_UserNullNum = _objcl2.gwNum + _objcl2.UserPersonNum; //关位 string strGuwanweiID = string.Empty; var gwcount = m_tblGuanweiList.Rows.Count; for (int a = 0; a < gwcount; a++) { strGuwanweiID = m_tblGuanweiList.Rows[a]["GuanweiID"].ToString(); //当前关位下的人员信息,关位下没有人员,不展示关位(工种)信息 DataView view = new DataView(m_tblDataList.Copy()); view.RowFilter = "GuanweiID='" + strGuwanweiID + "'"; DataTable dt_temp = view.ToTable(); //添加关位(工种) m_PersonList = (UserPersonsList)_lstContr2[_objcl2.u_gwNum]; //new UserPersonsList(); _objcl2.u_gwNum++; m_PersonList.TitleGuanwei = m_tblGuanweiList.Rows[a]["GuanweiName"].ToString();//关位名称 m_PersonList.GuanweiID = m_tblGuanweiList.Rows[a]["GuanweiID"].ToString(); bpCnt = int.Parse(m_tblGuanweiList.Rows[a]["SetNum"].ToString()); m_PersonList.StandardCount = bpCnt;//关位标配人数 m_PersonList.RealCount = int.Parse(m_tblGuanweiList.Rows[a]["realityCount"].ToString());//关位实配人数 try { m_PersonList.AllEventClick -= new UserPersonsList.AllEvent(m_PersonList_AllEventClick); } catch (Exception ex) { log.Error("AllEventClick Error:" + m_Person.UserID); } m_PersonList.AllEventClick += new UserPersonsList.AllEvent(m_PersonList_AllEventClick); this.setImgIndex(true);//设置显示位置 //panelContent.Controls.Add(m_PersonList);//展示空间 m_PersonList.Location = _point;//设置空间展示坐标 if (!m_PersonList.Visible) { Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); m_PersonList.Visible = true; })); } gwShowSite = 1; view = new DataView(dt_temp.Copy()); view.RowFilter = "GuanweiSite='99'"; int intCount = bpCnt + view.ToTable().Rows.Count; for (int i = 0; i < intCount; i++) { Boolean perFlg = true; int GwSite = 0; if (dt_temp.Rows.Count > 0) { GwSite = int.Parse(dt_temp.Rows[0]["GuanweiSite"].ToString());//关位位置 } while (GwSite == (i + 1)) { //人员信息 m_Person = (UserPerson)_lstContr2[_objcl2.u_UserPersonNum]; _objcl2.u_UserPersonNum++; //new UserPerson(); perFlg = false; //位置相同 m_Person.TitleName = dt_temp.Rows[0]["GuanweiNM"].ToString() + " - " + GwSite; if (dt_temp.Rows[0]["AttendType"].ToString() == "支援") { m_Person.TitleName = "(支)" + dt_temp.Rows[0]["GuanweiNM"].ToString() + " - " + GwSite; } if (dt_temp.Rows[0]["AttendType"].ToString() == "替关") { m_Person.TitleName = "(替)" + dt_temp.Rows[0]["GuanweiNM"].ToString() + " - " + GwSite; } m_Person.GuanweiID = dt_temp.Rows[0]["GuanweiID"].ToString(); m_Person.GuanweiNM = dt_temp.Rows[0]["GuanweiNM"].ToString(); m_Person.GuanweiSite = GwSite.ToString(); m_Person.GuanweiColor = dt_temp.Rows[0]["GuanweiColor"].ToString(); m_Person.Status = dt_temp.Rows[0]["StatusName"].ToString(); m_Person.StatusColor = dt_temp.Rows[0]["StatusColor"].ToString(); m_Person.Time = dt_temp.Rows[0]["CardTime"].ToString(); m_Person.TimeColor = dt_temp.Rows[0]["CardTimeColor"].ToString(); m_Person.Remind = dt_temp.Rows[0]["warnMemo"].ToString(); m_Person.RemindColor = dt_temp.Rows[0]["warnColor"].ToString(); m_Person.LicenseType = dt_temp.Rows[0]["LicenseType"].ToString(); m_Person.LicenseColor = dt_temp.Rows[0]["LicenseColor"].ToString(); m_Person.UserID = dt_temp.Rows[0]["UserID"].ToString(); m_Person.UserName = dt_temp.Rows[0]["UserNM"].ToString(); m_Person.UserIdNmColor = dt_temp.Rows[0]["UserIdColor"].ToString(); m_Person.Tag = "0"; try { m_Person.AllEventClick -= new UserPerson.AllEvent(m_Person_AllEventClick); m_Person.DoubleClick -= new UserPerson.DoubleEvent(m_Person_DoubleClick); } catch (Exception ex) { log.Error("AllEventClick Error:" + m_Person.UserID); } m_Person.AllEventClick += new UserPerson.AllEvent(m_Person_AllEventClick); m_Person.ImageUrl = GridCommon.GetUserImage(SysParam.m_daoCommon, dt_temp.Rows[0]["UserID"].ToString()); m_Person.DoubleClick += new UserPerson.DoubleEvent(m_Person_DoubleClick); this.setImgIndex(false);//设置显示位置 //panelContent.Controls.Add(m_Person);//展示空间 m_Person.Location = _point;//设置空间展示坐标 if (!m_Person.Visible) { Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); m_Person.Visible = true; })); } gwShowSite = GwSite + 1; dt_temp.Rows[0].Delete(); if (dt_temp.Rows.Count > 0) { GwSite = int.Parse(dt_temp.Rows[0]["GuanweiSite"].ToString());//关位位置 } else { break; } } if (perFlg && GwSite == 99 && gwShowSite > bpCnt) { m_Person = (UserPerson)_lstContr2[_objcl2.u_UserPersonNum]; _objcl2.u_UserPersonNum++; //new UserPerson(); //位置相同 m_Person.TitleName = dt_temp.Rows[0]["GuanweiNM"].ToString() + " - " + gwShowSite.ToString(); if (dt_temp.Rows[0]["AttendType"].ToString() == "支援") { m_Person.TitleName = "(支)" + dt_temp.Rows[0]["GuanweiNM"].ToString() + " - " + gwShowSite.ToString(); } if (dt_temp.Rows[0]["AttendType"].ToString() == "替关") { m_Person.TitleName = "(替)" + dt_temp.Rows[0]["GuanweiNM"].ToString() + " - " + gwShowSite.ToString(); } m_Person.GuanweiID = dt_temp.Rows[0]["GuanweiID"].ToString(); m_Person.GuanweiNM = dt_temp.Rows[0]["GuanweiNM"].ToString(); m_Person.GuanweiSite = GwSite.ToString(); m_Person.GuanweiColor = dt_temp.Rows[0]["GuanweiColor"].ToString(); m_Person.Status = dt_temp.Rows[0]["StatusName"].ToString(); m_Person.StatusColor = dt_temp.Rows[0]["StatusColor"].ToString(); m_Person.Time = dt_temp.Rows[0]["CardTime"].ToString(); m_Person.TimeColor = dt_temp.Rows[0]["CardTimeColor"].ToString(); m_Person.Remind = dt_temp.Rows[0]["warnMemo"].ToString(); m_Person.RemindColor = dt_temp.Rows[0]["warnColor"].ToString(); m_Person.LicenseType = dt_temp.Rows[0]["LicenseType"].ToString(); m_Person.LicenseColor = dt_temp.Rows[0]["LicenseColor"].ToString(); m_Person.UserID = dt_temp.Rows[0]["UserID"].ToString(); m_Person.UserName = dt_temp.Rows[0]["UserNM"].ToString(); m_Person.UserIdNmColor = dt_temp.Rows[0]["UserIdColor"].ToString(); m_Person.Tag = "0"; m_Person.AllEventClick += new UserPerson.AllEvent(m_Person_AllEventClick); m_Person.ImageUrl = GridCommon.GetUserImage(SysParam.m_daoCommon, dt_temp.Rows[0]["UserID"].ToString()); m_Person.DoubleClick += new UserPerson.DoubleEvent(m_Person_DoubleClick); this.setImgIndex(false);//设置显示位置 //panelContent.Controls.Add(m_Person);//展示空间 m_Person.Location = _point;//设置空间展示坐标 if (!m_Person.Visible) { Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); m_Person.Visible = true; })); } gwShowSite++; dt_temp.Rows[0].Delete(); } else if (perFlg) { //位置不同,显示空关位 //人员信息 m_PersonNull = (UserPersonNull)_lstContr2[_objcl2.u_UserNullNum]; _objcl2.u_UserNullNum++; m_PersonNull.TitleName = m_tblGuanweiList.Rows[a]["GuanweiName"].ToString() + " - " + gwShowSite; m_PersonNull.GuanweiID = m_tblGuanweiList.Rows[a]["GuanweiID"].ToString(); m_PersonNull.GuanweiNM = m_tblGuanweiList.Rows[a]["GuanweiName"].ToString(); m_PersonNull.GuanweiSite = gwShowSite.ToString(); m_PersonNull.Tag = "0"; m_PersonNull.AllEventClick += new UserPersonNull.AllEvent(m_PersonNull_AllEventClick); m_PersonNull.ImageUrl = ""; this.setImgIndex(false);//设置显示位置 //panelContent.Controls.Add(m_PersonNull);//展示空间 m_PersonNull.Location = _point;//设置空间展示坐标 if (!m_PersonNull.Visible) { Program._frmMain.Invoke(new Action(delegate() { Application.DoEvents(); m_PersonNull.Visible = true; })); } gwShowSite++; } } } wid_Left_Cnt = 1; wid_Right_Cnt = 1; #region hide no use control //未使用的不显示 if (_oldUsedObj.gwNum <= 0) { _oldUsedObj.gwNum = _objcl2.gwNum; _oldUsedObj.u_gwNum = _objcl2.u_gwNum; _oldUsedObj.UserPersonNum = _objcl2.UserPersonNum; _oldUsedObj.u_UserPersonNum = _objcl2.u_UserPersonNum; _oldUsedObj.UserNullNum = _objcl2.UserNullNum; _oldUsedObj.u_UserNullNum = _objcl2.u_UserNullNum; } else { //关位 if (_oldUsedObj.u_gwNum >= _objcl2.u_gwNum) { for (int i = _objcl2.u_gwNum; i <= _oldUsedObj.u_gwNum; i++) { _lstContr2[i].Visible = false; } } else { _oldUsedObj.u_gwNum = _objcl2.u_gwNum; } //人员 if (_oldUsedObj.u_UserPersonNum >= _objcl2.u_UserPersonNum) { for (int i = _objcl2.u_UserPersonNum; i <= _oldUsedObj.u_UserPersonNum; i++) { _lstContr2[i].Visible = false; } } else { _oldUsedObj.u_UserPersonNum = _objcl2.u_UserPersonNum; } //空位 if (_oldUsedObj.u_UserNullNum >= _objcl2.u_UserNullNum) { for (int i = _objcl2.u_UserNullNum; i <= _oldUsedObj.u_UserNullNum; i++) { _lstContr2[i].Visible = false; } } else { _oldUsedObj.u_UserNullNum = _objcl2.u_UserNullNum; } } #endregion this.ResumeLayout(false); this.PerformLayout(); } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("考勤数据加载失败!" + ex); FrmDialog.ShowDialog(); } finally { Program.logFlagEnd(log, s, "获取考勤人员信息一览"); this.TopMost = true; } }
} //防止闪烁 /// <summary> /// 窗体初始化处理 /// </summary> public override void SetFormValue() { try { dtStartTime.Text = DateTime.Now.ToString("yyyy-MM-dd"); } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog( "画面初始化失败!"+ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 窗体初始化处理 /// </summary> public override void SetFormValue() { try { if (this.parMyteamName != "") { lookmyteamName.Text = this.parMyteamName; } else { lookmyteamName.Text = Common._myTeamName; } if (this.parDdateOperDate != "") { dateOperDate1.EditValue = this.parDdateOperDate; } else { dateOperDate1.EditValue = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); } isLoad = false; } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("画面初始化失败!" + ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 获取选中人员信息 /// </summary> public void GetFormList(ref DataTable dt_temp) { try { //this.TopMost = false; dt_temp = m_tblDataList.Clone(); foreach (var col in panelContent.Controls) { if (col.GetType().ToString() == "MachineSystem.UserControls.UserPerson") { UserPerson person = col as UserPerson; if (person.Tag.ToString() == "1") //选中的人员 { DataView view = new DataView(m_tblDataList.Copy()); view.RowFilter = "UserID='" + person.UserID + "'"; if (view.ToTable().Rows.Count > 0) { dt_temp.Rows.Add(view.ToTable().Rows[0].ItemArray); } } } } } catch (Exception ex) { FrmAttendDialog FrmDialog = new FrmAttendDialog("界面初始化失败!" + ex); FrmDialog.ShowDialog(); } }
/// <summary> /// 刷新页面数据 /// </summary> private void btnRef_Click(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; panelContent.Refresh(); if (isEditValue) { return; } isEditValue = true; this.btnRef.Enabled = false; try { SetExecuteAttendResult(); } catch (Exception ex) { log.Error(ex); FrmAttendDialog FrmDialog = new FrmAttendDialog("数据刷新失败!" + ex); FrmDialog.ShowDialog(); } finally { isEditValue = false; this.btnRef.Enabled = true; this.Cursor = Cursors.Default; } }
/// <summary> /// 欠勤登记 /// </summary> private void btnLessFrequently_Click(object sender, EventArgs e) { //this.TopMost = false; frmLessFrequently frm = new frmLessFrequently(); DataTable dt_temp = new DataTable(); GetFormList(ref dt_temp); if (dt_temp.Rows.Count == 0) { FrmAttendDialog FrmDialog = new FrmAttendDialog("未选中任何人员信息!"); FrmDialog.ShowDialog(); return; } frm.m_tblDataList = dt_temp; frm.m_DataTime = DateTime.Parse(dateOperDate1.Text.Trim()); if (frm.ShowDialog() == DialogResult.OK) { //自动刷新 btnRef(); } }
/// <summary> /// 人员调动:保存 /// </summary> private void btnSave_Click(object sender, EventArgs e) { //this.TopMost = false; if (txtFrom.Text == "" || txtTo.Text == "" || m_tblAllList.Rows.Count == 0) { return; } if (DateTime.Parse(dtpStartDate.Text.Trim()) >= DateTime.Parse(dtpEndDate.Text.Trim()) && (pflag == "4" || pflag == "5" || pflag == "6"))// 4 支援调出 5 支援调入 6 替关调动 { FrmAttendDialog FrmDialog = new FrmAttendDialog("【结束时间】必须大于【开始时间】!"); FrmDialog.ShowDialog(); return; } m_tblAllList = new DataTable(); string str_sql = string.Format(@"select distinct JobForID,JobForName,ProjectID,ProjectName,LineID,LineName,TeamID from V_Produce_para where myTeamName='{0}' ", lookmyteamName.Text.Trim()); m_tblAllList = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); try { Common.AdoConnect.Connect.CreateSqlTransaction(); int result = 0; //人员调动类型; pflag 1 人员调入 2 人员调出 3 关位调整 4 支援调出 5 支援调入 6 替关调动 str_sql = string.Empty; string strGuanweiID = string.Empty; string strGuanweiSite = string.Empty; //From人员信息:moveFromPerson switch (pflag) { case "1"://1 人员调入 //修改用户line信息 m_dicPrimarName.Clear(); m_dicPrimarName["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData.Clear(); m_dicItemData["userID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["AttendUnit"] = "1"; if (moveToPersonFlg == "1") //1:moveToPersonList {//To工种信息 moveToPersonList strGuanweiID = moveToPersonList.GuanweiID.ToString(); strGuanweiSite = "99";//关位位置 } else if (moveToPersonFlg == "2")//2:moveToPerson {//To人员信息 moveToPerson; strGuanweiID = moveToPerson.GuanweiID.ToString(); strGuanweiSite = moveToPerson.GuanweiSite;//关位位置 } else if (moveToPersonFlg == "3")//3:moveToPersonNull {//To人员空位信息 moveToPersonNull strGuanweiID = moveToPersonNull.GuanweiID.ToString(); strGuanweiSite = moveToPersonNull.GuanweiSite;//关位位置 } m_dicItemData["GuanweiID"] = strGuanweiID; m_dicItemData["GuanweiSite"] = strGuanweiSite;//关位位置 ////查询当前关位下是否有两个人员,如果是这不能继续添加 //str_sql = string.Format(@"select AttendDate from Attend_Total_Result where JobForID='{0}' and ProjectID='{1}' and LineID='{2}' and TeamID='{3}' and GuanWeiID='{4}' and GuanweiSite='{5}' and AttendDate='{6}'", // m_dicItemData["JobForID"], m_dicItemData["ProjectID"], m_dicItemData["LineID"], m_dicItemData["TeamID"], strGuanweiID, strGuanweiSite, dateOperDate1.Text.Trim()); //DataTable dt = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); //if (dt.Rows.Count >= 2) //{ // FrmAttendDialog FrmDialog = new FrmAttendDialog("当前关位最多只能添加两个人!"); // FrmDialog.ShowDialog(); // return; //} //更新考勤单位是1的数据到Produce_User表中 result = SysParam.m_daoCommon.SetModifyDataItem("Produce_User", m_dicItemData, m_dicPrimarName); m_dicItemData.Clear(); m_dicItemData["userID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["GuanweiID"] = strGuanweiID; m_dicItemData["GuanweiSite"] = strGuanweiSite;//关位位置 //增加调动信息 m_dicItemData["StrDate"] = dtpStartDate.EditValue.ToString(); m_dicItemData["EndDate"] = "4000-01-01"; m_dicItemData["PFlag"] = pFlag.pflag1.GetHashCode().ToString(); m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Attend_Move, m_dicItemData); if (result > 0) { result=SetUserInfoToEmployee(m_dicItemData["userID"], m_tblAllList.Rows[0]["JobForName"].ToString(), m_tblAllList.Rows[0]["ProjectName"].ToString(), m_tblAllList.Rows[0]["LineName"].ToString(), moveToPersonNull.GuanweiNM); Common.AdoConnect.Connect.TransactionCommit(); FrmMoveDialog frmMoveDialog = new FrmMoveDialog("人员调入", txtFrom.Text, txtTo.Text, dtpStartDate.EditValue.ToString(), ""); frmMoveDialog.ShowDialog(); //日志 SysParam.m_daoCommon.WriteLog("平板-人员调动-人员调入", "新增", moveFromPerson.UserName); //自动刷新 btnRef_Click(null, null); } break; case "2":// 2 人员调出 //From人员信息:moveFromPerson --moveToPersonNull //1、清除人员信息表中的line信息 if (moveFromPerson.TitleName.Contains("支")) { XtraMsgBox.Show("当前支援人员不能支援调出!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } m_dicPrimarName.Clear(); m_dicPrimarName["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData.Clear(); m_dicItemData["userID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = "0"; m_dicItemData["ProjectID"] = "0"; m_dicItemData["LineID"] = "0"; m_dicItemData["TeamID"] = "0"; m_dicItemData["GuanweiID"] = "0"; m_dicItemData["GuanweiSite"] = "0"; m_dicItemData["AttendUnit"] = "0"; m_dicItemData["AttendUnit"] = "1"; //更新考勤单位是1的数据到Produce_User表中 result = SysParam.m_daoCommon.SetModifyDataItem("Produce_User", m_dicItemData, m_dicPrimarName); //更新人员调入,关位调整数据的结束日期 str_sql = string.Format(@"update Attend_Move set EndDate='{0}' ,OperID='{1}', OperDate='{2}' where 1=1 AND UserID='{3}' AND EndDate='4000-01-01'", dtpStartDate.EditValue.ToString(), Common._personid, DateTime.Now.ToString(), moveFromPerson.UserID.ToString()); result = SysParam.m_daoCommon.SetModifyDataItemBySql(str_sql, new StringDictionary(), new StringDictionary(), new StringDictionary()); //增加人员调出信息 m_dicPrimarName.Clear(); m_dicItemData.Clear(); m_dicItemData["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["GuanweiID"] = moveFromPerson.GuanweiID.ToString(); m_dicItemData["GuanweiSite"] = moveFromPerson.GuanweiSite;//关位位置 m_dicItemData["StrDate"] = dtpStartDate.EditValue.ToString(); m_dicItemData["EndDate"] = "1900-01-01"; m_dicItemData["PFlag"] = pFlag.pflag2.GetHashCode().ToString(); m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Attend_Move, m_dicItemData); if (result > 0) { result = SetUserInfoToEmployee(m_dicItemData["userID"], m_tblAllList.Rows[0]["JobForName"].ToString(), m_tblAllList.Rows[0]["ProjectName"].ToString(), m_tblAllList.Rows[0]["LineName"].ToString(), moveToPersonNull.GuanweiNM); Common.AdoConnect.Connect.TransactionCommit(); FrmMoveDialog frmMoveDialog = new FrmMoveDialog("人员调出", txtFrom.Text, txtTo.Text, dtpStartDate.EditValue.ToString(), ""); frmMoveDialog.ShowDialog(); //日志 SysParam.m_daoCommon.WriteLog("平板-人员调动-人员调出", "新增", moveFromPerson.UserName); //自动刷新 btnRef_Click(null, null); } break; case "3"://3 关位调整 //From人员信息:moveFromPerson m_dicPrimarName.Clear(); m_dicPrimarName["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData.Clear(); m_dicItemData["userID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["AttendUnit"] = "1"; if (moveToPersonFlg == "1") //1:moveToPersonList {//To工种信息 moveToPersonList strGuanweiID = moveToPersonList.GuanweiID.ToString(); strGuanweiSite = "99";//关位位置 } else if (moveToPersonFlg == "2")//2:moveToPerson {//To人员信息 moveToPerson; strGuanweiID = moveToPerson.GuanweiID.ToString(); strGuanweiSite = moveToPerson.GuanweiSite;//关位位置 } else if (moveToPersonFlg == "3")//3:moveToPersonNull {//To人员空位信息 moveToPersonNull strGuanweiID = moveToPersonNull.GuanweiID.ToString(); strGuanweiSite = moveToPersonNull.GuanweiSite;//关位位置 } m_dicItemData["GuanweiID"] = strGuanweiID; m_dicItemData["GuanweiSite"] = strGuanweiSite;//关位位置 //更新考勤单位是1的数据到Produce_User表中 result = SysParam.m_daoCommon.SetModifyDataItem("Produce_User", m_dicItemData, m_dicPrimarName); //更新人员调入,关位调整数据 //更新人员调入,关位调整数据的结束日期 str_sql = string.Format(@"update Attend_Move set EndDate='{0}', OperID='{1}', OperDate='{2}' where 1=1 AND UserID='{3}' AND EndDate='4000-01-01'", dtpStartDate.EditValue.ToString(), Common._personid, DateTime.Now.ToString(), moveFromPerson.UserID.ToString()); result = SysParam.m_daoCommon.SetModifyDataItemBySql(str_sql, new StringDictionary(), new StringDictionary(), new StringDictionary()); //增加调动信息 m_dicItemData.Clear(); m_dicItemData["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["GuanweiID"] = strGuanweiID; m_dicItemData["GuanweiSite"] = strGuanweiSite;//关位位置 m_dicItemData["StrDate"] = dtpStartDate.EditValue.ToString(); m_dicItemData["EndDate"] = "4000-01-01"; m_dicItemData["PFlag"] = pFlag.pflag3.GetHashCode().ToString(); m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Attend_Move, m_dicItemData); if (result > 0) { result = SetUserInfoToEmployee(m_dicItemData["userID"], m_tblAllList.Rows[0]["JobForName"].ToString(), m_tblAllList.Rows[0]["ProjectName"].ToString(), m_tblAllList.Rows[0]["LineName"].ToString(), moveToPersonNull.GuanweiNM); Common.AdoConnect.Connect.TransactionCommit(); FrmMoveDialog frmMoveDialog = new FrmMoveDialog("关位调整", txtFrom.Text, txtTo.Text, dtpStartDate.EditValue.ToString(), ""); frmMoveDialog.ShowDialog(); //日志 SysParam.m_daoCommon.WriteLog("平板-人员调动-关位调整", "新增", moveFromPerson.UserName); //DialogResult = DialogResult.OK; //自动刷新 btnRef_Click(null, null); } break; case "4"://4 支援调出 if (moveFromPerson.TitleName.Contains("支")) { XtraMsgBox.Show("当前支援人员不能支援调出!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //增加调动信息:保存调出前的向别,关位信息 m_dicItemData.Clear(); m_dicItemData["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["StrDate"] = dtpStartDate.EditValue.ToString(); m_dicItemData["EndDate"] = dtpEndDate.EditValue.ToString(); m_dicItemData["PFlag"] = pFlag.pflag4.GetHashCode().ToString(); m_dicItemData["GuanweiID"] = moveFromPerson.GuanweiID.ToString(); m_dicItemData["GuanweiSite"] = moveFromPerson.GuanweiSite;//关位位置 m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Attend_Move, m_dicItemData); if (result > 0) { Common.AdoConnect.Connect.TransactionCommit(); FrmMoveDialog frmMoveDialog = new FrmMoveDialog("支援调出", txtFrom.Text, txtTo.Text, dtpStartDate.EditValue.ToString(), dtpEndDate.EditValue.ToString()); frmMoveDialog.ShowDialog(); //日志 SysParam.m_daoCommon.WriteLog("平板-人员调动-支援调出", "新增", moveFromPerson.UserName); //自动刷新 btnRef_Click(null, null); } break; case "5"://5 支援调入 //增加调动信息:保存调入后的向别,关位信息 if (moveFromPerson.ProjectID == m_tblAllList.Rows[0]["ProjectID"].ToString() && moveFromPerson.JobForID == m_tblAllList.Rows[0]["JobForID"].ToString() && moveFromPerson.LineID == m_tblAllList.Rows[0]["LineID"].ToString()) { XtraMsgBox.Show("当前支援人员不能支援调入!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } m_dicItemData.Clear(); m_dicItemData["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["StrDate"] = dtpStartDate.EditValue.ToString(); m_dicItemData["EndDate"] = dtpEndDate.EditValue.ToString(); m_dicItemData["PFlag"] = pFlag.pflag5.GetHashCode().ToString(); if (moveToPersonFlg == "1") //1:moveToPersonList {//To工种信息 moveToPersonList strGuanweiID = moveToPersonList.GuanweiID.ToString(); strGuanweiSite = "99";//关位位置 } else if (moveToPersonFlg == "2")//2:moveToPerson {//To人员信息 moveToPerson; strGuanweiID = moveToPerson.GuanweiID.ToString(); strGuanweiSite = moveToPerson.GuanweiSite;//关位位置 } else if (moveToPersonFlg == "3")//3:moveToPersonNull {//To人员空位信息 moveToPersonNull strGuanweiID = moveToPersonNull.GuanweiID.ToString(); strGuanweiSite = moveToPersonNull.GuanweiSite;//关位位置 } m_dicItemData["GuanweiID"] = strGuanweiID; m_dicItemData["GuanweiSite"] = strGuanweiSite;//关位位置 m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Attend_Move, m_dicItemData); if (result > 0) { Common.AdoConnect.Connect.TransactionCommit(); FrmMoveDialog frmMoveDialog = new FrmMoveDialog("支援调入", txtFrom.Text, txtTo.Text, dtpStartDate.EditValue.ToString(), dtpEndDate.EditValue.ToString()); frmMoveDialog.ShowDialog(); //日志 SysParam.m_daoCommon.WriteLog("平板-人员调动-支援调入", "新增", moveFromPerson.UserName); //自动刷新 btnRef_Click(null, null); } break; case "6"://6 替关调动 //增加调动信息:保存需要替关的向别,关位信息 m_dicItemData.Clear(); m_dicItemData["UserID"] = moveFromPerson.UserID.ToString(); m_dicItemData["JobForID"] = m_tblAllList.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = m_tblAllList.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = m_tblAllList.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = m_tblAllList.Rows[0]["TeamID"].ToString(); m_dicItemData["StrDate"] = dtpStartDate.EditValue.ToString(); m_dicItemData["EndDate"] = dtpEndDate.EditValue.ToString(); m_dicItemData["PFlag"] = pFlag.pflag6.GetHashCode().ToString(); if (moveToPersonFlg == "1") //1:moveToPersonList {//To工种信息 moveToPersonList strGuanweiID = moveToPersonList.GuanweiID.ToString(); strGuanweiSite = "99";//关位位置 } else if (moveToPersonFlg == "2")//2:moveToPerson {//To人员信息 moveToPerson; strGuanweiID = moveToPerson.GuanweiID.ToString(); strGuanweiSite = moveToPerson.GuanweiSite;//关位位置 } else if (moveToPersonFlg == "3")//3:moveToPersonNull {//To人员空位信息 moveToPersonNull strGuanweiID = moveToPersonNull.GuanweiID.ToString(); strGuanweiSite = moveToPersonNull.GuanweiSite;//关位位置 } m_dicItemData["GuanweiID"] = strGuanweiID; m_dicItemData["GuanweiSite"] = strGuanweiSite;//关位位置 m_dicItemData["OperID"] = Common._personid; m_dicItemData["OperDate"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Attend_Move, m_dicItemData); if (result > 0) { Common.AdoConnect.Connect.TransactionCommit(); FrmMoveDialog frmMoveDialog = new FrmMoveDialog("替关调动", txtFrom.Text, txtTo.Text, dtpStartDate.EditValue.ToString(), dtpEndDate.EditValue.ToString()); frmMoveDialog.ShowDialog(); //日志 SysParam.m_daoCommon.WriteLog("平板-人员调动-替关调动", "新增", moveFromPerson.UserName); //自动刷新 btnRef_Click(null, null); } break; default: break; } } catch (Exception ex) { Common.AdoConnect.Connect.TransactionRollback(); log.Error(ex); } finally { this.TopMost = true; } }
/// <summary> /// 保存加班登记 /// </summary> private void btnSave_Click(object sender, EventArgs e) { try { int result = 0; gridView1.CloseEditor(); gridView1.UpdateCurrentRow(); DataTable dt_Data = ((DataView)this.gridView1.DataSource).Table.Copy(); dt_Data.AcceptChanges(); //DataView view = new DataView(dt_Data.Copy()); //view.Sort = "StrDate"; //dt_Data = view.ToTable(); string str_sql = string.Empty; //向别-班别 str_sql = string.Format(@"select * from V_Produce_para where myTeamName ='{0}'", m_teamName); DataTable dt_temp = SysParam.m_daoCommon.GetTableInfoBySqlNoWhere(str_sql); Common.AdoConnect.Connect.CreateSqlTransaction(); //先删除Attend_TeamSet对应向别的数据在添加 m_dicItemData.Clear(); m_dicPrimarName.Clear(); m_dicItemData["JobForID"] = dt_temp.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = dt_temp.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = dt_temp.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = dt_temp.Rows[0]["TeamID"].ToString(); m_dicPrimarName["JobForID"] = "true"; m_dicPrimarName["LineID"] = "true"; result = SysParam.m_daoCommon.SetDeleteDataItem(TableNames.Attend_TeamSet, m_dicItemData, m_dicPrimarName); for (int i = 0; i < dt_Data.Rows.Count; i++) { if (i == dt_Data.Rows.Count - 1) { continue; } if (i > 0 && DateTime.Compare(DateTime.Parse(dt_Data.Rows[i]["StrDate"].ToString()), DateTime.Parse(dt_Data.Rows[i - 1]["EndDate"].ToString())) < 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog("第【" + (i + 1) + "】行【" + dt_Data.Rows[i]["StrDate"].ToString() + "】\n月排班开始时间不能小于上月的结束时间!"); FrmDialog.ShowDialog(); return; } if (DateTime.Compare(DateTime.Parse(dt_Data.Rows[i]["EndDate"].ToString()), DateTime.Parse(dt_Data.Rows[i]["StrDate"].ToString())) < 0) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog("第【" + (i + 1) + "】行【" + dt_Data.Rows[i]["StrDate"].ToString() + "】\n月排班开始时间不能小于结束时间!"); FrmDialog.ShowDialog(); return; } m_dicItemData.Clear(); m_dicItemData["JobForID"] = dt_temp.Rows[0]["JobForID"].ToString(); m_dicItemData["ProjectID"] = dt_temp.Rows[0]["ProjectID"].ToString(); m_dicItemData["LineID"] = dt_temp.Rows[0]["LineID"].ToString(); m_dicItemData["TeamID"] = dt_temp.Rows[0]["TeamID"].ToString(); m_dicItemData["BgnDate"] = dt_Data.Rows[i]["StrDate"].ToString();//开始时间 m_dicItemData["EndDate"] = dt_Data.Rows[i]["EndDate"].ToString();//结束时间 m_dicItemData["pTypeID"] = dt_Data.Rows[i]["pTypeID"].ToString(); ;//班种 m_dicItemData["Operid"] = Common._personid; m_dicItemData["OperTime"] = DateTime.Now.ToString(); result = SysParam.m_daoCommon.SetInsertDataItem(TableNames.Attend_TeamSet, m_dicItemData); } ////删除界面已删除的数据 //StringDictionary dicItemData = new StringDictionary(); //StringDictionary dicPrimar = new StringDictionary(); //foreach (string value in m_hashtable.Values) //{ // dicItemData["ID"] = value; // dicPrimar["ID"] = value; // result = SysParam.m_daoCommon.SetDeleteDataItem(TableNames.Attend_TeamSet, dicItemData, dicPrimar); //} Common.AdoConnect.Connect.TransactionCommit(); FrmAttendDialog FrmDialogs = new FrmAttendDialog("保存数据成功!"); FrmDialogs.ShowDialog(); this.Close(); } catch (Exception ex) { Common.AdoConnect.Connect.TransactionRollback(); FrmAttendDialog FrmDialog = new FrmAttendDialog("保存数据失败!" + ex); FrmDialog.ShowDialog(); log.Error(ex); } }