Beispiel #1
0
 private DateTime GetDateTime(string st, string time)
 {
     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));
         int      HH = T_String.IsNullTo0(PublicFunction.S_Left(time, 2));
         int      mm = T_String.IsNullTo0(PublicFunction.S_Right(time, 2));
         DateTime dt = new DateTime(y, MM, d, HH, mm, 0, 0);
         return(dt);
     }
     catch (Exception)
     {
         return(new DateTime(1, 1, 1));
     }
 }
Beispiel #2
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);
        }
Beispiel #3
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 + "";
                }
            }
        }
Beispiel #4
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;
            //            }
            //        }
            //    }
            //}
        }