예제 #1
0
        public static double CongTG(double t1, double t2)
        {
            int g1 = Math.Abs(IsNullTo0(PublicFunction.S_Left(t1 + "", ((string)(t1 + "")).Length - 2)));
            int g2 = Math.Abs(IsNullTo0(PublicFunction.S_Left(t2 + "", ((string)(t2 + "")).Length - 2)));
            int f1 = Math.Abs(IsNullTo0(PublicFunction.S_Right("00" + t1 + "", 2)));
            int f2 = Math.Abs(IsNullTo0(PublicFunction.S_Right("00" + t2 + "", 2)));

            TimeSpan tm1 = new TimeSpan(g1, f1, 0);
            TimeSpan tm2 = new TimeSpan(g2, f2, 0);

            if (t1 < 0)
            {
                tm1 = tm1.Negate();
            }
            if (t2 < 0)
            {
                tm2 = tm2.Negate();
            }
            tm1 = tm1.Add(tm2);

            string st = (((Math.Abs(tm1.Days) * 24) + Math.Abs(tm1.Hours)).ToString("00")) + "" + Math.Abs(tm1.Minutes).ToString("00");

            if (tm1.TotalMilliseconds < 0)
            {
                return(IsNullTo00("-" + st));
            }
            return(IsNullTo00(st));
        }
        private string FunSqlINH(string EMP_ID, string INH_DT, string sql, string YYY_MM, SqlConnection con)
        {
            if (sql.IndexOf("[DayOfMonth_INH()]") > 0)
            {
                sql = sql.Replace("[DayOfMonth_INH()]", DayOfMonth(INH_DT) + "");
            }
            if (sql.IndexOf("[SundayOfMonth_INH()]") > 0)
            {
                sql = sql.Replace("[SundayOfMonth_INH()]", SundayOfMonth(INH_DT) + "");
            }
            if (sql.IndexOf("[HolidayOfMonth_INH()]") > 0)
            {
                sql = sql.Replace("[HolidayOfMonth_INH()]", HolidayOfMonth(INH_DT, con) + "");
            }
            if (sql.IndexOf("AnnLeaveToSalary") > 0)
            {
                sql = sql.Replace("[AnnLeaveToSalary()]", AnnLeaveToSalary(EMP_ID, YYY_MM) + "");
            }
            if (sql.IndexOf("[VacateDaysNoSUN()]") > 0)
            {
                DateTime dt = new DateTime(T_String.IsNullTo0(PublicFunction.S_Left(YYY_MM, 4)),
                                           T_String.IsNullTo0(PublicFunction.S_Right(YYY_MM, 2)), 1);

                sql = sql.Replace("[VacateDaysNoSUN()]", VacateDaysNoSUN(EMP_ID, con, dt) + "");
            }

            return(sql);
        }
예제 #3
0
        public static void Attendance_Calc(string EMP_ID, string ATT_DT, SqlConnection con, string table)
        {
            QLNhaHangContext _db = new QLNhaHangContext();
            var _dt = DateTime.Parse(ATT_DT);
            var rs  = _db.Tbldetailsattendance.Where(x => x.EmpId == EMP_ID && x.AttDt == _dt).FirstOrDefault();

            if (rs == null || rs.LocB1 == true)
            {
                return;
            }
            var rsca        = _db.Tbldetailsroster.Where(x => x.ShiId == rs.ShiId).OrderBy(x => x.SeqNo).ToList();
            var rsTypeShift = _db.Tbltypeshift.ToList();

            ArrayList Ca  = new ArrayList();
            ArrayList ATT = new ArrayList();

            for (int j = 0; j < rsca.Count(); j++)
            {
                Ca.Add(rsca[j].OnnTm);
                Ca.Add(rsca[j].OffTm);
            }

            Ca.Add(0);
            Ca.Add(0);
            Ca.Add(0);
            Ca.Add(0);
            for (int j = 1; j <= 5; j++)
            {
                ATT.Add(T_String.IsNullTo00(T_String.GetPropValue(rs, "Onn" + j.ToString("00")) + ""));
                ATT.Add(T_String.IsNullTo00(T_String.GetPropValue(rs, "Off" + j.ToString("00")) + ""));
            }

            string NOT_DR = rs.NotDr + "";
            int    pos    = NOT_DR.IndexOf("Sign");

            if (pos >= 0)
            {
                int pos1 = PublicFunction.S_Left(NOT_DR, pos + 4).LastIndexOf(";");

                if (pos1 > 0)
                {
                    NOT_DR = NOT_DR.Substring(pos1 + 1, pos - pos1 + 3);
                }
                else
                {
                    NOT_DR = NOT_DR.Substring(0, pos + 4);
                }
            }
            else
            {
                NOT_DR = "";
            }

            Attendance_Calc(EMP_ID, ATT_DT, con, Ca, ATT, rs.ShiId + "", rsca, null, rsTypeShift, table, NOT_DR);
        }
예제 #4
0
 private DateTime GetDate(string st)
 {
     try
     {
         string st1 = st;
         int    y   = T_String.IsNullTo0(PublicFunction.S_Left(st1, 4));
         st1 = PublicFunction.S_Right(st1, st1.Length - 4);
         int MM = T_String.IsNullTo0(PublicFunction.S_Left(st1, 2));
         st1 = PublicFunction.S_Right(st1, st1.Length - 2);
         int      d  = T_String.IsNullTo0(PublicFunction.S_Left(st1, 2));
         DateTime dt = new DateTime(y, MM, d);
         return(dt);
     }
     catch (Exception)
     {
         return(new DateTime(1, 1, 1));
     }
 }
예제 #5
0
        public double Round(double data, int SEQ, int ROU)
        {
            double gio  = IsD(PublicFunction.S_Left(PublicFunction.S_Right("00" + data + "", 4), 2));
            double phut = IsD(PublicFunction.S_Right("00" + data + "", 2));

            if (phut == 0)
            {
                return(data);
            }
            int tm1 = 0, tm = 0;

            for (int i = 1; i <= SEQ; i++)
            {
                tm  = (int)((60 / SEQ) * i);
                tm1 = (int)tm - ROU;
                if (phut <= tm && phut >= tm1)
                {
                    if (tm == 60)
                    {
                        tm = 0;
                        gio++;
                    }
                    return(IsD(gio + "" + tm.ToString("00")));
                }
                tm = (int)((60 / SEQ) * (i - 1));
                if (phut < tm1 && phut > tm)
                {
                    if (tm == 60)
                    {
                        tm = 0;
                        gio++;
                    }
                    return(IsD(gio + "" + tm.ToString("00")));
                }
            }
            return(data);
        }
예제 #6
0
        public void AddRawDataToDB(string st1, string filename, SqlConnection con, string SEQ_NO)
        {
            string st     = st1;
            string REA_NO = PublicFunction.S_Left(st, 3);

            st = PublicFunction.S_Right(st, st.Length - 3);
            string CRD_NO = PublicFunction.S_Left(st, 10);

            st = PublicFunction.S_Right(st, st.Length - 10);
            string CRD_DT = PublicFunction.S_Left(st, 8);

            st = PublicFunction.S_Right(st, st.Length - 8);
            string CRD_TM = PublicFunction.S_Left(st, 4);
            Double TM     = T_String.IsNullTo00(PublicFunction.S_Left(st, 4));

            DateTime dt1 = GetDateTime(CRD_DT, CRD_TM).AddMinutes(-CRD_MN);
            DateTime dt2 = GetDateTime(CRD_DT, CRD_TM).AddMinutes(CRD_MN);


            string sql = "", EMP_ID;

            //Kiem tra neu ma co roi thi ko them nua
            sql = "Select EMP_ID from TBLCARDDATA where DAT_TM=N'" + CRD_DT + CRD_TM + "' and CRD_NO=N'" + CRD_NO + "'";
            RecordSet rs = new RecordSet(sql, PublicFunction.C_con);

            if (rs.rows <= 0)
            {
                //					sql="Delete from FILC01A where DAT_TM=N'"+CRD_DT+CRD_TM+"' and CRD_NO=N'"+CRD_NO+"'";
                //					PublicFunction.SQL_Execute(sql,con);
                if (TM == 0000)
                {
                    CRD_TM = "2400";
                    TM     = 2400;
                    CRD_DT = GetDate(CRD_DT).AddDays(-1).ToString("yyyyMMdd");
                }
                sql = "(DAT_TM>" + dt1.ToString("yyyyMMddHHmm") + " and DAT_TM<" + dt2.ToString("yyyyMMddHHmm")
                      + ") and CRD_NO=N'" + CRD_NO + "'";
                if (T_String.IsNullTo0(T_String.GetDataFromSQL("COUNT(DAT_TM)", "TBLCARDDATA", sql, con)) <= 0)// thoi cho phep duoc lap lai the
                {
                    int index = this.CRD_NO.IndexOf(CRD_NO);
                    if (index >= 0)
                    {
                        EMP_ID = this.EMP_ID[index] + "";
                    }
                    else
                    {
                        EMP_ID = "";
                    }
                    sql  = "Insert into TBLCARDDATA(DAT_TM,EMP_ID,SWI_DT,USR_NM,CRD_DT,CRD_TM,CRD_NO,REA_NO,FIL_NM) values(";
                    sql += "N'" + CRD_DT + CRD_TM + "',N'" + EMP_ID + "','" + dt + "',N'" + "{UserID}" + "',";
                    sql += "'" + CRD_DT + "'," + TM + ",";
                    sql += "N'" + CRD_NO + "',N'" + REA_NO + "',";
                    sql += "N'" + filename + "')";

                    try
                    {
                        PublicFunction.SQL_Execute(sql, con);
                    }
                    catch (SqlException ex)
                    {
                        if (ex.Number != 2627)
                        {
                            //MessageBox.Show(ex.Message + "");
                            err += ex.Message + "";
                        }
                    }
                }
                //PublicFunction.SQL_Execute(sql,con);
                if (SEQ_NO == "0")
                {
                    //lb2.Items.Add(CRD_NO + "  " + CRD_DT + "  " + CRD_TM);
                    d1++;
                    //c1.Text = d1 + "";
                }
                else
                {
                    //lb4.Items.Add(CRD_NO + "  " + CRD_DT + "  " + CRD_TM);
                    d2++;
                    //c2.Text = d2 + "";
                }
            }
        }
예제 #7
0
        public void Round()
        {
            //NhuY (2011/10/25): Neu thiet lap "ko lam tron gio lam" -> chi ko lam tron gio lam, con tang ca thi lam tron
            for (int i = 0; i < Data.Count; i++)
            {
                if (SYS_SETTING_ATT.ROU_NO != "True" || Name[i] + "" != "ATT_HR" && Name[i] + "" != "NIG_HR")
                {
                    int SEQ = IsN(PublicFunction.S_Left(rsTypeShift[i].RouDr, 2));
                    int ROU = IsN(PublicFunction.S_Right(rsTypeShift[i].RouDr, 2));
                    if (SEQ != 0)
                    {
                        Data[i] = Round(IsD(Data[i] + ""), SEQ, ROU);
                    }
                }
            }
            //
            //if (thaisan.rows > 0)// thai san
            //{
            //    int index = Name.IndexOf("ATT_HR");
            //    Double hr = T_String.IsNullTo00(Data[index] + "");
            //    Double hr1 = T_String.IsNullTo00(thaisan.record(0, "WRK_OT") + "");
            //    Double gp = 0;

            //    gp = T_String.CongTG(gp, OTR_HR);
            //    if (hr > 0)
            //    {
            //        if (CON_MAN == 0 || T_String.CongTG(hr, gp) >= CON_MAN)
            //        {
            //            hr = hr + 100;
            //            hr1 = T_String.IsNullTo00(thaisan.record(0, "WRK_OT") + "");
            //            hr1 = T_String.TruTG(hr1, gp);
            //            if (hr > hr1 && hr1 > 0)
            //            {
            //                Data[index] = hr1;
            //                hr = hr - hr1;
            //                index = Name.IndexOf("OTT_HR");
            //                Data[index] = T_String.IsNullTo00(Data[index] + "") + hr;
            //            }
            //            else
            //            {
            //                Data[index] = hr;
            //            }
            //        }
            //        else
            //            giothaisan = 0;
            //    }
            //    else
            //    {
            //        index = Name.IndexOf("NIG_HR");
            //        hr = T_String.IsNullTo00(Data[index] + "");
            //        if (CON_MAN == 0 || T_String.CongTG(hr, gp) >= CON_MAN)
            //        {
            //            if (hr > 0)
            //            {
            //                hr = hr + 100;
            //                hr1 = T_String.IsNullTo00(thaisan.record(0, "WRK_OT") + "");
            //                hr1 = T_String.TruTG(hr1, gp);
            //                if (hr > hr1 && hr1 > 0)
            //                {
            //                    Data[index] = hr1;
            //                    hr = hr - hr1;
            //                    //index=Name.IndexOf("NIG_OT");
            //                    index = Name.IndexOf("OVO_HR");
            //                    Data[index] = T_String.IsNullTo00(Data[index] + "") + hr;
            //                }
            //                else
            //                {
            //                    Data[index] = hr;
            //                }
            //            }
            //        }
            //        else
            //            giothaisan = 0;
            //    }

            //    if (thaisan.record(0, "OTT_BT") + "" != "True")
            //    {
            //        for (int i = 0; i < Data.Count; i++)
            //        {
            //            if (Name[i] + "" != "ATT_HR" && Name[i] + "" != "NIG_HR")
            //                Data[i] = 0;
            //            else
            //            {
            //                if (Name[i] + "" == "ATT_HR")
            //                {
            //                    if (IsD(Data[i]) > ATT_MAX)
            //                        Data[i] = ATT_MAX;
            //                }
            //                else
            //                    if (IsD(Data[i]) > NIG_MAX)
            //                    Data[i] = NIG_MAX;
            //            }
            //        }
            //    }
            //}
        }