Ejemplo n.º 1
0
        public static bool SelectVali(string strCon, string MSNV, string SoVe, int LanXe, int TramId)
        {
            if (CSDL.Ve_Test(strCon, SoVe))
            {
                return(true);
            }
            DataTable dataTable = new DataTable();

            string[] parameterNames = new string[]
            {
                "@MSNV"
            };
            string[] parameterValues = new string[]
            {
                MSNV
            };
            dataTable = CSDL.TruyXuatCSDLByProcedure(strCon, "SeValiData", parameterNames, parameterValues, 1);
            try
            {
                IEnumerator enumerator = null;
                try
                {
                    enumerator = dataTable.Rows.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        DataRow dataRow = (DataRow)enumerator.Current;
                        string  maVali  = Conversions.ToString(dataRow["MSVali"]);
                        string  right   = Conversions.ToString(dataRow["SoVeBD"]);
                        string  right2  = Conversions.ToString(dataRow["SoVeKT"]);
                        if (Operators.CompareString(SoVe, right, false) >= 0 & Operators.CompareString(SoVe, right2, false) <= 0 & (int)VeXe.CabinInMaVali(maVali) == LanXe)
                        {
                            string left   = Strings.Format(DateAndTime.Now, "yyMMdd");
                            string left2  = Strings.Format(DateAndTime.DateAdd(DateInterval.Day, -1.0, DateAndTime.Now), "yyMMdd");
                            string left3  = Strings.Format(DateAndTime.Now, "HH");
                            string right3 = "12";
                            switch (ModuleKhaiBaoConst.CaTrucMain)
                            {
                            case 1:
                            case 2:
                                if ((int)VeXe.CatrucInMaVali(maVali) == ModuleKhaiBaoConst.CaTrucMain & Operators.CompareString(left, VeXe.NgayInMaValiString(maVali), false) == 0)
                                {
                                    bool result = true;
                                    return(result);
                                }
                                break;

                            case 3:
                                if ((int)VeXe.CatrucInMaVali(maVali) == ModuleKhaiBaoConst.CaTrucMain & ((Operators.CompareString(left, VeXe.NgayInMaValiString(maVali), false) == 0 & Operators.CompareString(left3, right3, false) > 0) | (Operators.CompareString(left2, VeXe.NgayInMaValiString(maVali), false) == 0 & Operators.CompareString(left3, right3, false) < 0)))
                                {
                                    bool result = true;
                                    return(result);
                                }
                                break;
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
            catch (Exception expr_1F4)
            {
                ProjectData.SetProjectError(expr_1F4);
                Exception ex = expr_1F4;
                ModuleKhac.SaveError(ex.Message, "SelectVali");
                ProjectData.ClearProjectError();
            }
            return(false);
        }
Ejemplo n.º 2
0
        public static bool KiemTraVeLanCungChieu(string strCon, int LanXe, string SoVe)
        {
            string        cmdText       = "select MsVali,SoveBD,SoveKT from tbl_Vali_DataBackup where convert(int, substring(MsVali,9,2)) =  " + Conversions.ToString(LanXe);
            SqlConnection sqlConnection = new SqlConnection(strCon);
            DataTable     dataTable     = new DataTable();

            try
            {
                sqlConnection.Open();
                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(new SqlCommand(cmdText, sqlConnection)
                {
                    CommandType = CommandType.Text
                });
                sqlDataAdapter.Fill(dataTable);
                sqlConnection.Close();
                IEnumerator enumerator = null;
                try
                {
                    enumerator = dataTable.Rows.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        DataRow dataRow = (DataRow)enumerator.Current;
                        string  maVali  = Conversions.ToString(dataRow["MSVali"]);
                        string  right   = Conversions.ToString(dataRow["SoveBD"]);
                        string  right2  = Conversions.ToString(dataRow["SoveKT"]);
                        if (Operators.CompareString(SoVe, right, false) >= 0 & Operators.CompareString(SoVe, right2, false) <= 0)
                        {
                            string   text  = "";
                            string   text2 = "";
                            DateTime t     = VeXe.NgayInMaVali(maVali);
                            if (CSDL.SelectThoiGianCatruc(ModuleKhaiBaoConst.StrConnectMain, Conversions.ToString(VeXe.CatrucInMaVali(maVali)), ref text, ref text2))
                            {
                                t = t.AddHours(Conversions.ToDouble(text2.Substring(0, 2))).AddMinutes(Conversions.ToDouble(text2.Substring(3, 2))).AddHours(24.0);
                                if (DateTime.Compare(DateAndTime.Now, t) <= 0)
                                {
                                    return(true);
                                }
                            }
                        }
                    }
                }
                finally
                {
                    if (enumerator is IDisposable)
                    {
                        (enumerator as IDisposable).Dispose();
                    }
                }
            }
            catch (Exception expr_18A)
            {
                ProjectData.SetProjectError(expr_18A);
                Exception ex = expr_18A;
                ModuleKhac.SaveError(ex.Message, "KiemTraVeLanCungChieu");
                ProjectData.ClearProjectError();
            }
            return(false);
        }