12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- using System.Data.SqlClient;
- using System.Windows.Forms;
- using System.Web.UI.WebControls;
- using System.Collections;
- using System.Threading;
- using LYFZ.Software.MainBusiness.DoorCityProcess;
- using System.Dynamic;
- namespace LYFZ.Software.MainBusiness.TimeAndAttendance
- {
- public class frmTimeStatistics : LYFZ.Software.UI.TimeAndAttendance.frmTimeStatistics
- {
- DataSet dsData = new DataSet();
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_Loninbansets lonindansets = new BLL.BLL_Loninbansets();
- public frmTimeStatistics()
- {
- this.Load += frmTimeStatistics_Load;
- this.btnLastWeek.Click += btnLastWeek_Click;
- this.btnNextWeek.Click += btnNextWeek_Click;
- this.btnExport.Click += btnExport_Click;
- this.btnPrint.Click += btnPrint_Click;
- this.chkWeekMode.Click += chkWeekMode_Click;
- this.dgvData.CellMouseDoubleClick += dgvData_CellMouseDoubleClick;
- this.dtpYearMonth.ClickChengedValue += dtpYearMonth_ClickChengedValue;
- this.btnClose.Click += btnClose_Click;
- cbxCompanyList.ComboBoxTree_NodeMouseClick += CbxCompanyList_ComboBoxTree_NodeMouseClick;
- //BindCompanyList();
- //cbxCompanyList.SelectedIndexChanged += cbxCompanyList_SelectedIndexChanged;
- }
- private void CbxCompanyList_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- if (!this.chkWeekMode.Checked)
- { this.dtpYearMonth_ClickChengedValue(""); }
- else
- { this.GetWeekData(); }
- }
- void cbxCompanyList_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (chkWeekMode.Checked)
- {
- GetWeekData();
- }
- else
- {
- dtpYearMonth_ClickChengedValue("");
- }
-
- }
- void BindCompanyList()
- {
- BLL.BLL_ErpCompanyInfo bllCompany = new BLL.BLL_ErpCompanyInfo();
- DataTable dt = bllCompany.GetAllList().Tables[0];
- cbxCompanyList.Items.Add(new ItemValue("", "全部"));
- foreach (DataRow dr in dt.Rows)
- {
- cbxCompanyList.Items.Add(new ItemValue(dr["Company_DividedShop"].ToString(), dr["Company_Name"].ToString_s()));
- }
- cbxCompanyList.SelectedIndex = 0;
- }
- DateTime WeekStartDate;
- DateTime WeekEndDate;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void frmTimeStatistics_Load(object sender, EventArgs e)
- {
- this.panelLastNextWeek.Visible = false;
- this.dgvData.dgvColumnHeadersHeight = 48;
- this.dgvData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.EnableResizing;
- this.dgvData.ColumnHeadersHeight = 48;
- Control.CheckForIllegalCrossThreadCalls = false;
- this.dtpYearMonth.StrDateValue = SDateTime.Now.ToString("yyyy-MM");
- // 部门人员绑定
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cbxCompanyList, IsFirstNodeNull: true, IsFirstNodeName: "全部", IsShowResign: false, IsShowAdmin: true, tb_User: LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable);
- this.cbxCompanyList.AfterSelectLevelFirstNode = true;
- this.cbxCompanyList.IsNodeMouseClick = true;
- this.cbxCompanyList.IsSelectParentNode = true;
- cbxCompanyList.TextFindTag("全部");
- #region 获取本周
- this.WeekStartDate = SDateTime.Now.AddDays(Convert.ToInt32(SDateTime.Now.DayOfWeek) * -1);
- this.WeekEndDate = SDateTime.Now.AddDays(6 - Convert.ToInt32(SDateTime.Now.DayOfWeek));
- #endregion
- this.chkWeekMode.Checked = true;
- if (!this.chkWeekMode.Checked)
- { this.dtpYearMonth_ClickChengedValue(""); }
- else
- { this.GetWeekData(); }
- }
- /// <summary>
- /// 上一个星期
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnLastWeek_Click(object sender, EventArgs e)
- {
- this.dgvData.Rows.Clear();
- this.WeekStartDate = this.WeekStartDate.AddDays(-7);
- this.WeekEndDate = this.WeekEndDate.AddDays(-7);
- this.GetWeekData();
- }
- /// <summary>
- /// 下一个星期
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnNextWeek_Click(object sender, EventArgs e)
- {
- this.dgvData.Rows.Clear();
- this.WeekStartDate = this.WeekStartDate.AddDays(7);
- this.WeekEndDate = this.WeekEndDate.AddDays(7);
- this.GetWeekData();
- }
- /// <summary>
- /// 周模式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkWeekMode_Click(object sender, EventArgs e)
- {
- if (this.chkWeekMode.Checked)
- {
- this.GetWeekData();
- }
- else
- {
- this.dtpYearMonth_ClickChengedValue("");
- }
- }
- /// <summary>
- /// 导出Excel
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnExport_Click(object sender, EventArgs e)
- {
- string StrModelName = "";
- if (this.chkWeekMode.Checked)
- { StrModelName = this.lblWhichWeek.Text.Trim(); }
- else
- { StrModelName = this.dtpYearMonth.StrDateValue.Trim(); }
- this.dgvData.ExportDataTable(StrModelName);
- }
- /// <summary>
- /// 打印
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnPrint_Click(object sender, EventArgs e)
- {
- try
- {
- Hashtable htData = new Hashtable();
- htData["y"] = this.dgvData.CurrentCellAddress.Y;
- int yyyy = Convert.ToInt32(this.dtpYearMonth.StrYear);
- int MM = Convert.ToInt32(this.dtpYearMonth.StrMonth);
- int chk = 0;
- if (!this.chkWeekMode.Checked)
- { chk = 0; }
- else
- { chk = 1; }
- htData["chk"] = chk;
- htData["time1"] = this.dtpYearMonth.StrYear;
- htData["time2"] = this.dtpYearMonth.StrMonth;
- htData["dgvData"] = this.dgvData;
- LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(EnumPublic.PrintTypeEnum.考勤报表, htData);
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message); }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 双击查看考勤详情
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
- {
- if (this.dgvData.Columns[e.ColumnIndex].Tag != null)
- {
- LYFZ.Software.MainBusiness.TimeAndAttendance.SetSmallForm.AttendanceDetailsSmallForm frm = new SetSmallForm.AttendanceDetailsSmallForm();
- frm.StrUserName = this.dgvData.Rows[e.RowIndex].Cells["姓名"].Value.ToString().Trim();
- frm.StrUserNumber = this.dgvData.Rows[e.RowIndex].Cells["编号"].Value.ToString().Trim();
- frm.StrDateTime = this.dgvData.Columns[e.ColumnIndex].Tag.ToString();
- frm.Show();
- }
- }
- }
- /// <summary>
- /// 获取工作数据
- /// </summary>
- /// <param name="StrWeekStartDate"></param>
- /// <param name="StrWeekEndDate"></param>
- /// <param name="WorkCount"></param>
- DataTable GetWorkData(string StrWeekStartDate, string StrWeekEndDate, int WorkCount,string companyWhere="")
- {
-
- DataTable newTable = new DataTable();
- newTable.Columns.Add("编号", typeof(string));
- newTable.Columns.Add("姓名", typeof(string));
- newTable.Columns.Add("迟到", typeof(string));
- newTable.Columns.Add("早退", typeof(string));
- newTable.Columns.Add("旷工", typeof(string));
- newTable.Columns.Add("漏打卡", typeof(string));
- newTable.Columns.Add("休息", typeof(string));
- newTable.Columns.Add("请假", typeof(string));
- for (int i = 0; i < WorkCount; i++)
- { newTable.Columns.Add(i.ToString().Trim(), typeof(string)); }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- string ExecuteSql = "select User_EmployeeID,User_Name,User_FirstFingerprintID,User_SecondaryFingerprintID from tb_ErpUser Where User_Status='在职' And User_Account <> 'admin' " + companyWhere + " ;";
- ExecuteSql += "select ID,User_ID,Time,fixed from loninbansets Where " + PublicCodeClasses.GetDateTime("Time", StrWeekStartDate, StrWeekEndDate, ConnectWord: "") + " and fixed !='' ;";
- ExecuteSql += "select no,dbo.fn_CheckDateTime(datetime) AS datetime from dbo.lonindata Where " + PublicCodeClasses.GetDateTime("datetime", StrWeekStartDate, StrWeekEndDate, ConnectWord: "") + " Group By no,dbo.fn_CheckDateTime(datetime);";
- ExecuteSql += "select type,date,user_id from loginsign Where " + PublicCodeClasses.GetDateTime("convert(datetime,date)", StrWeekStartDate, StrWeekEndDate, ConnectWord: "") + ";";
- ExecuteSql += "select time1,time2,time3,time4,name from lonintimeset;";
- DataSet dtSet = orbll.GetView_Custom(ExecuteSql);
- BindAttendanceStatistics(dtSet, newTable, StrWeekStartDate, WorkCount);
- #region 作废考勤统计
- //DataTable dt = dtSet.Tables["ds"];
- //DataTable dtPaibanSet = dtSet.Tables["ds1"];
- ////dtPaibanSet.PrimaryKey = new DataColumn[] { dtPaibanSet.Columns["User_ID"], dtPaibanSet.Columns["Time"] };
- //DataTable dtKaoqin = dtSet.Tables["ds2"];
- //DataTable dtQiandao = dtSet.Tables["ds3"];
- //DataTable dtBanchiSet = dtSet.Tables["ds4"];
- //dtBanchiSet.PrimaryKey = new DataColumn[] { dtBanchiSet.Columns["name"] };
- //for (int i = 0; i < dt.Rows.Count; i++)
- //{
- // string StrUserName = dt.Rows[i]["User_Name"].ToString().Trim();
- // DataRow newdtRow = newTable.NewRow();
- // int intLateToCount = 0;
- // int intEarlyGoCount = 0;
- // int intKuangGongCount = 0;
- // int intMissedPunch=0;
- // #region 处理一个星期的每天考勤情况
- // for (int j = 0; j < WorkCount; j++)
- // {
- // try
- // {
- // Dictionary<string, string> dataTimeList = new Dictionary<string, string>();
- // string StrDateTime = Convert.ToDateTime(StrWeekStartDate).AddDays(j).ToString("yyyy-MM-dd");
- // //排班
- // DataRow[] dtRow_PaibanSet = dtPaibanSet.Select( "User_ID = '"+ dt.Rows[i]["User_EmployeeID"].ToString().Trim() +"' and Time = '" + Convert.ToDateTime(StrDateTime).ToString("yyyy-MM-dd")+"'" );
- // //打卡
- // DataRow[] dtRows_Kaoqin = dtKaoqin.Select("no in ('" + dt.Rows[i]["User_FirstFingerprintID"].ToString().Trim() + "','" + dt.Rows[i]["User_SecondaryFingerprintID"].ToString().Trim() + "')" + PublicCodeClasses.GetDateTime2("datetime", StrDateTime, StrDateTime), sort: "datetime");
- // //签单
- // DataRow[] dtRows_Qiandao = dtQiandao.Select("user_id = '" + dt.Rows[i]["User_EmployeeID"].ToString().Trim() + "' And date = '" + StrDateTime + "'");
- // string StrTextString = "";
- // for (int k = 0; k < dtRows_Qiandao.Length; k++)
- // { StrTextString += dtRows_Qiandao[k]["type"].ToString().Trim() + ","; }
- // string StrValueText = "";
- // bool IsFindValueText = true;
- // if (dtRow_PaibanSet.Length>0)
- // {
- // #region 有安排班次
- // int forLateToCount = 0;
- // int forEarlyGoCount = 0;
- // StrValueText = dtRow_PaibanSet[0]["fixed"].ToString().Trim();
- // //班次设置
- // DataRow dtRow = dtBanchiSet.Rows.Find(dtRow_PaibanSet[0]["fixed"].ToString().Trim());
- // if (dtRow != null)
- // {
- // string StrText = "";
- // if (!string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // { StrText = "[A-B][C-D]"; }
- // else
- // { StrText = "[A-B]"; }
- // #region 处理签到
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrAllDay.Trim()) != -1)
- // {
- // if (!string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // {
- // dataTimeList.Add("time1", "签单");
- // dataTimeList.Add("time2", "签单");
- // dataTimeList.Add("time3", "签单");
- // dataTimeList.Add("time4", "签单");
- // StrText = StrText.Replace("A", "签单").Replace("B", "签单").Replace("C", "签单").Replace("D", "签单");
- // }
- // else
- // {
- // dataTimeList.Add("time1", "签单");
- // dataTimeList.Add("time2", "签单");
- // StrText = StrText.Replace("A", "签单").Replace("B", "签单");
- // }
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoToAndOffWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time1", "签单");
- // dataTimeList.Add("time2", "签单");
- // StrText = StrText.Replace("A", "签单").Replace("B", "签单");
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoToAndOffWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time3", "签单");
- // dataTimeList.Add("time4", "签单");
- // StrText = StrText.Replace("C", "签单").Replace("D", "签单");
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoToWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time1", "签单");
- // StrText = StrText.Replace("A", "签单");
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoOffWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time2", "签单");
- // StrText = StrText.Replace("B", "签单");
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrSecondParagraph_GoToWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time3", "签单");
- // StrText = StrText.Replace("C", "签单");
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrSecondParagraph_GoOffWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time4", "签单");
- // StrText = StrText.Replace("D", "签单");
- // }
- // #endregion
- // #region 获取每个班段的每个打卡的上班下班的时间点
- // string StrFirstParagraphDateTime = "";
- // string StrFirstParagraphDateTimeToMin = "";
- // string StrFirstParagraphDateTimeToMax = "";
- // string StrSecondParagraphDateTimeToMin = "";
- // string StrSecondParagraphDateTimeToMax = "";
- // for (int k = 0; k < dtRows_Kaoqin.Length; k++)
- // {
- // //遍历获取第一班段的上班时间的最先一次打卡记录,获取时间范围在第一班段的下班时间以前打的卡
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) <= Convert.ToDateTime(StrDateTime + " " + dtRow["time2"].ToString().Trim()))
- // {
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTime))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) < Convert.ToDateTime(StrFirstParagraphDateTime))
- // { StrFirstParagraphDateTime = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // else
- // {
- // StrFirstParagraphDateTime = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm");
- // }
- // }
- // //1.获取第一班段的下班最小时间(范围大于第一班段下班时间并小于第二班段的上班时间)
- // //2.获取第一班段的下班最大时间(范围大于第一班段下班时间并小于第二班段的上班时间)
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) >= Convert.ToDateTime(StrDateTime + " " + dtRow["time2"].ToString().Trim()).AddMinutes(-30))
- // {
- // //如果没有第二班段,则获取最后打卡下班时间
- // if (!string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) <= Convert.ToDateTime(StrDateTime + " " + dtRow["time3"].ToString().Trim()))
- // {
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMin))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) < Convert.ToDateTime(StrFirstParagraphDateTimeToMin))
- // { StrFirstParagraphDateTimeToMin = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) > Convert.ToDateTime(StrFirstParagraphDateTimeToMin))
- // { StrFirstParagraphDateTimeToMax = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // else
- // {
- // StrFirstParagraphDateTimeToMin = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm");
- // //StrFirstParagraphDateTimeToMax = StrFirstParagraphDateTimeToMin;
- // }
- // }
- // }
- // else if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMin))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) > Convert.ToDateTime(StrFirstParagraphDateTimeToMin))
- // { StrFirstParagraphDateTimeToMin = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // else
- // { StrFirstParagraphDateTimeToMin = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // //else if (Convert.ToDateTime(dtRows2[k]["datetime"]) < Convert.ToDateTime(StrDateTime + " " + dtRow["time2"].ToString().Trim()) && Convert.ToDateTime(dtRows2[k]["datetime"]) >= Convert.ToDateTime(StrDateTime + " " + dtRow["time1"].ToString().Trim()))
- // //{ StrFirstParagraphDateTimeToMax = Convert.ToDateTime(dtRows2[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // //获取大于第一班段下班时间并且小于第二班段下班时间(用于判断第二段上班卡是否迟到)
- // if (!string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) > Convert.ToDateTime(StrDateTime + " " + dtRow["time3"].ToString().Trim()) &&
- // Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) < Convert.ToDateTime(StrDateTime + " " + dtRow["time4"].ToString().Trim()))
- // {
- // if (!string.IsNullOrEmpty(StrSecondParagraphDateTimeToMin))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) < Convert.ToDateTime(StrSecondParagraphDateTimeToMin))
- // { StrSecondParagraphDateTimeToMin = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // else
- // { StrSecondParagraphDateTimeToMin = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // //获取第二班段的最后下班打卡时间
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) >= Convert.ToDateTime(StrDateTime + " " + dtRow["time4"].ToString().Trim()).AddMinutes(-30))
- // {
- // if (!string.IsNullOrEmpty(StrSecondParagraphDateTimeToMax))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) > Convert.ToDateTime(StrSecondParagraphDateTimeToMax))
- // { StrSecondParagraphDateTimeToMax = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // else
- // { StrSecondParagraphDateTimeToMax = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // }
- // }
- // #endregion
- // #region 第一班段的上班时间
- // if (StrText.Trim().IndexOf("A") != -1)
- // {
- // //如果获取到第一班段的上班打卡时间晚于第一班段设置的上班时间,则标迟到
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTime))
- // {
- // dataTimeList.Add("time1", StrFirstParagraphDateTime + "|" + StrDateTime + " " + dtRow["time1"].ToString().Trim());
- // //if (Convert.ToDateTime(StrFirstParagraphDateTime) > Convert.ToDateTime(StrDateTime + " " + dtRow["time1"].ToString().Trim()))
- // //{
- // // forLateToCount++;
- // //}
- // StrText = StrText.Replace("A", Convert.ToDateTime(StrFirstParagraphDateTime).ToString("HH:mm"));
- // }
- // //if (!string.IsNullOrEmpty(dtRow["time1"].ToString().Trim()))
- // //{
- // // StrText = StrText.Replace("A", Convert.ToDateTime(StrDateTime + " " + dtRow["time1"].ToString().Trim()).ToString("HH:mm"));
- // //}
- // else
- // {
- // dataTimeList.Add("time1", "");
- // StrText = StrText.Replace("A", "");
- // //forLateToCount++;
- // }
- // }
- // #endregion
- // #region 第一班段的下班时间
- // if (StrText.Trim().IndexOf("B") != -1)
- // {
- // //如果获取到的第一班段的下班打卡时间
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMin))
- // {
- // //如果不存在第二班段,则赋上第一班段下班的最小时间
- // if (string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // {
- // dataTimeList.Add("time2", StrFirstParagraphDateTimeToMin + "|" + StrDateTime + " " + dtRow["time2"].ToString().Trim());
- // StrText = StrText.Replace("B", Convert.ToDateTime(StrFirstParagraphDateTimeToMin).ToString("HH:mm"));
- // }
- // //如果获取到的第一班段下班最大时间不等于最小时间
- // else if (StrFirstParagraphDateTimeToMin.Trim() != StrFirstParagraphDateTimeToMax.Trim())
- // {
- // dataTimeList.Add("time2", StrFirstParagraphDateTimeToMin + "|" + StrDateTime + " " + dtRow["time2"].ToString().Trim());
- // StrText = StrText.Replace("B", Convert.ToDateTime(StrFirstParagraphDateTimeToMin).ToString("HH:mm"));
- // //StrText = StrText.Replace("C", Convert.ToDateTime(StrFirstParagraphDateTimeToMax).ToString("HH:mm"));
- // }
- // else
- // {
- // //如果第一班段的打卡最小时间与最时间相同,离第二班段的时间的上班时间近,则为第二班段上班时间
- // if ((Convert.ToDateTime(StrFirstParagraphDateTimeToMin) - Convert.ToDateTime(dtRow["time2"])).Minutes < (Convert.ToDateTime(dtRow["time3"]) - Convert.ToDateTime(StrFirstParagraphDateTimeToMin)).Minutes)
- // { StrFirstParagraphDateTimeToMax = StrFirstParagraphDateTimeToMin; }
- // else
- // {
- // dataTimeList.Add("time2", StrFirstParagraphDateTimeToMin + "|" + StrDateTime + " " + dtRow["time2"].ToString().Trim());
- // StrText = StrText.Replace("B", Convert.ToDateTime(StrFirstParagraphDateTimeToMin).ToString("HH:mm"));
- // }
- // }
- // }
- // //else if (!string.IsNullOrEmpty(dtRow["time4"].ToString().Trim()))
- // //{
- // // StrText = StrText.Replace("B", Convert.ToDateTime(StrDateTime + " " + dtRow["time4"].ToString().Trim()).ToString("HH:mm"));
- // //}
- // //else if (!string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // //{
- // // StrText = StrText.Replace("B", Convert.ToDateTime(StrDateTime + " " + dtRow["time3"].ToString().Trim()).ToString("HH:mm"));
- // //}
- // //else if (!string.IsNullOrEmpty(dtRow["time2"].ToString().Trim()))
- // //{
- // // StrText = StrText.Replace("B", Convert.ToDateTime(StrDateTime + " " + dtRow["time2"].ToString().Trim()).ToString("HH:mm"));
- // //}
- // else
- // {
- // dataTimeList.Add("time2", "");
- // //forEarlyGoCount++;
- // StrText = StrText.Replace("B", "");
- // }
- // }
- // #endregion
- // #region 第二班段上、下班时间
- // if (!string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // {
- // //第二班段上班时间
- // if (StrText.Trim().IndexOf("C") != -1)
- // {
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMax) || !string.IsNullOrEmpty(StrSecondParagraphDateTimeToMin))
- // {
- // if (StrFirstParagraphDateTimeToMax != StrFirstParagraphDateTimeToMin)
- // {
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMax))
- // {
- // dataTimeList.Add("time3", StrFirstParagraphDateTimeToMax + "|" + StrDateTime + " " + dtRow["time3"].ToString().Trim());
- // StrText = StrText.Replace("C", Convert.ToDateTime(StrFirstParagraphDateTimeToMax).ToString("HH:mm"));
- // }
- // else if (!string.IsNullOrEmpty(StrSecondParagraphDateTimeToMin))
- // {
- // dataTimeList.Add("time3", StrSecondParagraphDateTimeToMin + "|" + StrDateTime + " " + dtRow["time3"].ToString().Trim());
- // StrText = StrText.Replace("C", Convert.ToDateTime(StrSecondParagraphDateTimeToMin).ToString("HH:mm"));
- // }
- // }
- // else if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMax) || !string.IsNullOrEmpty(StrSecondParagraphDateTimeToMin))
- // {
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMax) && !string.IsNullOrEmpty(StrSecondParagraphDateTimeToMin))
- // {
- // if (Convert.ToDateTime(StrFirstParagraphDateTimeToMax) < Convert.ToDateTime(StrSecondParagraphDateTimeToMin))
- // {
- // //forLateToCount++;
- // dataTimeList.Add("time3", StrFirstParagraphDateTimeToMax + "|" + StrDateTime + " " + dtRow["time3"].ToString().Trim());
- // StrText = StrText.Replace("C", Convert.ToDateTime(StrFirstParagraphDateTimeToMax).ToString("HH:mm"));
- // }
- // }
- // else if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeToMax) || string.IsNullOrEmpty(StrSecondParagraphDateTimeToMin))
- // {
- // //forLateToCount++;
- // dataTimeList.Add("time3", StrFirstParagraphDateTimeToMax + "|" + StrDateTime + " " + dtRow["tim3e"].ToString().Trim());
- // StrText = StrText.Replace("C", Convert.ToDateTime(StrFirstParagraphDateTimeToMax).ToString("HH:mm"));
- // }
- // else if (string.IsNullOrEmpty(StrFirstParagraphDateTimeToMax) || !string.IsNullOrEmpty(StrSecondParagraphDateTimeToMin))
- // {
- // //forLateToCount++;
- // dataTimeList.Add("time3", StrSecondParagraphDateTimeToMin + "|" + StrDateTime + " " + dtRow["time3"].ToString().Trim());
- // StrText = StrText.Replace("C", Convert.ToDateTime(StrSecondParagraphDateTimeToMin).ToString("HH:mm"));
- // }
- // }
- // }
- // else
- // {
- // //forLateToCount++;
- // dataTimeList.Add("time3", "");
- // StrText = StrText.Replace("C", "");
- // }
- // }
- // //第二班段下班时间
- // if (StrText.Trim().IndexOf("D") != -1)
- // {
- // if (!string.IsNullOrEmpty(StrSecondParagraphDateTimeToMax))
- // {
- // dataTimeList.Add("time4", StrSecondParagraphDateTimeToMax + "|" + StrDateTime + " " + dtRow["time4"].ToString().Trim());
- // StrText = StrText.Replace("D", Convert.ToDateTime(StrSecondParagraphDateTimeToMax).ToString("HH:mm"));
- // }
- // else
- // {
- // dataTimeList.Add("time4", "");
- // //forEarlyGoCount++;
- // StrText = StrText.Replace("D", "");
- // }
- // }
- // }
- // #endregion
- // //if (forLateToCount > 0)
- // //{
- // // if (Convert.ToDateTime(SDateTime.Now.ToString("yyyy-MM-dd")) >= Convert.ToDateTime(StrDateTime))
- // // { intLateToCount++; }
- // //}
- // //if (forEarlyGoCount > 0)
- // //{
- // // if (Convert.ToDateTime(SDateTime.Now.ToString("yyyy-MM-dd")) >= Convert.ToDateTime(StrDateTime))
- // // { intEarlyGoCount++; }
- // //}
- // //if (!string.IsNullOrEmpty(dtRow["time3"].ToString().Trim()))
- // //{
- // // if (StrText.Trim().IndexOf("A") != -1 && StrText.Trim().IndexOf("B") != -1 && StrText.Trim().IndexOf("C") != -1 && StrText.Trim().IndexOf("D") != -1)
- // // { intKuangGongCount++; }
- // //}
- // //else if (StrText.Trim().IndexOf("A") != -1 && StrText.Trim().IndexOf("B") != -1)
- // //{ intKuangGongCount++; }
- // StrValueText += StrText.Trim();
- // IsFindValueText = false;
- // }
- // #endregion
- // }
- // if (IsFindValueText)
- // {
- // #region 没有安排班次
- // #region 处理签到
- // string StrText = "[A-B]";
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrAllDay.Trim()) != -1 || StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoToAndOffWork.Trim()) != -1 || StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoToAndOffWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time1", "签单");
- // dataTimeList.Add("time2", "签单");
- // StrText = StrText.Replace("A", "签单").Replace("B", "签单");
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoToWork.Trim()) != -1 || StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrSecondParagraph_GoToWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time1", "签单");
- // StrText = StrText.Replace("A", "签单");
- // }
- // if (StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrFirstParagraph_GoOffWork.Trim()) != -1 || StrTextString.IndexOf(LYFZ.EnumPublic.AttendanceSignType.StrSecondParagraph_GoOffWork.Trim()) != -1)
- // {
- // dataTimeList.Add("time2", "签单");
- // StrText = StrText.Replace("B", "签单");
- // }
- // #endregion
- // #region 获取一天的最早的打卡上班时间与最晚的打卡下班时间
- // if (StrText.Trim().IndexOf("A") != -1 || StrText.Trim().IndexOf("B") != -1)
- // {
- // //获取一天的最早的打卡上班时间与最晚的打卡下班时间
- // string StrFirstParagraphDateTimeGoUp = "";
- // string StrFirstParagraphDateTimeDown = "";
- // for (int k = 0; k < dtRows_Kaoqin.Length; k++)
- // {
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeGoUp))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) < Convert.ToDateTime(StrFirstParagraphDateTimeGoUp))
- // { StrFirstParagraphDateTimeGoUp = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // else
- // { StrFirstParagraphDateTimeGoUp = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeDown))
- // {
- // if (Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]) > Convert.ToDateTime(StrFirstParagraphDateTimeDown))
- // { StrFirstParagraphDateTimeDown = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // else
- // { StrFirstParagraphDateTimeDown = Convert.ToDateTime(dtRows_Kaoqin[k]["datetime"]).ToString("yyyy-MM-dd HH:mm"); }
- // }
- // //替换打卡时间点
- // if (!string.IsNullOrEmpty(StrFirstParagraphDateTimeGoUp))
- // {
- // if (StrFirstParagraphDateTimeGoUp == StrFirstParagraphDateTimeDown)
- // {
- // if (StrText.Trim().IndexOf("A") != -1 && StrText.Trim().IndexOf("B") != -1)
- // {
- // dataTimeList.Add("time1", StrFirstParagraphDateTimeGoUp );
- // StrText = StrText.Trim().Replace("A", Convert.ToDateTime(StrFirstParagraphDateTimeGoUp).ToString("HH:mm"));
- // }
- // else if (StrText.Trim().IndexOf("A") != -1 && StrText.Trim().IndexOf("B") == -1)
- // {
- // dataTimeList.Add("time1", StrFirstParagraphDateTimeGoUp);
- // StrText = StrText.Trim().Replace("A", Convert.ToDateTime(StrFirstParagraphDateTimeGoUp).ToString("HH:mm"));
- // }
- // else if (StrText.Trim().IndexOf("A") == -1 && StrText.Trim().IndexOf("B") != -1)
- // {
- // dataTimeList.Add("time2", StrFirstParagraphDateTimeGoUp);
- // StrText = StrText.Trim().Replace("B", Convert.ToDateTime(StrFirstParagraphDateTimeGoUp).ToString("HH:mm"));
- // }
- // }
- // else
- // {
- // dataTimeList.Add("time1", StrFirstParagraphDateTimeGoUp);
- // dataTimeList.Add("time2", StrFirstParagraphDateTimeDown);
- // StrText = StrText.Trim().Replace("A", Convert.ToDateTime(StrFirstParagraphDateTimeGoUp).ToString("HH:mm"));
- // StrText = StrText.Trim().Replace("B", Convert.ToDateTime(StrFirstParagraphDateTimeDown).ToString("HH:mm"));
- // }
- // }
- // if (StrText.Trim().IndexOf("A") != -1 && StrText.Trim().IndexOf("B") != -1)
- // {
- // //intKuangGongCount++;
- // dataTimeList.Add("time1", "");
- // dataTimeList.Add("time2", "");
- // StrText = StrText.Trim().Replace("A", "");
- // StrText = StrText.Trim().Replace("B", "");
- // }
- // if (StrText.Trim().IndexOf("A") != -1 && StrText.Trim().IndexOf("B") == -1)
- // {
- // //if (Convert.ToDateTime(SDateTime.Now.ToString("yyyy-MM-dd")) >= Convert.ToDateTime(StrDateTime))
- // //{ intLateToCount++; }
- // dataTimeList.Add("time1", "");
- // StrText = StrText.Trim().Replace("A", "");
- // }
- // if (StrText.Trim().IndexOf("A") == -1 && StrText.Trim().IndexOf("B") != -1)
- // {
- // //if (Convert.ToDateTime(SDateTime.Now.ToString("yyyy-MM-dd")) >= Convert.ToDateTime(StrDateTime))
- // //{ intEarlyGoCount++; }
- // dataTimeList.Add("time2", "");
- // StrText = StrText.Trim().Replace("B", "");
- // }
- // }
- // #endregion
- // StrValueText = StrText.Trim();
- // #endregion
- // }
- // newdtRow[j.ToString().Trim()] = StrValueText.Trim();
- // #region 考勤情况统计
- // var values = dataTimeList.Values;
- // List<string> vals = new List<string>(values);
- // string[] strVals = (from val in vals where val != "" select val).ToArray();
- // if(strVals.Length==0)
- // {
- // intKuangGongCount++;
- // }
- // else
- // {
- // if(strVals.Length>0&&vals.Count!=strVals.Length)
- // {
- // intMissedPunch++;
- // }
- // else
- // {
- // if(strVals.Length==2)
- // {
- // string[] stvalus = strVals[0].Split('|');
- // string[] envalus = strVals[1].Split('|');
- // if (stvalus.Length > 1)
- // {
- // if(Convert.ToDateTime(stvalus[0])>Convert.ToDateTime(stvalus[1]))
- // {
- // intLateToCount++;
- // }
- // }
- // if (envalus.Length > 1)
- // {
- // if (Convert.ToDateTime(envalus[0]) < Convert.ToDateTime(envalus[1]))
- // {
- // intEarlyGoCount++;
- // }
- // }
- // }
- // else if (strVals.Length == 4)
- // {
- // string[] stvalus1 = strVals[0].Split('|');
- // string[] envalus1 = strVals[1].Split('|');
- // string[] stvalus2 = strVals[2].Split('|');
- // string[] envalus2 = strVals[3].Split('|');
- // if (stvalus1.Length > 1)
- // {
- // if (Convert.ToDateTime(stvalus1[0]) > Convert.ToDateTime(stvalus1[1]))
- // {
- // intLateToCount++;
- // }
- // }
- // if (stvalus1.Length > 1)
- // {
- // if (Convert.ToDateTime(stvalus1[0]) < Convert.ToDateTime(stvalus1[1]))
- // {
- // intEarlyGoCount++;
- // }
- // }
- // if (stvalus2.Length > 1)
- // {
- // if (Convert.ToDateTime(stvalus2[0]) > Convert.ToDateTime(stvalus2[1]))
- // {
- // intLateToCount++;
- // }
- // }
- // if (stvalus2.Length > 1)
- // {
- // if (Convert.ToDateTime(stvalus2[0]) < Convert.ToDateTime(stvalus2[1]))
- // {
- // intEarlyGoCount++;
- // }
- // }
- // }
- // }
- // }
- // #endregion
- // //switch (j)
- // //{
- // // case 0: newdtRow["星期日"] = StrValueText; break;
- // // case 1: newdtRow["星期一"] = StrValueText; break;
- // // case 2: newdtRow["星期二"] = StrValueText; break;
- // // case 3: newdtRow["星期三"] = StrValueText; break;
- // // case 4: newdtRow["星期四"] = StrValueText; break;
- // // case 5: newdtRow["星期五"] = StrValueText; break;
- // // case 6: newdtRow["星期六"] = StrValueText; break;
- // //}
- // }
- // catch { MessageBoxCustom.Show(i.ToString() + " " + j.ToString() + " " + new System.Diagnostics.StackTrace(new System.Diagnostics.StackFrame(true)).ToString()); }
- // }
- // #endregion
- // newdtRow["编号"] = dt.Rows[i]["User_EmployeeID"].ToString().Trim();
- // newdtRow["姓名"] = dt.Rows[i]["User_Name"].ToString().Trim();
- // newdtRow["迟到"] = intLateToCount.ToString().Trim();
- // newdtRow["早退"] = intEarlyGoCount.ToString().Trim();
- // newdtRow["旷工"] = intKuangGongCount.ToString().Trim();
- // newdtRow["漏打卡"] = intMissedPunch.ToString().Trim();
- // newTable.Rows.Add(newdtRow);
- //}
- #endregion
- });
- return newTable;
- }
- /// <summary>
- /// 新考勤统计
- /// </summary>
- /// <param name="dtSet"></param>
- /// <param name="newTable"></param>
- void BindAttendanceStatistics(DataSet dtSet, DataTable newTable, string StrWeekStartDate ,int WorkCount)
- {
- DataTable dt = dtSet.Tables["ds"];
- DataTable dtPaibanSet = dtSet.Tables["ds1"];
- //dtPaibanSet.PrimaryKey = new DataColumn[] { dtPaibanSet.Columns["User_ID"], dtPaibanSet.Columns["Time"] };
- DataTable dtKaoqin = dtSet.Tables["ds2"];
- DataTable dtQiandao = dtSet.Tables["ds3"];
- DataTable dtBanchiSet = dtSet.Tables["ds4"];
- Dictionary<string, dynamic> userCheckWork = new Dictionary<string, dynamic>();
- foreach (DataRow dr in dt.Rows)
- {
- string StrUserName = dr["User_Name"].ToString().Trim();
- string EmployeeID = dr["User_EmployeeID"].ToString().Trim();
- List<string> fingers = new List<string>();
- if(!string.IsNullOrEmpty(dr["User_FirstFingerprintID"].ToString().Trim()))
- {
- fingers.Add(dr["User_FirstFingerprintID"].ToString());
- }
- if (!string.IsNullOrEmpty(dr["User_SecondaryFingerprintID"].ToString().Trim()))
- {
- fingers.Add(dr["User_SecondaryFingerprintID"].ToString());
- }
- DataRow newdtRow = newTable.NewRow();
- int intLateToCount = 0;
- int intEarlyGoCount = 0;
- int intKuangGongCount = 0;
- int intMissedPunch = 0;
- int restCount = 0;
- int leaveCount = 0;
- #region 处理一个星期的每天考勤情况
- for (int j = 0; j < WorkCount; j++)
- {
- try
- {
- ///获取当前时间
- DateTime staWeekTime = Convert.ToDateTime(StrWeekStartDate).AddDays(j);
- ///休息数据
- List<DataRow> restConfigList = dtPaibanSet.AsEnumerable().Where(
- p =>
- p.Field<string>("User_ID") == EmployeeID &&
- p.Field<DateTime>("Time").ToString("yyyy-MM-dd") == staWeekTime.ToString("yyyy-MM-dd") &&
- p.Field<string>("fixed").ToString()=="休息").ToList();
- List<DataRow> leaveConfigList = dtPaibanSet.AsEnumerable().Where(
- p =>
- p.Field<string>("User_ID") == EmployeeID &&
- p.Field<DateTime>("Time").ToString("yyyy-MM-dd") == staWeekTime.ToString("yyyy-MM-dd") &&
- p.Field<string>("fixed") == "请假").ToList();
- ///获取配置的时间段
- List<DataRow> workConfig = dtPaibanSet.AsEnumerable().Where(p => p.Field<string>("User_ID") == EmployeeID && p.Field<DateTime>("Time").ToString("yyyy-MM-dd") == staWeekTime.ToString("yyyy-MM-dd")).ToList();
- if (workConfig.Count > 0)
- {
- workConfig = dtBanchiSet.AsEnumerable().Where(p => p.Field<string>("name") == workConfig[0]["fixed"].ToString()).ToList();
- }
- ///获取会员当天配置好的打卡时间段
- List<dynamic> dySignList = new List<dynamic>();
- List<DataRow> dtKaoqinDr = dtKaoqin.AsEnumerable().Where(p =>
- ("," + string.Join(",", fingers.ToArray()) + ",").IndexOf("," + p.Field<string>("no") + ",") != -1
- && p.Field<string>("datetime").Trim().Split(' ')[0] == staWeekTime.ToString("yyyy-MM-dd")
- ).ToList();
- foreach (DataRow kqDr in dtKaoqinDr)
- {
- DateTime tempDateTime;
- if (DateTime.TryParse(kqDr["datetime"].ToLowerString(), out tempDateTime))
- {
- dynamic dyObj = new ExpandoObject();
- dyObj.TypeName = "";
- dyObj.DateTime = tempDateTime;
- dySignList.Add(dyObj);
- }
- }
- if(restConfigList.Count>0)
- {
- restCount++;
- }
- if(leaveConfigList.Count>0)
- {
- leaveCount++;
- }
- //获取签卡的时间段
- dtKaoqinDr = dtQiandao.AsEnumerable().Where(p =>
- p.Field<string>("user_id")== EmployeeID
- && p.Field<string>("date").Trim().Split(' ')[0] == staWeekTime.ToString("yyyy-MM-dd")
- ).ToList();
- foreach (DataRow kqDr in dtKaoqinDr)
- {
- DateTime tempDateTime;
- if (DateTime.TryParse(kqDr["date"].ToLowerString(), out tempDateTime))
- {
- dynamic dyObj = new ExpandoObject();
- dyObj.TypeName = kqDr["type"].ToString_s();
- dyObj.DateTime = tempDateTime;
- dySignList.Add(dyObj);
- }
- }
- ///签到时间排序,升序
- dySignList = dySignList.OrderBy(a => a.DateTime).ToList();
- if (dySignList.Count > 0)
- {
- ///存在排班
- if (workConfig.Count > 0)
- {
- List<dynamic> dyList = new List<dynamic>();
- ///排班阶段数据提取
- if(!string.IsNullOrEmpty(workConfig[0]["time1"].ToString_s()))
- {
- dynamic dyObj = new ExpandoObject();
- dyObj.StartTime = Convert.ToDateTime(staWeekTime.ToString("yyyy-MM-dd")+" " + workConfig[0]["time1"].ToString_s());
- dyObj.EndTime = Convert.ToDateTime(staWeekTime.ToString("yyyy-MM-dd") + " " + workConfig[0]["time2"].ToString_s());
- dyList.Add(dyObj);
- }
- if (!string.IsNullOrEmpty(workConfig[0]["time3"].ToString_s()))
- {
- dynamic dyObj = new ExpandoObject();
- dyObj.StartTime = Convert.ToDateTime(staWeekTime.ToString("yyyy-MM-dd") + " " + workConfig[0]["time3"].ToString_s());
- dyObj.EndTime = Convert.ToDateTime(staWeekTime.ToString("yyyy-MM-dd") + " " + workConfig[0]["time4"].ToString_s());
- dyList.Add(dyObj);
- }
- string typeText = "";
- ///存在排班数据
- if(dyList.Count>0)
- {
- ///只有一个阶段的排班
- if(dyList.Count==1)
- {
- ///获取开始时间和结束时间,开始时间和结束时间对排班数据进行
- string stimeDatet = "";
- string etimeDatet = "";
- TimeSpan timeSpan = dyList[0].EndTime - dyList[0].StartTime;
- int hourValue = timeSpan.Hours;
- if(dySignList[0].DateTime> dyList[0].StartTime.AddHours(-2)&& dySignList[0].DateTime< dyList[0].StartTime.AddHours(hourValue/2))
- {
- }
- else
- {
- dynamic dyObj = new ExpandoObject();
- dyObj.TypeName = "无数据";
- dyObj.DateTime = null;
- dySignList.Insert(0,dyObj);
- }
- //排班对打卡时间进行比较判断是否迟到
- if (dySignList[0].TypeName != "无数据")
- {
- if (dyList[0].StartTime < dySignList[0].DateTime)
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intLateToCount++;
- typeText = "迟到";
- }
- }
- stimeDatet = string.IsNullOrEmpty(dySignList[0].TypeName) ? dySignList[0].DateTime.ToString("HH:mm") : dySignList[0].TypeName;
- }
- else
- {
- intMissedPunch++;
- typeText = "漏";
- stimeDatet = "";
- }
- //排班对打卡时间进行比较判断早退还是漏打卡
- if (dyList[0].EndTime > dySignList[dySignList.Count-1].DateTime )
- {
- if ((dySignList.Count - 1) > 0)
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intEarlyGoCount++;
- typeText = "早退";
- }
-
- }
- else
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intMissedPunch++;
- typeText = "漏";
- }
- }
- }
-
- if ((dySignList.Count - 1) > 0)
- {
- etimeDatet = string.IsNullOrEmpty(dySignList[dySignList.Count - 1].TypeName) ? dySignList[dySignList.Count - 1].DateTime.ToString("HH:mm") : dySignList[dySignList.Count - 1].TypeName;
- }
- else
- {
- etimeDatet = "";
- }
- newdtRow[j.ToString()] = workConfig[0]["name"]+"[" + stimeDatet + "-" + etimeDatet + "]"+(string.IsNullOrEmpty(typeText)?"":"("+ typeText + ")");
- }
- else
- {
- ///将排班信息进行分组,分成3组
- List<dynamic> group1 = dySignList.Where(p => p.DateTime < dyList[0].EndTime).ToList();
- List<dynamic> group2 = dySignList.Where(p => p.DateTime >= dyList[0].EndTime && p.DateTime <= dyList[1].StartTime).ToList();
- List<dynamic> group3 = dySignList.Where(p => p.DateTime > dyList[1].StartTime).ToList();
- string stime1 = "";
- string etime1 = "";
- string stime2 = "";
- string etime2 = "";
- if(group1.Count>0)
- {
- stime1 = group1[0].DateTime.ToString("HH:mm");
- //if(dyList[0].StartTime< group1[0].DateTime)
- //{
- //}
- }
- if (group2.Count == 0)
- {
- etime1 = (group1.Count > 1 ? group1[group1.Count - 1].DateTime.ToString("HH:mm") : "");
-
- stime2 = (group3.Count > 0) ? group3[0].DateTime.ToString("HH:mm") : "";
- }
- else if (group2.Count == 1)
- {
- TimeSpan timeSpan = dyList[1].StartTime - dyList[0].EndTime;
- double halfMinu = timeSpan.TotalMinutes / 2;
- if (dyList[0].EndTime.AddMinutes(Convert.ToInt32(halfMinu)) >= group2[0].DateTime)
- {
- etime1 = group2[0].DateTime.ToString("HH:mm");
- if (group3.Count == 1)
- {
- timeSpan = dyList[1].EndTime - dyList[1].StartTime;
- halfMinu = timeSpan.TotalMinutes / 2;
- if (dyList[1].StartTime.AddMinutes(Convert.ToInt32(halfMinu)) >= group3[0].DateTime)
- {
- stime2 = group3[0].DateTime.ToString("HH:mm");
- }
- else
- {
- etime2 = group3[0].DateTime.ToString("HH:mm");
- }
- }
- else
- {
- stime2 = group3[0].DateTime.ToString("HH:mm");
- }
- }
- else
- {
- stime2 = group2[0].DateTime.ToString("HH:mm");
- if (group1.Count > 1)
- {
- DateTime tempEndTime = group1[group1.Count - 1].DateTime;
- if (tempEndTime > dyList[0].EndTime.AddMinutes(-Convert.ToInt32(halfMinu)))
- {
- etime1= tempEndTime.ToString("HH:mm");
- }
- }
- }
- }
- else
- {
- etime1 = group2[0].DateTime.ToString("HH:mm");
- stime2 = group2[group2.Count - 1].DateTime.ToString("HH:mm");
- if (group3.Count == 1)
- {
- TimeSpan timeSpan = dyList[1].EndTime - dyList[1].StartTime;
- double halfMinu = timeSpan.TotalMinutes / 2;
- if (dyList[1].StartTime.AddMinutes(Convert.ToInt32(halfMinu)) < group3[0].DateTime)
- {
- etime2 = group3[0].DateTime.ToString("HH:mm");
- }
- }
- }
- if (group3.Count > 0)
- {
- etime2 = group3[group3.Count - 1].DateTime.ToString("HH:mm");
- if (etime2 == stime2)
- {
- stime2 = "";
- }
- }
- if (string.IsNullOrEmpty(stime1) && string.IsNullOrEmpty(etime1) && string.IsNullOrEmpty(stime2) && string.IsNullOrEmpty(etime2))
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intKuangGongCount++;
- typeText = "旷";
- }
- }
- else if (string.IsNullOrEmpty(stime1)|| string.IsNullOrEmpty(etime1) || string.IsNullOrEmpty(stime2) || string.IsNullOrEmpty(etime2))
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intMissedPunch++;
- typeText = "漏";
- }
- }
- if(!string.IsNullOrEmpty(workConfig[0]["time3"].ToString_s()))
- {
- if (Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + workConfig[0]["time1"]) <
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + stime1) ||
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + workConfig[0]["time3"]) <
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + stime2))
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intLateToCount++;
- typeText = "迟到";
- }
- }
- }
- else
- {
- if (Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + workConfig[0]["time1"]) <
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + stime1))
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intLateToCount++;
- typeText = "迟到";
- }
- }
- }
- if (!string.IsNullOrEmpty(workConfig[0]["time3"].ToString_s()))
- {
- if (Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + workConfig[0]["time2"]) >
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + etime1) ||
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + workConfig[0]["time4"]) >
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + etime2))
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intEarlyGoCount++;
- typeText = "早退";
- }
- }
- }
- else
- {
- if (Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + workConfig[0]["time2"]) >
- Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd") + " " + etime1))
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intEarlyGoCount++;
- typeText = "早退";
- }
- }
- }
- if (restConfigList.Count > 0 || leaveConfigList.Count > 0)
- {
- newdtRow[j.ToString()] = workConfig[0]["name"].ToString_s() + "[" + stime1 + " -" + etime1 + "]" + "[" + stime2 + " -" + etime2 + "]"
- + (restConfigList.Count > 0 ? "(休)" : "") + (leaveConfigList.Count > 0 ? "(假)" : "");
- }
- else
- {
- newdtRow[j.ToString()] = workConfig[0]["name"].ToString_s() + "[" + stime1 + " -" + etime1 + "]" + "[" + stime2 + " -" + etime2 + "]"
- + (string.IsNullOrEmpty(typeText) ? "" : "(" + typeText + ")");
- }
- }
- }
- else
- {
- TimeSpan timeSpan = dyList[0].EndTime - dyList[0].StartTime;
- int hourValue = timeSpan.Hours;
- if (dySignList[0].DateTime > dyList[0].StartTime.AddHours(-2) && dySignList[0].DateTime < dyList[0].StartTime.AddHours(hourValue / 2))
- {
- }
- else
- {
- dynamic dyObj = new ExpandoObject();
- dyObj.TypeName = "无数据";
- dyObj.DateTime = null;
- dySignList.Insert(0, dyObj);
- }
- string timeDatet = "";
- if (dySignList[0].TypeName != "无数据")
- {
- timeDatet = string.IsNullOrEmpty(dySignList[0].TypeName) ? dySignList[0].DateTime.ToString("HH:mm") : dySignList[0].TypeName;
- }
- if (dySignList.Count > 1)
- {
- newdtRow[j.ToString()] = "[" + timeDatet + " - " + (string.IsNullOrEmpty(dySignList[dySignList.Count - 1].TypeName) ?
- dySignList[dySignList.Count - 1].DateTime.ToString("HH:mm") :
- dySignList[dySignList.Count - 1].TypeName) + "]" +
- (restConfigList.Count > 0 ? "(休)" : "") + (leaveConfigList.Count > 0 ? "(假)" : "");
- }
- else
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intMissedPunch++;
- }
- if (restConfigList.Count > 0 || leaveConfigList.Count > 0)
- {
- newdtRow[j.ToString()] = "[" + timeDatet + " -" + "]" + (restConfigList.Count > 0 ? "(休)" : "") + (leaveConfigList.Count > 0 ? "(假)" : "");
- }
- else
- {
- newdtRow[j.ToString()] = "[" + timeDatet + " -" + "](漏)";
- }
- }
- }
- }
- else
- {
- string timeDatet = string.IsNullOrEmpty(dySignList[0].TypeName) ? dySignList[0].DateTime.ToString("HH:mm") : dySignList[0].TypeName;
- if(dySignList.Count>1)
- {
- newdtRow[j.ToString()] ="["+ timeDatet + " - " + (string.IsNullOrEmpty(dySignList[dySignList.Count - 1].TypeName) ?
- dySignList[dySignList.Count - 1].DateTime.ToString("HH:mm") :
- dySignList[dySignList.Count - 1].TypeName)+"]" + (restConfigList.Count > 0 ? "(休)" : "") + (leaveConfigList.Count > 0 ? "(假)" : "");
- }
- else
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intMissedPunch++;
- }
- if (restConfigList.Count > 0 || leaveConfigList.Count > 0)
- {
- newdtRow[j.ToString()] = "[" + timeDatet + " -" + "]" + (restConfigList.Count > 0 ? "(休)" : "") + (leaveConfigList.Count > 0 ? "(假)" : "");
- }
- else
- {
- newdtRow[j.ToString()] = "[" + timeDatet + " -" + "](漏)";
- }
- }
- }
- }
- else
- {
- if (restConfigList.Count == 0 && leaveConfigList.Count == 0)
- {
- intKuangGongCount++;
- }
- if (restConfigList.Count > 0 || leaveConfigList.Count > 0)
- {
- newdtRow[j.ToString()] = "[" + "-" + "]" + (restConfigList.Count > 0 ? "(休)" : "") + (leaveConfigList.Count > 0 ? "(假)" : "");
- }
- else
- {
- newdtRow[j.ToString()] = "[" + "-" + "](旷)";
- }
- }
- }
- catch (Exception e)
- {
- intKuangGongCount++;
- newdtRow[j.ToString()] = "[" + "-" + "](旷)";
- }
- }
- newdtRow["编号"] = EmployeeID.Trim();
- newdtRow["姓名"] = StrUserName.Trim();
- newdtRow["迟到"] = intLateToCount.ToString().Trim();
- newdtRow["早退"] = intEarlyGoCount.ToString().Trim();
- newdtRow["旷工"] = intKuangGongCount.ToString().Trim();
- newdtRow["漏打卡"] = intMissedPunch.ToString().Trim();
- newdtRow["休息"] = restCount.ToString().Trim();
- newdtRow["请假"] = leaveCount.ToString().Trim();
- newTable.Rows.Add(newdtRow);
- #endregion
- }
- }
- /// <summary>
- /// 更改日期
- /// </summary>
- /// <param name="SelectValue"></param>
- void dtpYearMonth_ClickChengedValue(string SelectValue)
- {
- this.dtpYearMonth.Visible = true;
- this.panelLastNextWeek.Visible = false;
- if (string.IsNullOrEmpty(this.dtpYearMonth.StrDateValue.Trim()))
- { MessageBoxCustom.Show("请选择要排班的月份!"); return; }
- int IntMonthDay = DateTime.DaysInMonth(this.dtpYearMonth.StrYear, this.dtpYearMonth.StrMonth);
- string StrWeekStartDate = this.dtpYearMonth.StrDateValue + "-01";
- string StrWeekEndDate = Convert.ToDateTime(StrWeekStartDate).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- DataTable newTable = this.GetWorkData(StrWeekStartDate, StrWeekEndDate, IntMonthDay,((ItemValue)GetCompanyDataInfo()).Value.ToString_s());
- this.dgvData.Rows.Clear();
- string StrColumnName = "编号,姓名,迟到,早退,旷工,漏打卡,休息,请假";
- this.dgvData.DataColumns(StrColumnName, strHideField: "编号");
- DataGridViewColumn column = null;
- for (int i = 1; i <= IntMonthDay; i++)
- {
- StrColumnName = i + "日\r\n" + Convert.ToDateTime(this.dtpYearMonth.StrDateValue + "-01").AddDays(i - 1).ToString("dddd") + "";
- column = new DataGridViewColumn();
- column.ReadOnly = true;
- column.Name = StrColumnName;
- column.HeaderText = StrColumnName;
- column.Tag = Convert.ToDateTime(this.dtpYearMonth.StrDateValue + "-01").AddDays(i - 1).ToString("yyyy-MM-dd");
- this.dgvData.Columns.Add(column);
- }
- //this.dgvData.DataColumns(StrColumnName);
- this.dgvData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
- this.dgvData.Columns["姓名"].Frozen = true;
- for (int i = 0; i < this.dgvData.Columns.Count; i++)
- {
- switch (this.dgvData.Columns[i].Name.Trim())
- {
- case "姓名":
- case "迟到":
- case "早退":
- case "旷工":
- case "漏打卡":
- case "休息":
- case "请假":
- this.dgvData.Columns[i].Width = 70;
- break;
- default:
- this.dgvData.Columns[i].Width = 100;
- break;
- }
- }
- DataGridViewRow dgvr = null;
- DataGridViewCell cell = null;
- for (int i = 0; i < newTable.Rows.Count; i++)
- {
- dgvr = new DataGridViewRow();
- dgvr.Height = 48;
- for (int j = 0; j < newTable.Columns.Count; j++)
- {
- cell = new DataGridViewTextBoxCell();
- cell.Style.BackColor = System.Drawing.Color.White;
- string cellValue = newTable.Rows[i][j].ToString().Trim();
- SetCellBackColor(cell,ref cellValue);
- cell.Value = cellValue;
- dgvr.Cells.Add(cell);
- }
- this.dgvData.Rows.Add(dgvr);
- string[] columnsList = "迟到,早退,旷工,漏打卡,休息,请假".Split(',');
- foreach (string strColumn in columnsList)
- {
- string cellText = "";
- switch (strColumn)
- {
- case "迟到":
- case "早退":
- cellText = "(" + strColumn + ")";
- break;
- case "请假":
- cellText = "(假)";
- break;
- default:
- cellText = "(" + strColumn.ToCharArray()[0] + ")";
- break;
- }
- dgvr.Cells[strColumn].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
- if (Convert.ToDecimal(dgvr.Cells[strColumn].Value) > 0)
- {
- SetCellBackColor(dgvr.Cells[strColumn], ref cellText);
- }
- }
- }
- }
- ///修改单元格的颜色
- void SetCellBackColor(DataGridViewCell cell,ref string cellText)
- {
- if(cellText.Contains("(休)"))
- {
- cell.Style.BackColor = System.Drawing.Color.Green;
- }
- else if (cellText.Contains("(假)"))
- {
- cell.Style.BackColor = System.Drawing.Color.BlueViolet;
- }
- else if (cellText.Contains("(迟到)"))
- {
- cell.Style.BackColor = System.Drawing.Color.Yellow;
- cellText = cellText.Replace("(迟到)", "");
- }
- else if (cellText.Contains("(早退)"))
- {
- cell.Style.BackColor = System.Drawing.Color.YellowGreen;
- cellText = cellText.Replace("(早退)", "");
- }
- else if (cellText.Contains("(漏)"))
- {
- cell.Style.BackColor = System.Drawing.Color.Red;
- cellText = cellText.Replace("(漏)", "");
- }
- else if (cellText.Contains("(旷)"))
- {
- cell.Style.BackColor = System.Drawing.Color.DarkOrange;
- cellText = cellText.Replace("(旷)", "");
- }
- }
- /// <summary>
- /// 周统计
- /// </summary>
- void GetWeekData()
- {
- this.panelLastNextWeek.Visible = true;
- this.dtpYearMonth.Visible = false;
- DataTable newTable = this.GetWorkData(this.WeekStartDate.ToString("yyyy-MM-dd"), this.WeekEndDate.ToString("yyyy-MM-dd"), 7,((ItemValue)GetCompanyDataInfo()).Value.ToString_s());
- this.dgvData.Rows.Clear();
- string StrColumnName = "编号,姓名,迟到,早退,旷工,漏打卡,休息,请假";
- this.dgvData.DataColumns(StrColumnName, strHideField: "编号");
- DataGridViewColumn column = null;
- for (int i = 0; i < 7; i++)
- {
- string StrMonthDay = this.WeekStartDate.AddDays(i).ToString("MM月dd日");
- switch (i)
- {
- case 0: StrColumnName = "星期日\r\n";
- break;
- case 1: StrColumnName = "星期一\r\n";
- break;
- case 2: StrColumnName = "星期二\r\n";
- break;
- case 3: StrColumnName = "星期三\r\n";
- break;
- case 4: StrColumnName = "星期四\r\n";
- break;
- case 5: StrColumnName = "星期五\r\n";
- break;
- case 6: StrColumnName = "星期六\r\n";
- break;
- }
- StrColumnName += StrMonthDay;
- column = new DataGridViewColumn();
- column.ReadOnly = true;
- column.Name = StrColumnName;
- column.HeaderText = StrColumnName;
- column.Tag = this.WeekStartDate.AddDays(i).ToString("yyyy-MM-dd");
- this.dgvData.Columns.Add(column);
- }
- this.dgvData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
- //this.dgvData.DataColumns(StrColumnName);
- this.dgvData.Columns["姓名"].Frozen = true;
- int IntdgvDataColumnsCount = this.dgvData.Columns.GetColumnCount(DataGridViewElementStates.Visible);
- int intdgvDataWidth = (this.dgvData.Width - 50 - 280) / (IntdgvDataColumnsCount - 4);
- for (int i = 0; i < this.dgvData.Columns.Count; i++)
- {
- if (i > 7)
- {
- if (intdgvDataWidth < 170)
- { this.dgvData.Columns[i].Width = 170; }
- else
- { this.dgvData.Columns[i].Width = intdgvDataWidth; }
- }
- else
- { this.dgvData.Columns[i].Width = 70; }
- }
- DataGridViewRow dgvr = null;
- DataGridViewCell cell = null;
- for (int i = 0; i < newTable.Rows.Count; i++)
- {
- dgvr = new DataGridViewRow();
- dgvr.Height = 48;
- for (int j = 0; j < newTable.Columns.Count; j++)
- {
- cell = new DataGridViewTextBoxCell();
- cell.Style.BackColor = System.Drawing.Color.White;
- string cellValue = newTable.Rows[i][j].ToString().Trim();
- SetCellBackColor(cell,ref cellValue);
- cell.Value = cellValue;
- dgvr.Cells.Add(cell);
- }
- this.dgvData.Rows.Add(dgvr);
- string[] columnsList = "迟到,早退,旷工,漏打卡,休息,请假".Split(',');
- foreach(string strColumn in columnsList)
- {
- string cellText = "";
- switch(strColumn)
- {
- case "迟到":
- case "早退":
- cellText = "("+ strColumn + ")";
- break;
- case "请假":
- cellText = "(假)";
- break;
- default:
- cellText = "("+ strColumn.ToCharArray()[0] + ")";
- break;
- }
- dgvr.Cells[strColumn].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
- if (Convert.ToDecimal(dgvr.Cells[strColumn].Value) > 0)
- {
- SetCellBackColor(dgvr.Cells[strColumn],ref cellText);
- }
- }
-
- }
- }
- ItemValue GetCompanyDataInfo()
- {
- ItemValue itemValue = new ItemValue("", "");
- if (this.cbxCompanyList.Tag != null && this.cbxCompanyList.TreeView.SelectedNode != null)
- {
- string dataValue = this.cbxCompanyList.Tag.ToString();
- string dataType = this.cbxCompanyList.StrGetName.Trim();
- if (dataType.Length > 0)
- {
- switch (dataType.ToLower())
- {
- case "storename":
- itemValue.Value = "and User_DividedShop = '" + dataValue + "'";
- break;
- case "department":
- itemValue.Value = "and User_Department = '" + dataValue + "'";
- break;
- case "user":
- itemValue.Value = "and User_EmployeeID = '" + dataValue + "'";
- break;
- }
- }
- }
- return itemValue;
- }
- }
- }
|