123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.IO;
- using System.Data;
- using System.Data.SqlClient;
- using System.Data.OleDb;
- using System.Drawing;
- using LYFZ.ComponentLibrary;
- using System.Collections;
- namespace LYFZ.Software.MainBusiness.TimeAndAttendance
- {
- public class frmTimeMain : LYFZ.Software.UI.TimeAndAttendance.frmTimeMain
- {
- LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
- LYFZ.BLL.BLL_Loninbansets lbsetbll = new BLL.BLL_Loninbansets();
- public frmTimeMain()
- {
- this.Load += frmTimeMain_Load;
- this.btnLastWeek.Click += btnLastWeek_Click;
- this.btnNextWeek.Click += btnNextWeek_Click;
- this.btnEmployeeSchedule.Click += btnEmployeeSchedule_Click;
- this.btnSaveModule.Click += btnSaveModule_Click;
- this.btnGetModule.Click += btnGetModule_Click;
- this.btnSaveed.Click += btnSaveed_Click;
- this.btnTimeSet.Click += btnTimeSet_Click;
- this.btnSigned.Click += btnSigned_Click;
- this.btnSignedRecords.Click += btnSignedRecords_Click;
- this.btnClose.Click += btnClose_Click;
- this.dtpYearMonth.ClickChengedValue += dtpYearMonth_ClickChengedValue;
- this.chkWeekMode.Click += chkzhouyue_Click;
- this.cmbtreev.Leave += cmbtreev_Leave;
- this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
- this.dgvData.CellMouseDown += dgvData_CellMouseDown;
- this.dgvData.DataGridViewConMenu_ItemClicked += dgvData_DataGridViewConMenu_ItemClicked;
- this.dgvData.Scroll += dgvData_Scroll;
- this.Resize += frmTimeMain_Resize;
- //BindCompanyList();
-
- cbxCompanyList.ComboBoxTree_NodeMouseClick += CbxCompanyList_ComboBoxTree_NodeMouseClick;
- }
- private void CbxCompanyList_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- this.GetQueryMonthData();
- }
-
- DateTime WeekStartDate;
- DateTime WeekEndDate;
- string StrTextName = "";
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void frmTimeMain_Load(object sender, EventArgs e)
- {
- this.panelLastNextWeek.Visible = false;
- Control.CheckForIllegalCrossThreadCalls = false;
- this.dgvData.dgvColumnHeadersHeight = 35;
- this.dtpYearMonth.StrDateValue = SDateTime.Now.ToString("yyyy-MM");
- #region 获取本周
- this.WeekStartDate = SDateTime.Now.AddDays(Convert.ToInt32(SDateTime.Now.DayOfWeek) * -1);
- this.WeekEndDate = SDateTime.Now.AddDays(6 - Convert.ToInt32(SDateTime.Now.DayOfWeek));
- #endregion
- StrTextName = "休息,请假,";
- DataTable dat = orbll.GetView_Custom("lonintimeset", StrWhere: "", ShowColumnName: "name").Tables[0];
- for (int cmb = 0; cmb < dat.Rows.Count; cmb++)
- { StrTextName += dat.Rows[cmb]["name"].ToString().Trim() + ","; }
- // 部门人员绑定
- 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("全部");
- this.GetQueryMonthData();
- bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
- VersionControl.VersionFunctionEnum.员工考勤考勤管理);
- if (!b)
- {
- this.Close();
- }
- }
- 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;
- }
- /// <summary>
- /// 上星期
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnLastWeek_Click(object sender, EventArgs e)
- {
- this.WeekStartDate = this.WeekStartDate.AddDays(-7);
- this.WeekEndDate = this.WeekEndDate.AddDays(-7);
- this.GetQueryWeekData();
- this.GetWeekCount();
- }
- /// <summary>
- /// 下星期
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnNextWeek_Click(object sender, EventArgs e)
- {
- this.WeekStartDate = this.WeekStartDate.AddDays(7);
- this.WeekEndDate = this.WeekEndDate.AddDays(7);
- this.GetQueryWeekData();
- this.GetWeekCount();
- }
- /// <summary>
- /// 员工档期
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnEmployeeSchedule_Click(object sender, EventArgs e)
- {
- LYFZ.Software.MainBusiness.CameraControlBook.SmallForm.A_EmployeeScheduleSmallForm frm = new CameraControlBook.SmallForm.A_EmployeeScheduleSmallForm();
- frm.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- frm.Location = new Point(LYFZ.EnumPublic.FormLocation_X, LYFZ.EnumPublic.FormLocation_Y);
- frm.Size = new Size(LYFZ.EnumPublic.FormSize_Width, LYFZ.EnumPublic.FormSize_Height);
- frm.ShowDialog();
- }
- /// <summary>
- /// 存为模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSaveModule_Click(object sender, EventArgs e)
- {
- string StrModelName = "考勤排班模板(月)";
- string StrExtension = ".Mban";
- if (this.chkWeekMode.Checked)
- {
- StrModelName = "考勤排班模板(周)";
- StrExtension = ".Wban";
- }
- DataTable NewTable = this.dgvData.ToDataTable(IsShowVisible: true);
- SaveFileDialog saveFile = new SaveFileDialog();
- saveFile.FileName = StrModelName;
- saveFile.Title = "存排班模板";
- saveFile.Filter = "文件ban |*" + StrExtension;
- saveFile.FilterIndex = 1;
- DialogResult drst = saveFile.ShowDialog();
- if (drst == DialogResult.No || drst == DialogResult.Cancel || drst == DialogResult.No || drst == DialogResult.Abort)
- { return; }
- string StrPath = saveFile.FileName.Trim().Replace(StrExtension, "");
- //if (LYFZ.Command.Command_ExportExcel.DataTable2Sheet(StrPath + ".xls", NewTable, "Sheet1", IsCoveredExistingFile: true))
- //{
- // string StrSrcPath = StrPath + ".xls";
- // string StrDesPath = saveFile.FileName.Trim();
- // if (File.Exists(StrSrcPath))
- // {
- // if (File.Exists(StrDesPath))
- // {
- // try
- // { File.Delete(StrDesPath); }
- // catch
- // { MessageBoxCustom.Show("存模板失败!"); return; }
- // }
- // FileInfo fi = new FileInfo(StrSrcPath);
- // try
- // {
- // fi.MoveTo(StrDesPath);
- // MessageBoxCustom.Show("存模板成功!");
- // }
- // catch
- // {
- // File.Delete(StrSrcPath);
- // MessageBoxCustom.Show("存模板失败!");
- // return;
- // }
- // }
- // else
- // { MessageBoxCustom.Show("存模板失败!"); }
- //}
- //else
- //{ MessageBoxCustom.Show("存模板失败!"); }
- LYFZ.ComponentLibrary.FrmLoadHandling.ExecutionDoWorkMethod(delegate (object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- try
- {
- if (LYFZ.WinAPI.CustomPublicMethod.DataGridViewToExcel(StrPath + ".xls", NewTable, null, backgroundWorker))
- {
- string StrSrcPath = StrPath + ".xls";
- string StrDesPath = saveFile.FileName.Trim();
- if (File.Exists(StrSrcPath))
- {
- if (File.Exists(StrDesPath))
- {
- try
- { File.Delete(StrDesPath); }
- catch
- { MessageBoxCustom.Show("存模板失败!"); return; }
- }
- FileInfo fi = new FileInfo(StrSrcPath);
- try
- {
- fi.MoveTo(StrDesPath);
- MessageBoxCustom.Show("存模板成功!");
- }
- catch
- {
- File.Delete(StrSrcPath);
- MessageBoxCustom.Show("存模板失败!");
- return;
- }
- }
- else
- { MessageBoxCustom.Show("存模板失败!"); }
- }
- else
- {
- MessageBoxCustom.Show("存模板失败!");
- }
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show(String.Format("导出数据出错:{0}", ex.Message));
- }
- });
- }
- /// <summary>
- /// 读取模板
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnGetModule_Click(object sender, EventArgs e)
- {
- string StrExtension = ".Mban";
- if (this.chkWeekMode.Checked)
- { StrExtension = ".Wban"; }
- OpenFileDialog openFileDialog1 = new OpenFileDialog();
- openFileDialog1.Filter = "文件ban |*" + StrExtension;
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- {
- this.dgvData.Rows.Clear();
- DataGridViewRow dgvr = null;
- DataGridViewCell cell = null;
- DataTable dtPerson = orbll.GetView_Custom("tb_ErpUser", StrWhere: "User_Status='在职'", ShowColumnName: "User_EmployeeID,User_Name").Tables[0];
- DataTable dtExcel = LYFZ.WinAPI.CustomPublicMethod.GetExcelDatatable(openFileDialog1.FileName.Trim());
- string StrWhere = "";
- if (this.chkWeekMode.Checked)
- { StrWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Time", this.WeekStartDate.ToString("yyyy-MM-dd"), this.WeekEndDate.ToString("yyyy-MM-dd")); }
- else
- {
- string StrDateStart = this.dtpYearMonth.StrDateValue.Trim() + "-01";
- string StrDateEnd = Convert.ToDateTime(StrDateStart).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- StrWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Time", StrDateStart, StrDateEnd);
- }
- DataTable dt = this.GetWorkPerson();
- if (dtPerson.Rows.Count > 0)
- {
- for (int i = 0; i < dtPerson.Rows.Count; i++)
- {
- dgvr = new DataGridViewRow();
- cell = new DataGridViewTextBoxCell();
- cell.Value = dtPerson.Rows[i]["User_EmployeeID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = dtPerson.Rows[i]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- DataRow[] dtRows = dtExcel.Select("员工编号 = '" + dtPerson.Rows[i]["User_EmployeeID"].ToString().Trim() + "'");
- for (int j = 2; j < this.dgvData.Columns.Count; j++)
- {
- string StrCellValue = "";
- if (dtRows.Length > 0)
- {
- if (j < dtExcel.Columns.Count)
- {
- if (!string.IsNullOrEmpty(dtRows[0][j].ToString().Trim()))
- { StrCellValue = dtRows[0][j].ToString().Trim(); }
- }
- }
- cell = new DataGridViewTextBoxCell();
- cell.Value = StrCellValue.Trim();
- if (StrCellValue.Trim() == "休息")
- {
- string StrWhereDate = "";
- if (this.chkWeekMode.Checked)
- { StrWhereDate = this.WeekStartDate.AddDays((j - 2)).ToString("yyyy-MM-dd"); }
- else
- { StrWhereDate = Convert.ToDateTime(this.dtpYearMonth.StrDateValue.Trim() + "-01").AddDays((j - 2)).ToString("yyyy-MM-dd"); }
- DataRow[] dtRows2 = dt.Select("工作人员 = '" + dtPerson.Rows[i]["User_EmployeeID"].ToString().Trim() + "' And 工作日期 = '" + StrWhereDate + "'");
- if (dtRows2.Length > 0)
- { cell.Style.BackColor = Color.Red; }
- }
- dgvr.Cells.Add(cell);
- }
- this.dgvData.Rows.Add(dgvr);
- }
- }
- }
- }
- /// <summary>
- /// 获取人员
- /// </summary>
- /// <returns></returns>
- DataTable GetWorkPerson()
- {
- string StrDateStart = this.dtpYearMonth.StrDateValue.Trim() + "-01";
- string StrDateEnd = Convert.ToDateTime(StrDateStart).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- if (this.chkWeekMode.Checked)
- {
- StrDateStart = this.WeekStartDate.ToString("yyyy-MM-dd");
- StrDateEnd = this.WeekEndDate.ToString("yyyy-MM-dd");
- }
- string StrWhere = " Where" + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Convert(datetime,工作日期)", StrDateStart, StrDateEnd, ConnectWord: "");
- return this.GetWorkPerson(StrWhere);
- }
- /// <summary>
- /// 获取人员的DataTable
- /// </summary>
- /// <param name="StrWhere"></param>
- DataTable GetWorkPerson(string StrWhere)
- {
- string ExecuteSql = "with t AS ( " +
- "select Ordpg_ReservationPhotographyName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 工作日期 from tb_ErpOrdersPhotography Where Ordpg_ReservationPhotographyName != '' And Ordpg_ReservationPhotographyTime is not null " +
- "UNION ALL " +
- "select Ordpg_ReservationPhotographyAssistant AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 工作日期 from tb_ErpOrdersPhotography Where Ordpg_ReservationPhotographyAssistant != '' And Ordpg_ReservationPhotographyTime is not null " +
- "UNION ALL " +
- "select Ordpg_ReservationMakeupArtist AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 工作日期 from tb_ErpOrdersPhotography Where Ordpg_ReservationMakeupArtist != '' And Ordpg_ReservationPhotographyTime is not null " +
- "UNION ALL " +
- "select Ordpg_ReservationMakeupAssistant AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 工作日期 from tb_ErpOrdersPhotography Where Ordpg_ReservationMakeupAssistant != '' And Ordpg_ReservationPhotographyTime is not null " +
- "UNION ALL " +
- "select Ordpg_ReservationBootDivision AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 工作日期 from tb_ErpOrdersPhotography Where Ordpg_ReservationBootDivision != '' And Ordpg_ReservationPhotographyTime is not null " +
- "UNION ALL " +
- "select Ordpg_ReservationBootDivisionAssistant AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime)) AS 工作日期 from tb_ErpOrdersPhotography Where Ordpg_ReservationBootDivisionAssistant != '' And Ordpg_ReservationPhotographyTime is not null " +
- "UNION ALL " +
- "select Ordv_ReservationClothingName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationClothingTime)) AS 工作日期 from tb_ErpOrderDigital Where Ordv_ReservationClothingName != '' And Ordv_ReservationClothingTime is not null " +
- "UNION ALL " +
- "select Ordv_ReservationEarlyRepairName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationEarlyRepairTime)) AS 工作日期 from tb_ErpOrderDigital Where Ordv_ReservationEarlyRepairName != '' And Ordv_ReservationEarlyRepairTime is not null " +
- "UNION ALL " +
- "select Ordv_ReservationFilmSelectionName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationFilmSelectionTime)) AS 工作日期 from tb_ErpOrderDigital Where Ordv_ReservationFilmSelectionName != '' And Ordv_ReservationFilmSelectionTime is not null " +
- "UNION ALL " +
- "select Ordv_ReservationRefinementName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationRefinementTime)) AS 工作日期 from tb_ErpOrderDigital Where Ordv_ReservationRefinementName != '' And Ordv_ReservationRefinementTime is not null " +
- "UNION ALL " +
- "select Ordv_ReservationDesignerName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationDesignerTime)) AS 工作日期 from tb_ErpOrderDigital Where Ordv_ReservationDesignerName != '' And Ordv_ReservationDesignerTime is not null " +
- "UNION ALL " +
- "select Ordv_ReservationLookDesignName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationLookDesignTime)) AS 工作日期 from tb_ErpOrderDigital Where Ordv_ReservationLookDesignName != '' And Ordv_ReservationLookDesignTime is not null " +
- "UNION ALL " +
- "select Ordv_ReservationSendPhotoName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ReservationSendPhotoTime)) AS 工作日期 from tb_ErpOrderDigital Where Ordv_ReservationSendPhotoName != '' And Ordv_ReservationSendPhotoTime is not null " +
- "UNION ALL " +
- "select OPlist_ReservationTakeName AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(OPlist_ReservationTakeTime)) AS 工作日期 from tb_ErpOrderProductList where OPlist_Type = '2' And OPlist_ReservationTakeName != '' And OPlist_ReservationTakeTime is not null " +
- "UNION ALL " +
- "select Ws_Serviceman1 AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ws_WeddingDate)) AS 工作日期 from tb_ErpWeddingService Where Ws_Status = '0' And Ws_Serviceman1 != '' And Ws_WeddingDate is not null " +
- "UNION ALL " +
- "select Ws_Serviceman2 AS 工作人员,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ws_WeddingDate)) AS 工作日期 from tb_ErpWeddingService Where Ws_Status = '0' And Ws_Serviceman2 != '' And Ws_WeddingDate is not null " +
- ") " +
- "select * from t " + StrWhere + "Group By 工作人员,工作日期";
- return orbll.GetView_Custom(ExecuteSql).Tables[0];
- }
- /// <summary>
- /// 保存
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSaveed_Click(object sender, EventArgs e)
- {
- LYFZ.Model.Model_Loninbansets model = null;
- List<Helper.CommandInfo> clist = new List<Helper.CommandInfo>();
- string StrMages = "";
- for (int i = 0; i < this.dgvData.Rows.Count; i++)
- {
- string StrTip = "";
- for (int j = 2; j < this.dgvData.Columns.Count; j++)
- {
- if (this.dgvData.Rows[i].Cells[j].Value.ToString().Trim() == "休息" && this.dgvData.Rows[i].Cells[j].Style.BackColor == Color.Red)
- { StrTip += this.dgvData.Columns[j].Name.Trim().Replace("\r\n", "") + ","; }
- }
- if (!string.IsNullOrEmpty(StrTip))
- { StrMages += this.dgvData.Rows[i].Cells["姓名"].Value.ToString().Trim() + ":" + StrTip.TrimEnd(',') + "\r\n"; }
- }
- if (!string.IsNullOrEmpty(StrMages))
- { MessageBoxCustom.Show("列表中红色格子的休息日已安排有工作,不能安排休息!\r\n" + StrMages); return; }
- if (this.chkWeekMode.Checked)
- {
- string StrStartDate = this.WeekStartDate.ToString("yyyy-MM-dd");
- string StrEndDate = this.WeekEndDate.ToString("yyyy-MM-dd");
- string StrWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Time", StrStartDate, StrEndDate, ConnectWord: "");
- DataTable dt = orbll.GetView_Custom("loninbansets", StrWhere: StrWhere, ShowColumnName: "*").Tables[0];
- for (int i = 0; i < this.dgvData.Rows.Count; i++)
- {
- for (int j = 3; j < this.dgvData.Columns.Count; j++)
- {
- string StrNowDateTime = Convert.ToDateTime(this.WeekStartDate.AddDays(j - 3).ToString("yyyy-MM-dd")).ToString("yyyy-MM-dd HH:mm:ss");
- DataRow[] dtRows = dt.Select("User_ID = '" + this.dgvData.Rows[i].Cells["员工编号"].Value.ToString().Trim() + "' And Time = '" + StrNowDateTime + "'");
- if (dtRows.Length > 0)
- {
- if (this.dgvData.Rows[i].Cells[j].Value.ToString().Trim() != dtRows[0]["Fixed"].ToString().Trim())
- {
- model = lbsetbll.DataRowToModel(dtRows[0]);
- model.Fixed = this.dgvData.Rows[i].Cells[j].Value.ToString().Trim();
- model.Time = Convert.ToDateTime(model.Time).ToString("yyyy-MM-dd HH:mm:ss");
- clist.Add(lbsetbll.GetUpdateCommandInfo(model));
- }
- }
- else
- {
- model = new Model.Model_Loninbansets();
- model.User_ID = this.dgvData.Rows[i].Cells["员工编号"].Value.ToString().Trim();
- model.Time = StrNowDateTime;
- model.Fixed = this.dgvData.Rows[i].Cells[j].Value.ToString().Trim();
- clist.Add(lbsetbll.GetAddCommandInfo(model));
- }
- }
- }
- }
- else
- {
- string StrStartDate = this.dtpYearMonth.StrDateValue.Trim() + "-01";
- string StrEndDate = Convert.ToDateTime(StrStartDate).AddMonths(1).ToString("yyyy-MM-dd");
- string StrWhere = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Time", StrStartDate, StrEndDate, ConnectWord: "");
- DataTable dt = orbll.GetView_Custom("loninbansets", StrWhere: StrWhere, ShowColumnName: "*").Tables[0];
- for (int i = 0; i < this.dgvData.Rows.Count; i++)
- {
- for (int j = 1; j < this.dgvData.Columns.Count - 2; j++)
- {
- string StrNowDateTime = this.dtpYearMonth.StrDateValue.Trim() + "-" + (j).ToString("d2") + " 00:00:00";
- DataRow[] dtRows = dt.Select("User_ID = '" + this.dgvData.Rows[i].Cells["员工编号"].Value.ToString().Trim() + "' And Time = '" + StrNowDateTime + "'");
- if (dtRows.Length > 0)
- {
- if (this.dgvData.Rows[i].Cells[j + 2].Value.ToString().Trim() != dtRows[0]["Fixed"].ToString().Trim())
- {
- model = lbsetbll.DataRowToModel(dtRows[0]);
- model.Fixed = this.dgvData.Rows[i].Cells[j + 2].Value.ToString().Trim();
- model.Time = Convert.ToDateTime(model.Time).ToString("yyyy-MM-dd HH:mm:ss");
- clist.Add(lbsetbll.GetUpdateCommandInfo(model));
- }
- }
- else
- {
- model = new Model.Model_Loninbansets();
- model.User_ID = this.dgvData.Rows[i].Cells["员工编号"].Value.ToString().Trim();
- model.Time = StrNowDateTime;
- model.Fixed = this.dgvData.Rows[i].Cells[j + 2].Value.ToString().Trim();
- clist.Add(lbsetbll.GetAddCommandInfo(model));
- }
- }
- }
- }
- if (clist.Count > 0)
- {
- if (MessageBoxCustom.Show("您确定要保存吗?", "温馨提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- int intExecuteCount = 0;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- intExecuteCount = LYFZ.BLL.BaseBllOperate.ExecuteSqlTran(clist);
- });
- if (intExecuteCount > 0)
- { MessageBoxCustom.Show("保存成功!"); }
- else
- { MessageBoxCustom.Show("保存失败!"); }
- }
- }
- else
- { MessageBoxCustom.Show("没做过任何修改,无须保存!"); }
- }
- /// <summary>
- /// 时间设置
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnTimeSet_Click(object sender, EventArgs e)
- {
- frmTimeupdate frm = new frmTimeupdate();
- frm.ShowDialog();
- }
- /// <summary>
- /// 签单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSigned_Click(object sender, EventArgs e)
- {
- if (this.dgvData.SelectedRows.Count > 0)
- {
- frmTimesign frm = new frmTimesign();
- frm.StrUserNumber = this.dgvData.SelectedRows[0].Cells["员工编号"].Value.ToString().Trim();
- frm.StrUserName = this.dgvData.SelectedRows[0].Cells["姓名"].Value.ToString().Trim();
- frm.ShowDialog();
- }
- else
- { MessageBoxCustom.Show("请选择一个员工签单!"); }
- }
- /// <summary>
- /// 签单记录
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnSignedRecords_Click(object sender, EventArgs e)
- {
- frmtimeRecording frm = new frmtimeRecording();
- frm.ShowDialog();
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 选择年月
- /// </summary>
- /// <param name="SelectValue"></param>
- void dtpYearMonth_ClickChengedValue(string SelectValue)
- {
- this.GetQueryMonthData();
- }
- /// <summary>
- /// 周模式
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void chkzhouyue_Click(object sender, EventArgs e)
- {
- this.dgvData.Rows.Clear();
- if (this.chkWeekMode.Checked)
- {
- this.panelLastNextWeek.Visible = true;
- this.dtpYearMonth.Visible = false;
- this.lblWhichWeek.Visible = true;
- this.GetQueryWeekData();
- this.GetWeekCount();
- }
- else
- {
- this.panelLastNextWeek.Visible = false;
- this.dtpYearMonth.Visible = true;
- this.lblWhichWeek.Visible = false;
- this.frmTimeMain_Load(null, null);
- }
- }
- /// <summary>
- /// 鼠标焦点离开时
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cmbtreev_Leave(object sender, EventArgs e)
- {
- if (this.cmbtreev.Visible)
- {
- if (this.cmbtreev.Text.Trim() == "休息")
- {
- string StrTime = "";
- if (this.chkWeekMode.Checked == true)
- { StrTime = this.WeekStartDate.AddDays(this.dgvData.CurrentCell.ColumnIndex - 3).ToString("yyyy-MM-dd"); }
- else
- { StrTime = this.dtpYearMonth.StrDateValue + "-" + (this.dgvData.CurrentCell.ColumnIndex - 2).ToString("d2"); }
- string StrWhere = "where 工作人员='" + this.dgvData.CurrentRow.Cells["员工编号"].Value.ToString() + "' " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Convert(datetime,工作日期)", StrTime, StrTime) + " ";
- DataTable dt = new DataTable();
- #region 查询当安排为休息或者空时 判断该员工当天有没有安排
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- dt = this.GetWorkPerson(StrWhere);
- });
- if (dt.Rows.Count > 0)
- { MessageBoxCustom.Show("此员工当前时间已有安排!请选择正确的排班"); }
- else
- { this.dgvData.CurrentCell.Value = this.cmbtreev.Text.Trim(); }
- #endregion
- }
- else
- {
- this.dgvData.CurrentCell.Value = this.cmbtreev.Text.Trim();
- if (this.dgvData.CurrentCell.Style.BackColor == Color.Red)
- { this.dgvData.CurrentCell.Style.BackColor = this.dgvData.CurrentRow.Cells[this.dgvData.CurrentCell.ColumnIndex - 1].Style.BackColor; }
- }
- this.cmbtreev.Visible = false;
- }
- }
- /// <summary>
- /// 双击单元格显示下拉框
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
- {
- if (this.dgvData.Columns[e.ColumnIndex].HeaderText.Trim() != "姓名")
- {
- DataGridViewCell cell = this.dgvData.Rows[e.RowIndex].Cells[e.ColumnIndex];
- Rectangle rect = this.dgvData.GetCellDisplayRectangle(cell.ColumnIndex, cell.RowIndex, true);
- this.cmbtreev.Size = cell.Size;
- this.cmbtreev.Location = new Point(rect.Location.X + this.dgvData.Location.X, rect.Location.Y + this.dgvData.Location.Y);
- this.cmbtreev.Visible = true;
- if (cell.Value != System.DBNull.Value)
- { this.cmbtreev.TextFindTag(cell.Value.ToString().Trim()); }
- this.cmbtreev.Focus();
- }
- }
- }
- /// <summary>
- /// 右键菜单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- this.dgvData.conMenu.Items.Clear();
- ToolStripMenuItem item = null;
- string StrTime = "";
- if (this.chkWeekMode.Checked == true)
- { StrTime = this.WeekStartDate.AddDays(e.ColumnIndex - 3).ToString("yyyy-MM-dd"); }
- else
- { StrTime = this.dtpYearMonth.StrDateValue + "-" + (e.ColumnIndex - 2).ToString("d2"); }
- List<string> strList = new List<string>(this.StrTextName.Split(','));
- for (int i = 0; i < strList.Count; i++)
- {
- item = new ToolStripMenuItem();
- item.Text = strList[i].Trim();
- item.Tag = StrTime + "|" + e.ColumnIndex;
- this.dgvData.conMenu.Items.Add(item);
- }
- }
- }
- /// <summary>
- /// 右键菜单选择项事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_DataGridViewConMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- ToolStripItem item = e.ClickedItem;
- string[] StrSplit = item.Tag.ToString().Trim().Split('|');
- if (item.Text.Trim() == "休息"|| item.Text.Trim() == "请假")
- {
- string StrMagess = "";
- string StrpPrson = "";
- List<string> StrList = new List<string>();
- for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
- {
- StrList.Add(this.dgvData.SelectedRows[i].Cells["员工编号"].Value.ToString().Trim());
- StrpPrson += "'" + this.dgvData.SelectedRows[i].Cells["员工编号"].Value.ToString().Trim() + "',";
- }
- Hashtable htData = new Hashtable();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- string StrWhere = "where 工作人员 in (" + StrpPrson.TrimEnd(',') + ") " + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Convert(datetime,工作日期)", StrSplit[0].Trim(), StrSplit[0].Trim()) + " ";
- DataTable dt = this.GetWorkPerson(StrWhere);
- for (int i = 0; i < StrList.Count; i++)
- {
- DataRow[] dtRows = dt.Select("工作人员 = '" + StrList[i].Trim() + "'");
- if (dtRows.Length > 0)
- { StrMagess += LYFZ.BLL.BLL_ErpOrderView.GetUserName(StrList[i].Trim()) + ","; }
- else
- { htData[StrList[i].Trim()] = item.Text.Trim(); }
- }
- });
- for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
- {
- if (htData.ContainsKey(this.dgvData.SelectedRows[i].Cells["员工编号"].Value.ToString().Trim()))
- { this.dgvData.SelectedRows[i].Cells[Convert.ToInt32(StrSplit[1])].Value = item.Text.Trim(); }
- }
- if (StrMagess.Trim().Length > 0)
- { MessageBoxCustom.Show("员工:" + StrMagess + ",当前时间已有安排!请选择正确的排班"); }
- }
- else
- {
- for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
- {
- this.dgvData.SelectedRows[i].Cells[Convert.ToInt32(StrSplit[1])].Value = item.Text.Trim();
- if (this.dgvData.SelectedRows[i].Cells[Convert.ToInt32(StrSplit[1])].Style.BackColor == Color.Red)
- { this.dgvData.SelectedRows[i].Cells[Convert.ToInt32(StrSplit[1])].Style.BackColor = this.dgvData.SelectedRows[i].Cells[Convert.ToInt32(StrSplit[1]) - 1].Style.BackColor; }
- }
- }
- }
- /// <summary>
- /// 列表滚动条滚动事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_Scroll(object sender, ScrollEventArgs e)
- {
- if (this.cmbtreev.Visible)
- { this.cmbtreev_Leave(this, null); }
- }
- /// <summary>
- /// 窗体大小发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void frmTimeMain_Resize(object sender, EventArgs e)
- {
- switch (this.panelClose.Location.Y)
- {
- case 1: this.flowLayoutPanel1.Height = 31; break;
- case 31: this.flowLayoutPanel1.Height = 62; break;
- }
- }
- /// <summary>
- /// 获取Excel数据
- /// </summary>
- /// <param name="path"></param>
- /// <returns></returns>
- DataTable FromExcel(string path)
- {
- string strConn;
- strConn = "provider=microsoft.jet.oledb.4.0;data source=" + path + ";extended properties=excel 8.0";
- OleDbConnection OleConn = new OleDbConnection(strConn);
- OleConn.Open();
- String sql = "SELECT * FROM [Sheet1$]";//改变这sql语句取你需要的
- OleDbDataAdapter OleDaExcel = new OleDbDataAdapter(sql, OleConn);
- DataSet OleDsExcle = new DataSet();
- OleDaExcel.Fill(OleDsExcle);
- OleConn.Close();
- return OleDsExcle.Tables[0];
- }
- /// <summary>
- /// 获取当前星期是今年的第几周
- /// </summary>
- void GetWeekCount()
- {
- int IntWeekCount = (this.WeekStartDate.DayOfYear / 7);
- DateTime d1 = new DateTime(this.WeekStartDate.Year, 1, 1);
- if (d1.DayOfWeek != 0)
- { IntWeekCount += 2; }
- else
- { IntWeekCount += 1; }
- this.lblWhichWeek.Text = "第" + IntWeekCount + "周";
- }
- /// <summary>
- /// 周查询
- /// </summary>
- void GetQueryWeekData()
- {
- string StrColumnName = "员工编号,部门,姓名";
- for (int i = 0; i < 7; i++)
- {
- int dd = this.WeekStartDate.AddDays(i).Day;
- int MM = this.WeekStartDate.AddDays(i).Month;
- switch (i)
- {
- case 0: StrColumnName += ",星期日\r\n" + MM + "月" + dd + "日";
- break;
- case 1: StrColumnName += ",星期一\r\n" + MM + "月" + dd + "日";
- break;
- case 2: StrColumnName += ",星期二\r\n" + MM + "月" + dd + "日";
- break;
- case 3: StrColumnName += ",星期三\r\n" + MM + "月" + dd + "日";
- break;
- case 4: StrColumnName += ",星期四\r\n" + MM + "月" + dd + "日";
- break;
- case 5: StrColumnName += ",星期五\r\n" + MM + "月" + dd + "日";
- break;
- case 6: StrColumnName += ",星期六\r\n" + MM + "月" + dd + "日";
- break;
- }
- }
- this.dgvData.DataColumns(StrColumnName, strHideField: "员工编号");
- this.dgvData.Columns["姓名"].Frozen = true;
- int IntdgvDataColumnsCount = this.dgvData.Columns.GetColumnCount(DataGridViewElementStates.Visible);
- int intdgvDataWidth = (this.dgvData.Width - 50) / IntdgvDataColumnsCount;
- for (int i = 0; i < this.dgvData.Columns.Count; i++)
- { this.dgvData.Columns[i].Width = intdgvDataWidth; }
- string companyWhere = "";
- ItemValue itemValue = GetCompanyDataInfo();
- if (!string.IsNullOrEmpty(itemValue.Value.ToString_s()))
- {
- companyWhere = itemValue.Value.ToString_s();
- }
- //if(!string.IsNullOrEmpty(((ItemValue)cbxCompanyList.SelectedItem).Value.ToString_s()))
- //{
- // companyWhere = " and User_DividedShop = '" + ((ItemValue)cbxCompanyList.SelectedItem).Value.ToString_s()+"'";
- //}
- DataSet dtSet = new DataSet();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- string ExecuteSql = "select Dt_Name,User_EmployeeID,User_Name from tb_ErpUser Left Join tb_ErpDepartment on tb_ErpDepartment.ID = User_Department where User_Status='在职' And User_Account <> 'admin' " + companyWhere + " order by tb_ErpDepartment.ID;";
- ExecuteSql += "select User_ID,fixed,dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(time)) AS time from loninbansets where time >= '" + this.WeekStartDate.ToString("yyyy-MM-dd 00:00:00") + "' and time <= '" + this.WeekEndDate.ToString("yyyy-MM-dd HH:mm:ss") + "' order by time;";
- dtSet = orbll.GetView_Custom(ExecuteSql);
- });
- DataTable da = dtSet.Tables["ds"];
- DataTable dt = dtSet.Tables["ds1"];
- for (int i = 0; i < da.Rows.Count; i++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- cell = new DataGridViewTextBoxCell();
- cell.Value = da.Rows[i]["User_EmployeeID"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = da.Rows[i]["Dt_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- cell = new DataGridViewTextBoxCell();
- cell.Value = da.Rows[i]["User_Name"].ToString().Trim();
- dgvr.Cells.Add(cell);
- for (int j = 3; j < this.dgvData.Columns.Count; j++)
- {
- cell = new DataGridViewTextBoxCell();
- cell.Value = "";
- DataRow[] dtRow = dt.Select("user_id = '" + da.Rows[i]["User_EmployeeID"].ToString().Trim() + "' And time = '" + this.WeekStartDate.AddDays(j - 3).ToString("yyyy-MM-dd") + "'");
- if (dtRow.Length > 0)
- {
- if (!string.IsNullOrEmpty(dtRow[0]["fixed"].ToString()))
- { cell.Value = dtRow[0]["fixed"]; }
- }
- dgvr.Cells.Add(cell);
- }
- this.dgvData.Rows.Add(dgvr);
- }
- this.dgvData.ClearSelection();
- }
- 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;
- }
- /// <summary>
- /// 月查询
- /// </summary>
- void GetQueryMonthData()
- {
- string companyWhere = "";
- ItemValue itemValue = GetCompanyDataInfo();
- if(!string.IsNullOrEmpty(itemValue.Value.ToString_s()))
- {
- companyWhere = itemValue.Value.ToString_s();
- }
- int yyyy = Convert.ToInt32(this.dtpYearMonth.StrYear);
- int MM = Convert.ToInt32(this.dtpYearMonth.StrMonth);
- DataSet dtSet = new DataSet();
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, System.ComponentModel.BackgroundWorker backgroundWorker)
- {
- string ExecuteSql = "select Dt_Name,User_EmployeeID,User_Name from tb_ErpUser Left Join tb_ErpDepartment on tb_ErpDepartment.ID = User_Department where User_Status='在职' And User_Account <> 'admin' "+ companyWhere + " order by tb_ErpDepartment.ID;";
- ExecuteSql += "select User_ID,fixed,time from loninbansets where datename(yyyy,Time)='" + yyyy + "' and datename(MM,Time)='" + MM.ToString("d2") + "';";
- dtSet = orbll.GetView_Custom(ExecuteSql);
- });
- DataTable da = dtSet.Tables["ds"];
- DataTable dt = dtSet.Tables["ds1"];
-
- this.dgvData.Rows.Clear();
- this.dgvData.Columns.Clear();
-
- string StrColumnName = "员工编号,部门,姓名";
- int intDsy = Convert.ToInt32(Convert.ToDateTime(this.dtpYearMonth.StrDateValue.Trim() + "-01").AddMonths(1).AddSeconds(-1).ToString("dd"));
- for (int i = 0; i < intDsy; i++)
- {
- StrColumnName += "," + (i + 1) + "日" + Environment.NewLine + Convert.ToDateTime(this.dtpYearMonth.StrDateValue + "-01").AddDays(i).ToString("dddd") + "";
- }
- this.dgvData.DataColumns(StrColumnName, strHideField: "员工编号");
- this.dgvData.Columns["姓名"].Frozen = true;
- for (int i = 0; i < this.dgvData.Columns.Count; i++)
- {
- switch (this.dgvData.Columns[i].Name.Trim())
- {
- case "姓名":
- this.dgvData.Columns[i].Width = 80;
- break;
- default:
- this.dgvData.Columns[i].Width = 80;
- break;
- }
- }
- for (int i = 0; i < da.Rows.Count; i++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- DataGridViewCell cell = null;
- for (int j = 0; j < dgvData.Columns.Count; j++)
- {
- cell = new DataGridViewTextBoxCell();
- switch (j)
- {
- case 0:
- cell.Value = da.Rows[i]["User_EmployeeID"];
- break;
- case 1:
- cell.Value = da.Rows[i]["Dt_Name"].ToString().Trim();
- break;
- case 2:
- cell.Value = da.Rows[i]["User_Name"];
- break;
- default:
- cell.Value = "";
- DataRow[] dtRow = dt.Select("user_id='" + da.Rows[i]["User_EmployeeID"] + "' And time = '" + Convert.ToDateTime((this.dtpYearMonth.StrDateValue + "-" + (j - 2).ToString("d2"))) + "'");
- if (dtRow.Length > 0)
- {
- if (!string.IsNullOrEmpty(dtRow[0]["fixed"].ToString()))
- { cell.Value = dtRow[0]["fixed"]; }
- }
- break;
- }
- dgvr.Cells.Add(cell);
- }
- this.dgvData.Rows.Add(dgvr);
- }
- this.dgvData.ClearSelection();
- }
- /// <summary>
- /// 把空数据转换成SQL的空字符
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- string SqlNull(object obj)
- {
- if (obj == null)
- return "";
- return obj.ToString().Trim();
- }
- }
- }
|