Exemplo n.º 1
0
 /// <summary>
 /// Tạo id - khóa chính
 /// </summary>
 /// <param name="strFormat">Chuỗi định dạng</param>
 /// <param name="pTable">Bảng muốn tạo khóa chính</param>
 /// <returns>Khóa chính</returns>
 public string CreateId(string strFormat, string pTable)
 {
     string id;
     DataProvider dp = new DataProvider();
     DataTable dt = new DataTable();
     dt = GetAll(pTable);
     int rowCount = dt.Rows.Count + 1;
     string row;
     if (rowCount < 10)
     {
         row = "000" + rowCount.ToString();
     }
     else if (rowCount >= 10 && rowCount < 100)
     {
         row = "00" + rowCount.ToString();
     }
     else if (rowCount >= 100 && rowCount < 1000)
     {
         row = "0" + rowCount.ToString();
     }
     else
         row = rowCount.ToString();
     id = strFormat.ToString() + row.ToString();
     return id;
 }
Exemplo n.º 2
0
 public static IDbCommand GetCommand(DataProvider providerType)
 {
     switch (providerType)
     {
         case DataProvider.SqlServer:
             return new SqlCommand();
         case DataProvider.OleDb:
             return new OleDbCommand();
         case DataProvider.Odbc:
             return new OdbcCommand();
         default:
             return null;
     }
 }
Exemplo n.º 3
0
 public static IDbDataAdapter GetDataAdapter(DataProvider
     providerType)
 {
     switch (providerType)
     {
         case DataProvider.SqlServer:
             return new SqlDataAdapter();
         case DataProvider.OleDb:
             return new OleDbDataAdapter();
         case DataProvider.Odbc:
             return new OdbcDataAdapter();
         default:
             return null;
     }
 }
Exemplo n.º 4
0
 public static IDataParameter GetParameter(DataProvider
     providerType)
 {
     IDataParameter iDataParameter = null;
     switch (providerType)
     {
         case DataProvider.SqlServer:
             iDataParameter = new SqlParameter();
             break;
         case DataProvider.OleDb:
             iDataParameter = new OleDbParameter();
             break;
         case DataProvider.Odbc:
             iDataParameter = new OdbcParameter();
             break;
     }
     return iDataParameter;
 }
Exemplo n.º 5
0
        public string Login(string strMaNhanVien, string strPassword)
        {
            DataProvider dp = new DataProvider();
            string strQuery = "Select * From NHANVIEN Where TINHTRANG = 1 and MANHANVIEN = N'" + strMaNhanVien + "'";
            strQuery += " and MATKHAU = N'" + strPassword + "'";
            DataTable dt = dp.ExecuteQuery(strQuery);
            string strTenNhanVien = "";

            if (dt.Rows.Count == 0)
            {
                return "404";
            }
            else
            {
                strTenNhanVien = dt.Rows[0]["TENNHANVIEN"].ToString();
            }
            return strTenNhanVien;
        }
Exemplo n.º 6
0
 public static IDbConnection GetConnection(DataProvider
     providerType)
 {
     IDbConnection iDbConnection = null;
     switch (providerType)
     {
         case DataProvider.SqlServer:
             iDbConnection = new SqlConnection();
             break;
         case DataProvider.OleDb:
             iDbConnection = new OleDbConnection();
             break;
         case DataProvider.Odbc:
             iDbConnection = new OdbcConnection();
             break;
         default:
             return null;
     }
     return iDbConnection;
 }
Exemplo n.º 7
0
 public DBManager(DataProvider providerType, string
     connectionString)
 {
     this.providerType = providerType;
     this.strConnection = connectionString;
 }
Exemplo n.º 8
0
 public DBManager(DataProvider providerType)
 {
     this.providerType = providerType;
 }
Exemplo n.º 9
0
        public static IDbDataParameter[] GetParameters(DataProvider
            providerType,
            int paramsCount)
        {
            IDbDataParameter[] idbParams = new IDbDataParameter[paramsCount];

            switch (providerType)
            {
                case DataProvider.SqlServer:
                    for (int i = 0; i < paramsCount; ++i)
                    {
                        idbParams[i] = new SqlParameter();
                    }
                    break;
                case DataProvider.OleDb:
                    for (int i = 0; i < paramsCount; ++i)
                    {
                        idbParams[i] = new OleDbParameter();
                    }
                    break;
                case DataProvider.Odbc:
                    for (int i = 0; i < paramsCount; ++i)
                    {
                        idbParams[i] = new OdbcParameter();
                    }
                    break;
                default:
                    idbParams = null;
                    break;
            }
            return idbParams;
        }
Exemplo n.º 10
0
 public static IDbTransaction GetTransaction(DataProvider
     providerType)
 {
     IDbConnection iDbConnection = GetConnection(providerType);
     IDbTransaction iDbTransaction = iDbConnection.BeginTransaction();
     return iDbTransaction;
 }
Exemplo n.º 11
0
 public static DataTable LayTatCaDichVuDatPhong_DichVu_LoaiDV(ChiTietDatPhongDTO chiTietDatPhong)
 {
     return(DataProvider.ExecuseQuery("SELECT MaDichVuDatPhong,dichvudatphong.MaChiTietDatPhong, dichvudatphong.MaDichVu,SoLuong, Gia, TenDV,DonGia, DonVi, dichvu.MaLDV, TenLDV FROM quanlykaraoke.dichvudatphong,quanlykaraoke.dichvu,quanlykaraoke.loaidichvu  WHERE  quanlykaraoke.dichvudatphong.MaDichVu = quanlykaraoke.dichvu.MaDV AND quanlykaraoke.dichvu.MaLDV = quanlykaraoke.loaidichvu.MaLDV AND dichvudatphong.MaChiTietDatPhong = '" + chiTietDatPhong.MaChiTietDatPhong + "'; "));
 }
Exemplo n.º 12
0
        public static bool XoaDichVuDatPhong(int maDVP)
        {
            DataProvider.ExecuseNonQuery("DELETE FROM  quanlykaraoke.dichvudatphong  WHERE  quanlykaraoke.dichvudatphong.MaDichVuDatPhong = '" + maDVP + "';");

            return(true);
        }
Exemplo n.º 13
0
        public static bool UpdateDichVuDatPhong(DichVuDatPhongDTO dichVuDatPhongDTO)
        {
            DataProvider.ExecuseNonQuery("UPDATE  quanlykaraoke.dichvudatphong SET  quanlykaraoke.dichvudatphong.SoLuong = '" + dichVuDatPhongDTO.SoLuong + "',  quanlykaraoke.dichvudatphong.Gia ='" + dichVuDatPhongDTO.DonGia + "' WHERE  quanlykaraoke.dichvudatphong.MaDichVuDatPhong = '" + dichVuDatPhongDTO.MaDichVuDatPhong + "';");

            return(true);
        }
Exemplo n.º 14
0
 public static DataProvider GetInstance()
 {
     if (instance == null)
         instance = new DataProvider();
     return instance;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Sets the provider type and the connection string.
 /// </summary>
 ///
 /// <param name="ProviderType">
 /// The data provider type.
 /// </param>
 ///
 /// <param name="ConnectionString">
 /// The connection string to use for this object.
 /// </param>
 ///
 public DBManager(DataProvider ProviderType, string ConnectionString) : this(ProviderType)
 {
     this.ConnectionString = ConnectionString ?? throw new ArgumentNullException(nameof(ConnectionString));
 }
Exemplo n.º 16
0
 /// <summary>
 /// Sets the data provider type.
 /// </summary>
 ///
 /// <param name="ProviderType">
 /// The data provider type.
 /// </param>
 ///
 public DBManager(DataProvider ProviderType)
 {
     this.ProviderType = ProviderType;
 }