/// <summary> /// Count DataTable với ID_ShopsProducts table class. /// </summary> /// <param name="ID">ID</param> /// <returns></returns> public static int Count_With_ID_Product(int ID_Product) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand("st_tbShopsImages_CountByID_ShopsProducts", conn); sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.Add("@ID_Product", SqlDbType.Int).Value = ID_Product; try { conn.Open(); return((int)sqlComm.ExecuteScalar()); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doSQL dữ liệu. /// </summary> /// <returns></returns> public static bool doSQL(string sSQL) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand("st_processSQL", conn); sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.Add("@sSQL", SqlDbType.Bit).Value = sSQL; try { conn.Open(); sqlComm.ExecuteNonQuery(); return(true); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Get DataTable với tbShopsProductstable class. /// </summary> /// <param name="ID">ID</param> /// <returns></returns> public static DataTable getDataTableJoinShopsProducts() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand("st_tbShopsImages_SelectJointbShopsProducts", conn); sqlComm.CommandType = CommandType.StoredProcedure; SqlDataAdapter sqlDTA = new SqlDataAdapter(sqlComm); DataTable dt = new DataTable(); try { conn.Open(); sqlDTA.Fill(dt); return(dt); } catch (SqlException ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Get All DataTable với ID_Product table class. /// </summary> /// <param name="ID">ID</param> /// <returns></returns> public static DataTable getDataTable_With_ID_Product(int ID_Product) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand("st_tbShopsImages_SelectByID_Product_All", conn); sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.Add("@ID_Product", SqlDbType.Int).Value = ID_Product; try { conn.Open(); SqlDataAdapter sqlDTA = new SqlDataAdapter(sqlComm); DataTable dt = new DataTable(); sqlDTA.Fill(dt); return(dt); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Get TOP DataRows với table class. /// </summary> /// <returns></returns> public static DataTable getDataTable_ByTop(string top) { SqlConnection conn = new AccessDB().get_Conn(); string sSQL = "Select Top " + top + " * From tbShopsImages"; SqlCommand sqlComm = new SqlCommand(sSQL, conn); sqlComm.CommandType = CommandType.Text; try { SqlDataAdapter sqlDTA = new SqlDataAdapter(sqlComm); DataTable dt = new DataTable(); conn.Open(); sqlDTA.Fill(dt); return(dt); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Get max ID auto. /// </summary> /// <returns></returns> public static int getMaxIdAuto() { SqlConnection conn = new AccessDB().get_Conn(); string sSQL = "Select MAX(ID_ImageProduct) From tbShopsImages"; SqlCommand sqlComm = new SqlCommand(sSQL, conn); sqlComm.CommandType = CommandType.Text; try { conn.Open(); return((int)sqlComm.ExecuteScalar()); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Đếm tổng số bảng ghi. /// </summary> /// <returns></returns> public static int countRows(bool Hidden) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand("st_tbShopsImages_Count", conn); sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; try { conn.Open(); int intResult = (int)sqlComm.ExecuteScalar(); return(intResult); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doDelete dữ liệu. /// </summary> /// <returns></returns> public int doDelete() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbShopsImages_Delete, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { sqlComm.Parameters.Add("@ID_ImageProduct", SqlDbType.Int).Value = ID_ImageProduct_find; conn.Open(); sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doUpdate Key dữ liệu. /// </summary> /// <returns></returns> public int doUpdate_KEY(string Key_ID_ImageProduct_Old, string Key_ID_ImageProduct_New) { SqlConnection conn = new AccessDB().get_Conn(); string sql = "Update tbShopsImages Set ID_ImageProduct=@ID_ImageProduct_New Where ID_ImageProduct=@ID_ImageProduct_old"; SqlCommand sqlComm = new SqlCommand(sql, conn); sqlComm.CommandType = CommandType.Text; try { sqlComm.Parameters.Add("@ID_ImageProduct_New", SqlDbType.Int).Value = Key_ID_ImageProduct_New; sqlComm.Parameters.Add("@ID_ImageProduct_old", SqlDbType.Int).Value = Key_ID_ImageProduct_Old; conn.Open(); sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doUpdate dữ liệu. /// </summary> /// <returns></returns> public int doUpdate() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbShopsPayments_Update, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { conn.Open(); //ID_Payment sqlComm.Parameters.Add("@ID_Payment_find", SqlDbType.Int).Value = ID_Payment_find; //PaymentName if (PaymentName != null) { sqlComm.Parameters.Add("@PaymentName", SqlDbType.NVarChar).Value = PaymentName; } else { sqlComm.Parameters.Add("@PaymentName", SqlDbType.NVarChar).Value = DBNull.Value; } //Description if (Description != null) { sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = Description; } else { sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = DBNull.Value; } //EditTime if (EditTime.Year == 1) { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = EditTime; } //Hidden sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doInsert dữ liệu. /// </summary> /// <returns></returns> public int doInsert() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbSlider_Insert, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { //Title sqlComm.Parameters.Add("@Title", SqlDbType.NVarChar).Value = Title; //Image sqlComm.Parameters.Add("@Image", SqlDbType.NVarChar).Value = Image; //SummaryContent sqlComm.Parameters.Add("@SummaryContent", SqlDbType.NVarChar).Value = SummaryContent; //Description sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = Description; //AddTime if (AddTime.Year == 1) { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = AddTime; } //EditTime if (EditTime.Year == 1) { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = EditTime; } //Hidden sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; conn.Open(); sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doUpdate dữ liệu. /// </summary> /// <returns></returns> public int doUpdate() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbShopsOrders_Update, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { conn.Open(); //ID_Order sqlComm.Parameters.Add("@ID_Order_find", SqlDbType.Int).Value = ID_Order_find; //ID_Product sqlComm.Parameters.Add("@ID_Product", SqlDbType.Int).Value = ID_Product; //ID_OrderProduct sqlComm.Parameters.Add("@ID_OrderProduct", SqlDbType.Int).Value = ID_OrderProduct; //AddTime if (AddTime.Year == 1) { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = AddTime; } //EditTime if (EditTime.Year == 1) { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = EditTime; } //Hidden sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doInsert dữ liệu. /// </summary> /// <returns></returns> public int doInsert() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbLogs_Insert, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { //ID_User sqlComm.Parameters.Add("@ID_User", SqlDbType.Int).Value = ID_User; //Description sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = Description; //AddTime if (AddTime.Year == 1) { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = AddTime; } //Hidden sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; conn.Open(); sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Get DataTable Like Key với table class. /// </summary> /// <param name="ID">ID</param> /// <returns></returns> public static DataTable getDataTable_LikeKey(string Key) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbUsers_SelectAll_LikeKey, conn); sqlComm.CommandType = CommandType.StoredProcedure; sqlComm.Parameters.Add("@Key", SqlDbType.NVarChar).Value = Key; SqlDataAdapter sqlDTA = new SqlDataAdapter(sqlComm); DataTable dt = new DataTable(); try { conn.Open(); sqlDTA.Fill(dt); return(dt); } catch (SqlException ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Get DataTable My có parameter với table class. /// </summary> /// <param name="ID">ID</param> /// <returns></returns> public static DataTable getDataTable_My(int key_ID_User) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbUsers_SelectByID, conn); sqlComm.CommandType = CommandType.StoredProcedure; DataTable dt = new DataTable(); try { conn.Open(); sqlComm.Parameters.Add("@ID_User", SqlDbType.Int).Value = key_ID_User; SqlDataAdapter sqlDTA = new SqlDataAdapter(sqlComm); sqlDTA.Fill(dt); return(dt); } catch (SqlException ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Get DataTable ProcessSQL với table class. /// </summary> /// <param name="ID">ID</param> /// <returns></returns> public static DataTable getDataTable_SQL_pro(string sSQL) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand("st_processSQL", conn); sqlComm.CommandType = CommandType.StoredProcedure; DataTable dt = new DataTable(); try { sqlComm.Parameters.Add("@sSQL", SqlDbType.Bit).Value = sSQL; SqlDataAdapter sqlDTA = new SqlDataAdapter(sqlComm); conn.Open(); sqlDTA.Fill(dt); return(dt); } catch (SqlException ex) { throw ex; } finally { if (dt != null) { dt.Dispose(); } if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Xác định Khóa chính có tồn tại dữ liệu. /// </summary> /// <returns>Truy: Có; False: Không</returns> public static bool Exits_Key(int key_ID_User) { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand("st_tbUsers_Count_Key", conn); sqlComm.CommandType = CommandType.StoredProcedure; try { sqlComm.Parameters.Add("@ID_User", SqlDbType.Int).Value = key_ID_User; conn.Open(); if (((int)sqlComm.ExecuteScalar()) == 1) { return(true); } else { return(false); } } catch (SqlException ex) { throw ex; return(false); } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doInsert dữ liệu. /// </summary> /// <returns></returns> public int doInsert() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbUsers_Insert, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { //ID_Catalog sqlComm.Parameters.Add("@ID_Catalog", SqlDbType.Int).Value = ID_Catalog; //UserName sqlComm.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = UserName; //Password sqlComm.Parameters.Add("@Password", SqlDbType.VarChar).Value = Password; //FullName sqlComm.Parameters.Add("@FullName", SqlDbType.NVarChar).Value = FullName; //Image sqlComm.Parameters.Add("@Image", SqlDbType.NVarChar).Value = Image; //Gender sqlComm.Parameters.Add("@Gender", SqlDbType.NVarChar).Value = Gender; //Email sqlComm.Parameters.Add("@Email", SqlDbType.VarChar).Value = Email; //PhoneNumber sqlComm.Parameters.Add("@PhoneNumber", SqlDbType.VarChar).Value = PhoneNumber; //Description sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = Description; //TitleWeb sqlComm.Parameters.Add("@TitleWeb", SqlDbType.NVarChar).Value = TitleWeb; //LinkSEO sqlComm.Parameters.Add("@LinkSEO", SqlDbType.VarChar).Value = LinkSEO; //H1SEO sqlComm.Parameters.Add("@H1SEO", SqlDbType.NVarChar).Value = H1SEO; //KeywordSEO sqlComm.Parameters.Add("@KeywordSEO", SqlDbType.NText).Value = KeywordSEO; //AddTime if (AddTime.Year == 1) { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = AddTime; } //EditTime if (EditTime.Year == 1) { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = EditTime; } //Hidden sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; conn.Open(); sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doUpdate dữ liệu. /// </summary> /// <returns></returns> public int doUpdate() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbShopsCatalogs_Update, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { conn.Open(); //ID_Catalog sqlComm.Parameters.Add("@ID_Catalog_find", SqlDbType.Int).Value = ID_Catalog_find; //ID_Parent sqlComm.Parameters.Add("@ID_Parent", SqlDbType.Int).Value = ID_Parent; //CatalogName if (CatalogName != null) { sqlComm.Parameters.Add("@CatalogName", SqlDbType.NVarChar).Value = CatalogName; } else { sqlComm.Parameters.Add("@CatalogName", SqlDbType.NVarChar).Value = DBNull.Value; } //Image if (Image != null) { sqlComm.Parameters.Add("@Image", SqlDbType.NVarChar).Value = Image; } else { sqlComm.Parameters.Add("@Image", SqlDbType.NVarChar).Value = DBNull.Value; } //Description if (Description != null) { sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = Description; } else { sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = DBNull.Value; } //TitleWeb if (TitleWeb != null) { sqlComm.Parameters.Add("@TitleWeb", SqlDbType.NVarChar).Value = TitleWeb; } else { sqlComm.Parameters.Add("@TitleWeb", SqlDbType.NVarChar).Value = DBNull.Value; } //LinkSEO if (LinkSEO != null) { sqlComm.Parameters.Add("@LinkSEO", SqlDbType.VarChar).Value = LinkSEO; } else { sqlComm.Parameters.Add("@LinkSEO", SqlDbType.VarChar).Value = DBNull.Value; } //H1SEO if (H1SEO != null) { sqlComm.Parameters.Add("@H1SEO", SqlDbType.NVarChar).Value = H1SEO; } else { sqlComm.Parameters.Add("@H1SEO", SqlDbType.NVarChar).Value = DBNull.Value; } //KeywordSEO if (KeywordSEO != null) { sqlComm.Parameters.Add("@KeywordSEO", SqlDbType.NText).Value = KeywordSEO; } else { sqlComm.Parameters.Add("@KeywordSEO", SqlDbType.NText).Value = DBNull.Value; } //EditTime if (EditTime.Year == 1) { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = EditTime; } //Hidden sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
/// <summary> /// Thực hiện doInsert dữ liệu. /// </summary> /// <returns></returns> public int doInsert() { SqlConnection conn = new AccessDB().get_Conn(); SqlCommand sqlComm = new SqlCommand(st_tbShopsOrdersDetail_Insert, conn); sqlComm.CommandType = CommandType.StoredProcedure; try { //ID_Payment sqlComm.Parameters.Add("@ID_Payment", SqlDbType.Int).Value = ID_Payment; //ID_User sqlComm.Parameters.Add("@ID_User", SqlDbType.Int).Value = ID_User; //OrdersName sqlComm.Parameters.Add("@OrdersName", SqlDbType.NVarChar).Value = OrdersName; //UserName sqlComm.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = UserName; //UserEmail sqlComm.Parameters.Add("@UserEmail", SqlDbType.NVarChar).Value = UserEmail; //UserAddress sqlComm.Parameters.Add("@UserAddress", SqlDbType.NVarChar).Value = UserAddress; //UserPhone sqlComm.Parameters.Add("@UserPhone", SqlDbType.NVarChar).Value = UserPhone; //PriceTotal sqlComm.Parameters.Add("@PriceTotal", SqlDbType.Float).Value = PriceTotal; //Description sqlComm.Parameters.Add("@Description", SqlDbType.NText).Value = Description; //AddTime if (AddTime.Year == 1) { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@AddTime", SqlDbType.DateTime).Value = AddTime; } //EditTime if (EditTime.Year == 1) { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = DBNull.Value; } else { sqlComm.Parameters.Add("@EditTime", SqlDbType.DateTime).Value = EditTime; } //Hidden sqlComm.Parameters.Add("@Hidden", SqlDbType.Bit).Value = Hidden; conn.Open(); sqlComm.ExecuteNonQuery(); return(1); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }