public async Task <ActionResult> DeleteConfirmed(int id) { ComboProduct comboProduct = await db.ComboProducts.FindAsync(id); db.ComboProducts.Remove(comboProduct); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,ComboCode,ComboName,ValidStartDate,ValidEndDate,Price,ProductPrice,ProductCommision,ProductSettlement,ProductContractPrice")] ComboProduct comboProduct) { if (ModelState.IsValid) { db.Entry(comboProduct).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(comboProduct)); }
private void btnThem_Click_1(object sender, EventArgs e) { ComboBLL comboBLL = new ComboBLL(); Combo combo = new Combo(); try { if (flagimage) { fullpath = DBConnection.folder_combo + path; } int i = 1; while (File.Exists(DBConnection.folder_combo + path)) { if (path.Contains("(") && path.Contains(")")) { string[] f = path.Split('('); string[] n = f[1].Split(')'); int num = int.Parse(n[0]); path = path.Replace("(" + num + ")", "(" + ++num + ")"); } else { string[] t = path.Split('.'); path = t[0] + "(" + i + ")." + t[1]; } } File.Copy(fullpath, DBConnection.folder_combo + path); flagimage = false; combo.comboName = txtComboName.Text; combo.dayStart = dayStart.Value; combo.dayEnd = dayEnd.Value; combo.discountMoney = numDiscount.Value.ToString(); combo.total = total; /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/ combo.image = path; comboBLL.AddCombo(combo); ComboProduct comboProduct = new ComboProduct(); foreach (int listidprouct in list) { comboProduct.product_id = int.Parse(listidprouct.ToString()); comboBLL.AddComboProduct(comboProduct); } LoadListView(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// GET: ComboProducts/Delete/5 public async Task <ActionResult> Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ComboProduct comboProduct = await db.ComboProducts.FindAsync(id); if (comboProduct == null) { return(HttpNotFound()); } return(View(comboProduct)); }
private void btnThem_Click(object sender, EventArgs e) { ComboBLL comboBLL = new ComboBLL(); Combo combo = new Combo(); try { if (flagimage) { fullpath = DBConnection.folder_combo + path; } int i = 1; while (File.Exists(DBConnection.folder_combo + path)) { string[] temp = path.Split('.'); path = temp[0] + "-" + i + "." + temp[1]; i++; } File.Copy(fullpath, DBConnection.folder_combo + path); flagimage = false; combo.comboName = txtComboName.Text; combo.dayStart = dayStart.Value; combo.dayEnd = dayEnd.Value; combo.discountMoney = numDiscount.Value.ToString(); combo.total = total; /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/ combo.image = path; comboBLL.AddCombo(combo); ComboProduct comboProduct = new ComboProduct(); foreach (int listidprouct in list) { comboProduct.product_id = int.Parse(listidprouct.ToString()); comboBLL.AddComboProduct(comboProduct); } LoadListView(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void AddComboProduct(ComboProduct comboProduct) { using (SqlConnection conn = DBConnection.GetConnection()) { conn.Open(); string sql = "select MAX(Id) from Combo"; SqlCommand command = new SqlCommand(sql, conn); SqlDataAdapter dataAdapter = new SqlDataAdapter(command); DataTable dt = new DataTable(); dataAdapter.Fill(dt); int combo_id = int.Parse(dt.Rows[0][0].ToString()); int product_id = comboProduct.product_id; sql = @"INSERT INTO ComboProduct VALUES(" + combo_id + ", " + product_id + ")"; SqlCommand com = new SqlCommand(sql, conn); com.ExecuteNonQuery(); conn.Close(); } }
private void btnThem_Click(object sender, EventArgs e) { ComboBLL comboBLL = new ComboBLL(); Combo combo = new Combo(); try { if (flagimage && !File.Exists(DBConnection.folder_combo + path)) { File.Copy(fullpath, DBConnection.folder_combo + path); } flagimage = false; combo.comboName = txtComboName.Text; combo.dayStart = dayStart.Value; combo.dayEnd = dayEnd.Value; combo.discountMoney = numDiscount.Value.ToString(); combo.total = total; /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/ combo.image = path; comboBLL.AddCombo(combo); ComboProduct comboProduct = new ComboProduct(); foreach (int listidprouct in list) { comboProduct.product_id = int.Parse(listidprouct.ToString()); comboBLL.AddComboProduct(comboProduct); } MessageBox.Show("Thêm Combo thành công", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadListView(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AddComboProduct(ComboProduct comboProduct) { DAL.ComboDAL.AddComboProduct(comboProduct); }