/// <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; }
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; } }
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; } }
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; }
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; }
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; }
public DBManager(DataProvider providerType, string connectionString) { this.providerType = providerType; this.strConnection = connectionString; }
public DBManager(DataProvider providerType) { this.providerType = providerType; }
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; }
public static IDbTransaction GetTransaction(DataProvider providerType) { IDbConnection iDbConnection = GetConnection(providerType); IDbTransaction iDbTransaction = iDbConnection.BeginTransaction(); return iDbTransaction; }
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 + "'; ")); }
public static bool XoaDichVuDatPhong(int maDVP) { DataProvider.ExecuseNonQuery("DELETE FROM quanlykaraoke.dichvudatphong WHERE quanlykaraoke.dichvudatphong.MaDichVuDatPhong = '" + maDVP + "';"); return(true); }
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); }
public static DataProvider GetInstance() { if (instance == null) instance = new DataProvider(); return instance; }
/// <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)); }
/// <summary> /// Sets the data provider type. /// </summary> /// /// <param name="ProviderType"> /// The data provider type. /// </param> /// public DBManager(DataProvider ProviderType) { this.ProviderType = ProviderType; }