public static DateTime GetLastBackupTime() { Hownet.BLL.OtherType bllOT = new Hownet.BLL.OtherType(); DataTable dtTem = bllOT.GetList("(Name='备份文件夹位置')").Tables[0]; string filePath = "C:\\"; if (dtTem.Rows.Count > 0) { filePath = dtTem.Rows[0]["Value"].ToString(); } DirectoryInfo di = new DirectoryInfo(filePath); FileInfo[] arrFi = di.GetFiles("*.bak"); // SortAsFileCreationTime(ref arrFi); if (arrFi.Length > 0) { DataTable dt = new DataTable(); dt.Columns.Add("One"); dt.Columns.Add("Two", typeof(DateTime)); for (int i = 0; i < arrFi.Length; i++) { dt.Rows.Add(arrFi[i].Name, Convert.ToDateTime(arrFi[i].CreationTime)); } dt.DefaultView.Sort = "Two DESC"; return(Convert.ToDateTime(dt.DefaultView[0]["Two"])); } else { return(Convert.ToDateTime("1900-1-1")); } }
private void CaicMinute(int ID) { try { modAR = bllAR.GetModel(ID); int a = 0; modAR.DayWorkMin = modAR.AbsenteeismMin = modAR.BeLateMin = modAR.OvertimeMin = modAR.LeaveEarlyMin = modAR.LateAtNight = 0; Hownet.BLL.OtherType bllOT = new Hownet.BLL.OtherType(); bool IsCaic = Convert.ToInt32(bllOT.GetList("(Name='按实际刷卡计时')").Tables[0].Rows[0]["Value"]) == 1; if (IsCaic) { if (modAR.TimeOne.HasValue && modAR.TimeTwo.HasValue) { TimeSpan ts = (TimeSpan)(modAR.TimeTwo - modAR.TimeOne); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.DayWorkMin += a; } } if (modAR.TimeThree.HasValue && modAR.TimeFour.HasValue) { TimeSpan ts = (TimeSpan)(modAR.TimeFour - modAR.TimeThree); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.DayWorkMin += a; } } if (modAR.TimeFive.HasValue && modAR.TimeSix.HasValue) { DateTime ddN = Convert.ToDateTime(modAR.DateDay.Date.ToShortDateString() + " " + BasicTable.dtAttRules.Select("(Name='lThree')")[0]["Value"]); //晚上加班下班时间,用于判断晚班有深夜班时间 if (!(ddN < (DateTime)(modAR.TimeSix))) //晚上下班提前或正常下班的。 { TimeSpan ts = (TimeSpan)(modAR.TimeSix - modAR.TimeFive); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.OvertimeMin = a; } } else//超过夜班下班时间的。 { TimeSpan ts = (TimeSpan)(ddN - modAR.TimeFive); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.OvertimeMin = a; } ts = (TimeSpan)(modAR.TimeSix - ddN); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.LateAtNight = a; } } } } else { DateTime ddt = modAR.DateDay; DateTime one = Convert.ToDateTime(ddt.Date.ToShortDateString() + " " + BasicTable.dtAttRules.Select("(Name='One')")[0]["Value"].ToString()); DateTime lone = Convert.ToDateTime(ddt.Date.ToShortDateString() + " " + BasicTable.dtAttRules.Select("(Name='lOne')")[0]["Value"].ToString()); DateTime two = Convert.ToDateTime(ddt.Date.ToShortDateString() + " " + BasicTable.dtAttRules.Select("(Name='Two')")[0]["Value"].ToString()); DateTime ltwo = Convert.ToDateTime(ddt.Date.ToShortDateString() + " " + BasicTable.dtAttRules.Select("(Name='lTwo')")[0]["Value"].ToString()); DateTime three = Convert.ToDateTime(ddt.Date.ToShortDateString() + " " + BasicTable.dtAttRules.Select("(Name='Three')")[0]["Value"].ToString()); DateTime lthree = Convert.ToDateTime(ddt.Date.ToShortDateString() + " " + BasicTable.dtAttRules.Select("(Name='lThree')")[0]["Value"].ToString()); if (modAR.TimeOne.HasValue && modAR.TimeTwo.HasValue) { if (modAR.TimeTwo < lone) { lone = Convert.ToDateTime(modAR.TimeTwo); } if (modAR.TimeOne > one) { one = Convert.ToDateTime(modAR.TimeOne); } TimeSpan ts = (TimeSpan)(lone - one); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.DayWorkMin += a; } } if (modAR.TimeThree.HasValue && modAR.TimeFour.HasValue) { if (modAR.TimeFour < ltwo) { ltwo = Convert.ToDateTime(modAR.TimeFour); } if (modAR.TimeThree > two) { two = Convert.ToDateTime(modAR.TimeThree); } TimeSpan ts = (TimeSpan)(ltwo - two); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.DayWorkMin += a; } } if (modAR.TimeFive.HasValue && modAR.TimeSix.HasValue) { if (!(lthree < (DateTime)(modAR.TimeSix))) //晚上下班提前或正常下班的。 { if (modAR.TimeFive > three) { three = Convert.ToDateTime(modAR.TimeFive); } TimeSpan ts = (TimeSpan)(modAR.TimeSix - three); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.OvertimeMin = a; } } else//超过夜班下班时间的。 { if (modAR.TimeFive > three) { three = Convert.ToDateTime(modAR.TimeFive); } TimeSpan ts = (TimeSpan)(lthree - three); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.OvertimeMin = a; } ts = (TimeSpan)(modAR.TimeSix - lthree); a = ts.Hours * 60 + ts.Minutes; if (a > 0) { modAR.LateAtNight = a; } } } } } catch (Exception ex) { } bllAR.Update(modAR); }
private void frCompanyInfo_Load(object sender, EventArgs e) { dtOT = bllOT.GetList("(TypeID=" + (int)Hownet.BLL.Enums.OtherType.系统设置 + ")").Tables[0]; DataRow[] drs = dtOT.Select("(Name='物料使用条码出入仓')"); if (drs.Length == 0) { DataTable dtTem = dtOT.Clone(); DataRow dr = dtTem.NewRow(); dr["A"] = 1; dr["ID"] = 0; dr["Name"] = "物料使用条码出入仓"; dr["TypeID"] = (int)Hownet.BLL.Enums.OtherType.系统设置; dr["Value"] = "False"; dtTem.Rows.Add(dr); bllOT.AddByDt(dtTem); } else { try { _chb物料使用条码出入仓.Checked = Convert.ToBoolean(drs[0]["Value"]); } catch (Exception ex) { } } drs = dtOT.Select("(Name='成品需按货架存放')"); if (drs.Length == 0) { DataTable dtTem = dtOT.Clone(); DataRow dr = dtTem.NewRow(); dr["A"] = 1; dr["ID"] = 0; dr["Name"] = "成品需按货架存放"; dr["TypeID"] = (int)Hownet.BLL.Enums.OtherType.系统设置; dr["Value"] = "False"; dtTem.Rows.Add(dr); bllOT.AddByDt(dtTem); } else { try { _chb成品需按货架存放.Checked = Convert.ToBoolean(drs[0]["Value"]); } catch (Exception ex) { } } drs = dtOT.Select("(Name='分组显示为部位')"); if (drs.Length == 0) { DataTable dtTem = dtOT.Clone(); DataRow dr = dtTem.NewRow(); dr["A"] = 1; dr["ID"] = 0; dr["Name"] = "分组显示为部位"; dr["TypeID"] = (int)Hownet.BLL.Enums.OtherType.系统设置; dr["Value"] = "False"; dtTem.Rows.Add(dr); bllOT.AddByDt(dtTem); } else { try { _chb分组显示为部位.Checked = Convert.ToBoolean(drs[0]["Value"]); } catch (Exception ex) { } } drs = dtOT.Select("(Name='备份文件夹位置')"); if (drs.Length == 0) { DataTable dtTem = dtOT.Clone(); DataRow dr = dtTem.NewRow(); dr["A"] = 1; dr["ID"] = 0; dr["Name"] = "备份文件夹位置"; dr["TypeID"] = (int)Hownet.BLL.Enums.OtherType.系统设置; dr["Value"] = @"E:\Backup"; dtTem.Rows.Add(dr); bllOT.AddByDt(dtTem); } else { try { _teBackUpDir.Text = drs[0]["Value"].ToString(); } catch (Exception ex) { } } int _id = bllST.GetMaxId() - 1; // ds = bllST.GetList("(ID=" + _id + ")"); modST = bllST.GetModel(_id); Hownet.BLL.Working bllW = new Hownet.BLL.Working(); Hownet.BLL.Deparment bllD = new Hownet.BLL.Deparment(); _coBackDepot.DataSource = bllW.GetList("(IsSpecial=0)").Tables[0]; DataTable dtD = bllD.GetList("(TypeID=42)").Tables[0]; _coDefaultRaw.DataSource = dtD; DataTable dtDD = bllD.GetList("(TypeID=42) OR (TypeID=39)").Tables[0]; //DataRow dr = dtDD.NewRow(); //dr["ID"] = 0; //dr["Name"] = string.Empty; //dtDD.Rows.Add(dr); _coDefaultDepot.DataSource = dtDD; if (modST != null) { ID = modST.ID; _address.Text = modST.Address; _bank.Text = modST.BanKName; _bankID.Text = modST.BankNO; _bankUser.Text = modST.BankUserName; _comName.Text = modST.CompanyName; _fax.Text = modST.Fax; _linkMan.Text = modST.LinkMan; _phone.Text = modST.Phone; _ceDirect.Checked = modST.Direct2Depot; _ceSell.Checked = modST.Sell4Depot; _ceAutoClient.Checked = modST.AutoClient; _chBoxOrPic.Checked = modST.BoxOrPic; _Mobile.Text = modST.Mobile; _coNumType.SelectedIndex = modST.NumType; _coSellMoney.SelectedIndex = modST.SellMoney; _ceCustom.Checked = modST.CustOder; _chNotPermissions.Checked = modST.NotPermissions; _ceDepotAllowNegative.Checked = modST.DepotAllowNegative; _ceIsChangedSales.Checked = modST.IsChangedSales; _coBackDepot.SelectedValue = modST.BackDepotWorking; _mbOderOne.Text = modST.OderOne.ToString().PadLeft(2, '0'); _mbOderTwo.Text = modST.OderTwo.ToString().PadLeft(2, '0'); _mbOrderThree.Text = modST.OderThree.ToString().PadLeft(2, '0'); _ceAutoCaicBoardWages.Checked = modST.AutoCaicBoardWages; _coDefaultRaw.SelectedValue = modST.DefaultRawDepot; _coDefaultDepot.SelectedValue = modST.DefaultDepot; _ceIsShowMoney.Checked = modST.IsShowMoney; _ceCompanyByUser.Checked = modST.CompanyByUser; _teDoubleNotDefaultWTNum.Text = modST.DoubleNotDefaultWTNum.ToString(); _meOrderDays.Text = modST.OrderDays.ToString(); _ceOrderNeedEat.Checked = modST.OrderNeedEat; _ceIsCheckNoWork.Checked = modST.IsCheckNoWork; _ceIsCanEditAmount.Checked = modST.IsCanEditAmount; _ceIsAutoClose.Checked = modST.IsAutoClose; _ceIsTicketNotNeedCaic.Checked = modST.IsTicketNotNeedCaic; _ceIsShowOutEmp.Checked = modST.IsShowOutEmp; _chMaterielByTask.Checked = modST.MaterielByTask; _chMaterielByTask.Enabled = bllST.CheckCanSetMatByTask(); _ceSumByWorking.Checked = modST.SumByWorking; _tbRegistration.Text = modST.Registration; } else { modST = new Hownet.Model.SysTem(); _coDefaultRaw.SelectedValue = _coDefaultDepot.SelectedValue = 0; _teDoubleNotDefaultWTNum.Text = "0"; } }