コード例 #1
0
 public void Note(string st)
 {
     //			if(thaisan.rows<=0)
     //			{
     if (NOT_DR.IndexOf(st) < 0)
     {
         NOT_DR += st;
     }
     //			}
 }
コード例 #2
0
        private void EAR_TO_ABS()
        {
            //NhuY (2017/02/07): xét quy định số phút vắng
            if (ASB_MN > 0 && EAR_MN >= ASB_MN)
            {
                ABS_TM = 1;
                EAR_MN = EAR_TM = 0;

                if (NOT_DR.IndexOf("Absent") >= 0)
                {
                    NOT_DR = NOT_DR.Replace("Early;", "");
                }
                else
                {
                    NOT_DR = NOT_DR.Replace("Early", "Absent");
                }
            }
        }
コード例 #3
0
        public void GetNote()
        {
            double cc = IsN(rsca[0].OnnTm);

            if (T_String.IsNullTo00(ToDayDTTime.ToString("yyyyMMddHHmm"))
                < T_String.IsNullTo00(DateTime.Parse(ATT_DT).ToString("yyyyMMdd") + cc.ToString("0000")))
            {
                return;
            }
            double ONN_MN = IsD(SYS_SETTING_ATT.ONN_MN);
            double OFF_MN = IsD(SYS_SETTING_ATT.OFF_MN);

            ASB_MN = IsD(SYS_SETTING_ATT.ABS_MN);
            int index = -1;
            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();
            var phep_l = phep.Select(x => x.leave).ToList();

            if (phep.Count() > 0 && phep[0].leave.DayBt + "" == "True")
            {
                return;
            }

            LEA_OUT = T_String.CongTG(OTR_HR, LEA_OUT);
            LEA_OUT = T_String.CongTG(OTR_HR, LEA_H1);
            LEA_OUT = T_String.CongTG(OTR_HR, LEA_H2);
            LEA_OUT = T_String.CongTG(OTR_HR, LEA_H3);

            Double tt = T_String.CongTG(ATT_MAX, NIG_MAX);

            if (LEA_OUT >= tt && tt > 0)
            {
                return;
            }

            if (NOT_DR.IndexOf("Abnormal") >= 0)
            {
                return;
            }

            double m = 0, max = 0, min = 0, m1 = 0;//m1 so lan quet the , m= la thoi gian quet the truoc do

            double  c  = 0;
            Boolean QD = false;

            for (int j = 0; j < ATT.Count; j++)  // thoi gian quet the
            {
                double t1 = IsN(ATT[j] + "");

                if (j > 0 && t1 < IsN(ATT[j - 1]) && IsN(ATT[j]) > 0)
                {
                    t1 = t1 + 2400;
                }

                if (t1 != 0)
                {
                    if (t1 > max)
                    {
                        max = t1;
                    }

                    m  = t1;
                    m1 = j;
                    if (min == 0)
                    {
                        min = t1;
                    }
                }
                c  = 0;
                QD = false;
                for (int i = 0; i < rsca.Count(); i++)  // chay theo ca
                {
                    double c01 = -1;
                    if (i >= 1)
                    {
                        c01 = IsN(rsca[i - 1].OffTm);         // gio vao
                    }
                    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);
                    if (c1 < c)// qua dem
                    {
                        QD = true;
                    }
                    if (c2 < c1) // qua dem
                    {
                        c2 = c2 + 2400;
                        QD = true;
                    }
                    else
                    {
                        if (QD)
                        {
                            c2 = c2 + 2400;
                            //c1=c2+2400;
                            c1 = c1 + 2400; //NhuY
                        }
                    }
                    c = c2;
                    if (giothaisan > 0)
                    {
                        c1 = (giothaisanIN > 0 ? giothaisanIN : c1);
                        c2 = (giothaisanOU > 0 ? giothaisanOU : c2);
                    }

                    if (rsca[i].LatBt + "" == "True" && (rsca[i].TypId == "ATT_HR" || rsca[i].TypId == "NIG_HR"))
                    {
                        if (j % 2 == 0 && t1 <= c1)// Late
                        {
                            break;
                        }
                        if ((j % 2 == 0 && t1 < c2 && t1 > c1) || (min != 0 && t1 == min)) // Late  | (min!=0 && t1==min) | gio vao dau tien
                        {
                            if ((T_String.CongTG(c1, ASB_MN)) <= t1 && ASB_MN != 0)
                            {
                                if (phep.Count() > 0 /*|| OutTrip.rows > 0*/)
                                {
                                    if (phep.Count() > 0 && phep[i].leave.DayBt + "" == "True")
                                    {
                                        return;
                                    }
                                    else
                                    {
                                        //if (!CheckPhep(t1, phep, j) && !(CheckPhep(c1, phep, j) && (min != 0 && t1 == min)))
                                        if (!CheckPhep(t1, phep_l, j) && (min != 0 && t1 == min))
                                        {
                                            //if (!CheckPhep(t1, OutTrip, j) && !(CheckPhep(c1, OutTrip, j) && (min != 0 && t1 == min)))//Xét công tác: bỏ, vì ko sử dụng chức năng này
                                            {
                                                NOT_DR += "Absent" + ";";
                                                //GetPhep(phep);
                                                NOT_D1 += j.ToString("00");
                                                ABS_TM++;

                                                EAR_TO_ABS();
                                                return;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    NOT_DR += "Absent" + ";";
                                    //GetPhep(phep);
                                    NOT_D1 += j.ToString("00");
                                    ABS_TM++;

                                    EAR_TO_ABS();
                                    return;
                                }
                            }
                            if (T_String.CongTG(c1, ONN_MN) <= t1)
                            {
                                if (!CheckPhep(t1, phep_l, j) && !(CheckPhep(c1, phep_l, j) && (min != 0 && t1 == min)))
                                {
                                    //if (/*!CheckPhep(t1, OutTrip, j) &&*/ !(/*CheckPhep(c1, OutTrip, j) &&*/ (min != 0 && t1 == min)))
                                    //{
                                    Double LT = GetHourAndPhep(c1, t1, phep_l);
                                    if (t1 > c2)
                                    {
                                        LT = GetHourAndPhep(c1, c2, phep_l);
                                    }
                                    else
                                    {
                                        LT = GetHourAndPhep(c1, t1, phep_l);
                                    }
                                    Note("Late" + ";");
                                    NOT_D1 += j.ToString("00");
                                    LAT_MN  = T_String.CongTG(LT, LAT_MN);
                                    LAT_TM++;
                                    //}
                                }
                            }
                        }
                        if (j % 2 == 1 && t1 > c1 && t1 < c2) // early   cu Tan doi
                        {
                            if (T_String.CongTG(t1, OFF_MN) <= c2)
                            {
                                if (!CheckPhep(t1, phep_l, j))
                                {
                                    //if (!CheckPhep(t1, OutTrip, j))
                                    //{
                                    index = i;
                                    Double EA = GetHourAndPhep(t1, c2, phep_l);
                                    Note("Early" + ";");
                                    NOT_D1 += j.ToString("00");
                                    EAR_MN  = T_String.CongTG(EA, EAR_MN);
                                    EAR_TM++;

                                    EAR_TO_ABS();
                                    return;
                                    //}
                                }
                            }
                            break;
                        }
                    }
                }
            }

            if (m == 0) // neu ko quet the gi het
            {
                double t1;
                if (ATT.Count == 0)
                {
                    t1 = 0;
                }
                else
                {
                    t1 = IsN(ATT[0] + "");
                }

                //				//NhuY: Neu la ca cn hoac le thi ko xet absent
                //				if(phep.record(0,"DAY_BT")+""=="True" || T_String.GetDataFromSQL("COUNT(*)", "FILC02B",
                //					"SHI_ID=N'" + rsca.record(0, "SHI_ID") + "' AND (TYP_ID='ATT_HR' OR TYP_ID='NIG_HR')")=="0")
                //				{
                //					return;
                //				}
                //NhuY: Neu la ca cn hoac le thi ko xet absent
                if (phep_l[0].DayBt + "" == "True" || !IsWorkShift)
                {
                    return;
                }
                else // ko quet the
                {
                    if (phep.Count() <= 0 /*&& OutTrip.rows <= 0*/)
                    {
                        NOT_DR += "Absent" + ";";
                        //GetPhep(phep);
                        ABS_TM++;
                        return;
                    }
                    Boolean QD1 = 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);
                        if (c1 < c)// qua dem
                        {
                            QD1 = true;
                        }
                        if (c2 < c1) // qua dem
                        {
                            c2  = c2 + 2400;
                            QD1 = true;
                        }
                        else
                        {
                            if (QD1)
                            {
                                c2 = c2 + 2400;
                                c1 = c2 + 2400;
                            }
                        }
                        c = c2;
                        if (giothaisan > 0)
                        {
                            //							c1=T_String.CongTG(c1,giothaisanIN);
                            //							c2=T_String.TruTG(c2,giothaisanOU);
                            //NhuY 2017/03/28
                            c1 = (giothaisanIN > 0 ? giothaisanIN : c1);
                            c2 = (giothaisanOU > 0 ? giothaisanOU : c2);
                        }
                        if (rsca[i].LatBt + "" == "True" || (rsca[i].TypId == "ATT_HR" || rsca[i].TypId == "NIG_HR"))
                        {
                            if (phep.Count() > 0 /*|| OutTrip.rows > 0*/)
                            {
                                if (!CheckPhep(c1, phep_l, 0))
                                {
                                    //if (!CheckPhep(c1, OutTrip, 0))
                                    //{
                                    NOT_DR += "Absent" + ";";
                                    //GetPhep(phep);
                                    ABS_TM++;
                                    NOT_D1 = "00";

                                    EAR_TO_ABS();
                                    return;
                                    //}
                                }
                                if (!CheckPhep(c2, phep_l, 0))
                                {
                                    //if (!CheckPhep(c2, OutTrip, 0))
                                    //{
                                    NOT_DR += "Absent" + ";";
                                    //GetPhep(phep);
                                    ABS_TM++;
                                    NOT_D1 = "00";

                                    EAR_TO_ABS();
                                    return;
                                    //}
                                }
                            }
                        }
                    }
                }
            }
            else // co quet the kiem tra xem co phai chuyen du lieu ngay hien tai ko
            {
                if (ATT_DT != ToDayDT)
                {
                    QD = false;
                    for (int i = rsca.Count() - 1; i >= 0; i--)
                    {
                        if (rsca[i].LatBt + "" == "True" || (rsca[i].TypId == "ATT_HR" || rsca[i].TypId == "NIG_HR"))
                        {
                            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);
                            if (QD)
                            {
                                if (c1 > c2)
                                {
                                    c2 = c2 + 2400;
                                    QD = true;
                                }
                                else
                                {
                                    c2 = c2 + 2400;
                                    c1 = c1 + 2400;
                                }
                            }

                            if (giothaisan > 0)
                            {
                                //								c1=T_String.CongTG(c1,giothaisanIN);
                                //								c2=T_String.TruTG(c2,giothaisanOU);
                                //NhuY 2017/03/28
                                c1 = (giothaisanIN > 0 ? giothaisanIN : c1);
                                c2 = (giothaisanOU > 0 ? giothaisanOU : c2);
                            }

                            //
                            if (max > c1 + 2400 && max > c2 + 2400)
                            {
                                max -= 2400;
                            }

                            if (index + 1 <= i)
                            {
                                double max11 = 0;
                                if (max < c1)
                                {
                                    max11 = c1;
                                }
                                else
                                {
                                    max11 = max;
                                }

                                if (T_String.CongTG(max11, OFF_MN) <= c2) // max la gio quet the sau cung
                                {
                                    if (!CheckPhep(max11, phep_l, 0))
                                    {
                                        //if (!CheckPhep(max11, OutTrip, 0))
                                        //{
                                        Double v1 = 0, v2 = c2;
                                        if (max11 >= c1)
                                        {
                                            v1 = max11;
                                        }
                                        else
                                        {
                                            v1 = c1;
                                        }

                                        Double EA = GetHourAndPhep(v1, v2, phep_l);
                                        //											if(T_String.CongTG(EA,OFF_MN)<0)// thai san
                                        //											{
                                        Note("Early" + ";");
                                        //NOT_D1+=i.ToString("00");
                                        EAR_MN = T_String.CongTG(EA, EAR_MN);
                                        EAR_TM++;
                                        //	}
                                        //}
                                    }
                                }
                            }
                            else
                            {
                                if (index + 1 > i)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            EAR_TO_ABS();

            //			//NhuY (2017/02/07): xét quy định số phút vắng
            //			if (EAR_MN >= ABS_MN)
            //			{
            //				ABS_TM = 1;
            //				EAR_MN = EAR_TM = 0;
            //
            //				if (NOT_DR.IndexOf("Absent") >= 0)
            //					NOT_DR = NOT_DR.Replace("Early;", "");
            //				else
            //					NOT_DR = NOT_DR.Replace("Early", "Absent");
            //			}
        }