public void cb1_SelectedValueChanged() { Double h = 0; string sql = "Select * from TBLDETAILSROSTER where SHI_ID=N'" + cb1 + "'"; RecordSet rs = new RecordSet(sql, PublicFunction.C_con); for (int i = 0; i < rs.rows; i++) { double on = T_String.IsNullTo00(rs.record(i, "ONN_TM")); double off = T_String.IsNullTo00(rs.record(i, "OFF_TM")); if (on > off) { off = off + 2400; } if (rs.record(i, "TYP_ID") + "" == "ATT_HR" || rs.record(i, "TYP_ID") + "" == "NIG_HR") { h = T_String.CongTG(T_String.TruTG(off, on), h); } } if (h <= 0) { h = 8; } else { txt_h = T_String.DT_HourMinConvertToHour((int)h).ToString("#,##0.##"); } cal(); }
public void dt3_ValueChanged() { if (dt3.ToString("HH:mm") != "" && dt4.ToString("HH:mm") != "") { double tam = T_String.TruTG(T_String.IsNullTo00(dt4.ToString("HH:mm").Replace(":", "")), T_String.IsNullTo00(dt3.ToString("HH:mm").Replace(":", ""))); txt_h1 = T_String.IsNullTo00((((int)tam / 100) + ((tam % 100) / 60)).ToString("N", new CultureInfo("en-US")) + "").ToString("#,##0.##"); } cal(); }
public double GetHourAndPhep(double t3, double t4, List <Tblleave> phep) { double t1 = t3, t2 = t4; //for (int i = 0; i < phep.rows; i++) if (phep.Count() > 0) { double c1 = IsN(phep[0].StrTm); // gio vao double c2 = IsN(phep[0].EndTm); // gio ra if (c2 < c1) { c2 = T_String.CongTG(c2, 2400.0); } else { if ((t1 >= 2400 || t2 >= 2400) && (t1 > c1 && t1 > c2)) { c1 = T_String.CongTG(c1, 2400.0); c2 = T_String.CongTG(c2, 2400.0); } } //Nằm ngoài phép if (t1 > c2 || t2 < c1) { return(T_String.TruTG(t2, t1)); } //Tr/hợp cả 2 nằm trong phép if (t1 >= c1 && t2 <= c2) { return(0); } //Có giao với phép double tong = 0; if (t1 < c1) { tong = T_String.TruTG(c1, t1); } if (t2 > c2) { tong += T_String.TruTG(t2, c2); } return(tong); } return(T_String.TruTG(t2, t1)); }
public void UpdateSql() { string sql1 = ""; string sql = ""; Get_ATT_HR(); var phep = (from l in _db.Tblleave join tl in _db.Tbltypeleave on l.LeaId equals tl.LeaId where l.EmpId == EMP_ID && l.StrDt.Value.CompareTo(DateTime.Parse(ATT_DT)) <= 0 && l.EndDt.Value.CompareTo(DateTime.Parse(ATT_DT)) >= 0 select new ExLeave() { leave = l, leave_name = tl.LeaNm }).ToList(); GetPhep(phep); //Round(); GetNote(); var roster = _db.Tblroster.Where(x => x.ShiId == SHI_ID).FirstOrDefault(); double ADD_H1 = T_String.IsNullTo00(roster.AddH1 + ""); double ADD_H2 = T_String.IsNullTo00(roster.AddH2 + ""); double CON_H1 = T_String.IsNullTo00(roster.ConH1 + ""); double CON_H2 = T_String.IsNullTo00(roster.ConH2 + ""); if (NOT_DD + "" != "") { NOT_DR = NOT_DD + "; " + NOT_DR; } var _tdt = DateTime.Parse(ATT_DT); var att = _db.Tbldetailsattendance.Where(x => x.AttDt == _tdt && x.EmpId == EMP_ID).FirstOrDefault(); if (att == null) { return; } sql = "Update [" + tb + "] set "; double WRK_HR = 0; for (int i = 0; i < Name.Count; i++) { switch (Name[i] + "") { case "ATT_HR": if (ATT_MAX > 0) { if (ADD_H1 > 0 && (Double)Data[i] > CON_H1) { ATT_MAX = T_String.CongTG(ATT_MAX, ADD_H1); if ((Double)Data[i] > 0) { Data[i] = T_String.CongTG(ADD_H1, (Double)Data[i]); } } WRK_HR = T_String.CongTG(WRK_HR, (Double)Data[i]); //T_String.IsNullTo00(Data[i]+"")); int tam = (int)T_String.CongTG(T_String.IsNullTo0(Data[i] + ""), OTR_HR); if (sql1 != "") { sql1 += ","; } //var tmpa = T_String.DT_HourMinConvertToHour(tam); //var tmpb = T_String.DT_HourMinConvertToHour((int)ATT_MAX); sql1 += "ATT_DY=" + T_String.DT_HourMinConvertToHour(tam) / T_String.DT_HourMinConvertToHour((int)ATT_MAX); T_String.SetPropValue(att, "AttDy", T_String.DT_HourMinConvertToHour(tam) / T_String.DT_HourMinConvertToHour((int)ATT_MAX)); } else { if (sql1 != "") { sql1 += ","; } sql1 += "ATT_DY=0"; T_String.SetPropValue(att, "AttDy", 0); } break; case "NIG_HR": if ((Double)Data[i] > CON_H2) { if (NIG_MAX > 0) { if (ADD_H2 > 0) { NIG_MAX = T_String.CongTG(NIG_MAX, ADD_H2); if ((Double)Data[i] > 0) { Data[i] = T_String.CongTG(ADD_H2, (Double)Data[i]); } } WRK_HR = T_String.CongTG(WRK_HR, (Double)Data[i]); int tam = (int)T_String.CongTG(T_String.IsNullTo0(Data[i] + ""), OTR_HR); if (sql1 != "") { sql1 += ","; } sql1 += "NigDy=" + T_String.DT_HourMinConvertToHour(tam) / T_String.DT_HourMinConvertToHour((int)NIG_MAX); T_String.SetPropValue(att, "NigDy", T_String.DT_HourMinConvertToHour(tam) / T_String.DT_HourMinConvertToHour((int)NIG_MAX)); } else { if (sql1 != "") { sql1 += ","; } sql1 += "NIG_DY=0"; T_String.SetPropValue(att, "NigDy", 0); } } break; case "OTT_HR": case "OVO_HR": break; } if (sql1 != "") { sql1 += ","; } sql1 += Name[i] + "=" + Data[i]; var _name = Regex.Replace((Name[i] + "").ToLower(), @"([a-z0-9]+)_([a-z0-9]+)", m => string.Format("{0}{1}", Char.ToUpperInvariant(m.Groups[1].Value[0]) + m.Groups[1].Value.Substring(1), Char.ToUpperInvariant(m.Groups[2].Value[0]) + m.Groups[2].Value.Substring(1))); /*(Name[i] + "").ToLower();*/ T_String.SetPropValue(att, _name + "", Data[i]); } sql = sql + sql1; if (ABS_TM > 0) { double max = T_String.CongTG(ATT_MAX, NIG_MAX); ABS_MN = T_String.TruTG(max, WRK_HR); ABS_MN = T_String.TruTG(ABS_MN, LEA_H1); ABS_MN = T_String.TruTG(ABS_MN, LEA_H2); ABS_MN = T_String.TruTG(ABS_MN, LEA_H3); ABS_MN = T_String.TruTG(ABS_MN, OTR_HR); if (ABS_MN == 0) { ABS_TM = 0; NOT_DR = NOT_DR.Replace("Absent;", ""); } } sql += ",NOT_DR=N'" + NOT_DR + "'"; T_String.SetPropValue(att, "NotDr", NOT_DR); sql += ",NOT_D1=N'" + NOT_D1 + "'"; T_String.SetPropValue(att, "NotD1", NOT_D1); sql += ",LAT_MN=N'" + LAT_MN + "'"; T_String.SetPropValue(att, "LatMn", LAT_MN); sql += ",LAT_TM=N'" + LAT_TM + "'"; T_String.SetPropValue(att, "LatTm", LAT_TM); sql += ",EAR_MN=N'" + EAR_MN + "'"; T_String.SetPropValue(att, "EarMn", EAR_MN); sql += ",EAR_TM=N'" + EAR_TM + "'"; T_String.SetPropValue(att, "EarTm", EAR_TM); sql += ",ABS_MN=N'" + ABS_MN + "'"; T_String.SetPropValue(att, "AbsMn", ABS_MN); sql += ",ABS_TM=N'" + ABS_TM + "'"; T_String.SetPropValue(att, "AbsTm", ABS_TM); sql += ",OTR_HR=" + OTR_HR.ToString("#0") + ""; T_String.SetPropValue(att, "OtrHr", OTR_HR.ToString("#0")); sql += ",LEA_H1=" + LEA_H1.ToString("#0") + ""; T_String.SetPropValue(att, "LeaH1", LEA_H1.ToString("#0")); sql += ",LEA_I1=N'" + LEA_I1 + "'"; T_String.SetPropValue(att, "LeaI1", LEA_I1); sql += ",LEA_H2=" + LEA_H2.ToString("#0") + ""; T_String.SetPropValue(att, "LeaH2", LEA_H2.ToString("#0")); sql += ",LEA_I2=N'" + LEA_I2 + "'"; T_String.SetPropValue(att, "LeaI2", LEA_I2); sql += ",LEA_H3=" + LEA_H3.ToString("#0") + ""; T_String.SetPropValue(att, "LeaH3", LEA_H3.ToString("#0")); sql += ",LEA_I3=N'" + LEA_I3 + "'"; T_String.SetPropValue(att, "LeaI3", LEA_I3); _db.SaveChanges(); sql += " where EMP_ID=N'" + EMP_ID + "' and ATT_DT='" + ATT_DT + "'"; }
public void Get_ATT_HR() { double ONN_MN = IsD(SYS_SETTING_ATT.ONN_MN); double OFF_MN = IsD(SYS_SETTING_ATT.OFF_MN); string ONN_BT = SYS_SETTING_ATT.ONN_BT; string OFF_BT = SYS_SETTING_ATT.OFF_BT; var phep = (from l in _db.Tblleave join tl in _db.Tbltypeleave on l.LeaId equals tl.LeaId where l.EmpId == EMP_ID && l.StrDt.Value.CompareTo(DateTime.Parse(ATT_DT)) <= 0 && l.EndDt.Value.CompareTo(DateTime.Parse(ATT_DT)) >= 0 select new ExLeave() { leave = l, leave_name = tl.LeaNm }).ToList(); Boolean QD = false; double c = 0; for (int i = 0; i < rsca.Count(); i++) { double c1 = IsN(rsca[i].OnnTm); // gio vao double c2 = IsN(rsca[i].OffTm); // gio ra double MAX_HR1 = IsD(rsca[i].WrkHr); // gio cong if (c1 < c)// qua dem { QD = true; } if (c2 < c1) // qua dem { c2 = c2 + 2400; QD = true; } else { if (QD) { c2 = c2 + 2400; c1 = c1 + 2400; } } c = c2; if (rsca[i].TypId == "ATT_HR") { if (MAX_HR1 > 0 && MAX_HR1 < T_String.TruTG(c2, c1)) { ATT_MAX = T_String.CongTG(ATT_MAX, MAX_HR1); } else { ATT_MAX = T_String.CongTG(ATT_MAX, T_String.TruTG(c2, c1)); } } if (rsca[i].TypId == "NIG_HR") { if (MAX_HR1 > 0 && MAX_HR1 < T_String.TruTG(c2, c1)) { NIG_MAX = T_String.CongTG(NIG_MAX, MAX_HR1); } else { NIG_MAX = T_String.CongTG(NIG_MAX, T_String.TruTG(c2, c1)); } } } if (ATT.Count <= 0) { return; } ArrayList AT = new ArrayList(); int dem = 0; for (int i = 0; i < ATT.Count; i++) { if (IsN(ATT[i] + "") != 0) { double st = IsD(ATT[i] + ""); if (i >= NIG_TM - 1 && NIG_TM > 0 && QD == true) { st = st + 2400; } dem++; AT.Add(st); if (st > maxmax) { maxmax = st; } } } if (dem % 2 == 1) { if (ATT_DT != ToDayDT) { NOT_DR = "Abnormal;"; } return; } QD = false; c = 0; for (int i = 0; i < rsca.Count(); i++) { double c1 = IsN(rsca[i].OnnTm); // gio vao double c2 = IsN(rsca[i].OffTm); // gio ra double giothaisanIN = IsN(rsca[i].ManIn); double giothaisanOU = IsN(rsca[i].ManOu); int j = AT.Count - 1; if (c1 < c)// qua dem { QD = true; } if (c2 < c1) // qua dem { c2 = c2 + 2400; QD = true; } else { if (QD) { c2 = c2 + 2400; c1 = c1 + 2400; } } c = c2; while (j >= 0) { double t2 = IsN(AT[j] + ""); j--; double t1 = IsN(AT[j] + ""); j--; if (t2 < t1) { t2 = t2 + 2400; //NhuY } double a1, a2, a; if (t2 > c1) { if (t1 > c1) { //if(ONN_BT=="True" && T_String.TruTG(t1,c1)<= ONN_MN ) if (ONN_BT == "True" && T_String.TruTG(t1, c1) < ONN_MN && (rsca[i].TypId == "ATT_HR" || rsca[i].TypId == "NIG_HR")) { a1 = c1; } else { a1 = t1; } } else { a1 = c1; } if (t2 > c2) { a2 = c2; } else { //if(OFF_BT=="True" && T_String.TruTG(c2,t2)<= OFF_MN) if (OFF_BT == "True" && T_String.TruTG(c2, t2) < OFF_MN && (rsca[i].TypId == "ATT_HR" || rsca[i].TypId == "NIG_HR")) { a2 = c2; } else { a2 = t2; } } if (a2 > a1) { a = GetHourAndPhep(a1, a2, phep.Select(x => x.leave).ToList()); //T_String.TruTG(a2,a1); //a = 0; double MAX_HR = IsD(rsca[i].WrkHr); // gio cong double MIN_ST = IsD(rsca[i].MinSt); // MIN_ST if (MIN_ST == 0 || MIN_ST <= a) // lam tren bao nhieu phut moi tinh { if (MAX_HR < a && MAX_HR > 0) // thoi gian lam viec toi da { Add(rsca[i].TypId, MAX_HR); } else { Add(rsca[i].TypId, a); } } } } } } }