private void btnSua_Click(object sender, EventArgs e) { ComboBLL comboBLL = new ComboBLL(); Combo combo = new Combo(); combo.comboName = txtComboName.Text; combo.dayStart = dayStart.Value; combo.dayEnd = dayEnd.Value; combo.discountMoney = numDiscount.Value.ToString(); combo.total = int.Parse(txtTotal.Text.Replace(",", "")); /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/ combo.image = path; try { if (flagimage && !File.Exists(DBConnection.folder_combo + path)) { File.Copy(fullpath, DBConnection.folder_combo + path); } flagimage = false; comboBLL.EditCombo(combo, id); comboBLL.EditComboProduct(list, id); MessageBox.Show("Sửa combo thành công", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Lỗi khi sửa Combo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } LoadListView(); }
private void btnXoa_Click(object sender, EventArgs e) { ComboBLL comboBLL = new ComboBLL(); string pathTemp = comboBLL.pathImage(id); try { comboBLL.DeleteCombo(id); MessageBox.Show("Xóa combo thành công", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception) { MessageBox.Show("Lỗi khi xóa Combo", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtComboName.Clear(); txtTotal.Clear(); numDiscount.Value = 0; dayStart.Value = DateTime.Now; dayEnd.Value = DateTime.Now; lblNameImage.Text = "Chưa có ảnh"; previewImage.Image = null; btnSua.Enabled = false; btnXoa.Enabled = false; LoadListView(); }
private void LoadPreviewImage(int id) { ComboBLL comboBLL = new ComboBLL(); path = comboBLL.pathImage(id); previewImage.Image = Image.FromFile(DBConnection.folder_combo + path); previewImage.SizeMode = PictureBoxSizeMode.StretchImage; lblNameImage.Text = path; }
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); } }
private void btnXoa_Click_1(object sender, EventArgs e) { ComboBLL comboBLL = new ComboBLL(); string pathTemp = comboBLL.pathImage(id); comboBLL.DeleteCombo(id); txtComboName.Clear(); txtTotal.Clear(); numDiscount.Value = 0; dayStart.Value = DateTime.Now; dayEnd.Value = DateTime.Now; lblNameImage.Text = "Chưa có ảnh"; previewImage.Image = null; btnSua.Enabled = false; btnXoa.Enabled = false; LoadListView(); }
private void btnSua_Click(object sender, EventArgs e) { ComboBLL comboBLL = new ComboBLL(); Combo combo = new Combo(); combo.comboName = txtComboName.Text; combo.dayStart = dayStart.Value; combo.dayEnd = dayEnd.Value; combo.discountMoney = numDiscount.Value.ToString(); combo.total = int.Parse(txtTotal.Text.Replace(",", "")); /*Lấy Tên Ảnh đưa vào cơ sở dữ liệu*/ combo.image = path; comboBLL.EditCombo(combo, id); comboBLL.EditComboProduct(list, id); LoadListView(); }
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); } }
private void listView_Click(object sender, EventArgs e) { flag = true; flagimage = true; ComboBLL comboBLL = new ComboBLL(); txtComboName.Text = listViewCombo.SelectedItems[0].SubItems[1].Text; dayStart.Value = DateTime.Parse(listViewCombo.SelectedItems[0].SubItems[2].Text); dayEnd.Value = DateTime.Parse(listViewCombo.SelectedItems[0].SubItems[3].Text); numDiscount.Text = listViewCombo.SelectedItems[0].SubItems[5].Text; txtTotal.Text = listViewCombo.SelectedItems[0].SubItems[4].Text; total = int.Parse(txtTotal.Text.Replace(",", "")); int idcombo = int.Parse(listViewCombo.SelectedItems[0].ImageKey); LoadPreviewImage(idcombo); id = idcombo; btnThem.Enabled = true; btnXoa.Enabled = true; btnSua.Enabled = true; list = comboBLL.ListIDProduct(id); }
private void LoadListViewCombo() { ComboBLL comboBLL = new ComboBLL(); DataTable dataTable; if (clickSearch) { dataTable = comboBLL.Search(dateStart.Value, dateEnd.Value, txtSeachCombo.Text); } else { dataTable = comboBLL.GetAllCombo(); } LoadImage(dataTable, folder_combo, 120, 70); listViewData.Clear(); listViewData.View = View.Details; listViewData.FullRowSelect = true; listViewData.SmallImageList = imageList; listViewData.Columns.Add("Hình ảnh", 120); listViewData.Columns.Add("Tên Combo", 80); listViewData.Columns.Add("Ngày bắt đầu", 140); listViewData.Columns.Add("Ngày kết thúc", 140); listViewData.Columns.Add("Total", 70); listViewData.Columns.Add("Giảm giá"); ListViewItem lvitem; foreach (DataRow row in dataTable.Rows) { lvitem = new ListViewItem(); lvitem.ImageKey = row.Field <int>("Id").ToString(); lvitem.SubItems.Add(row.Field <string>("ComboName")); lvitem.SubItems.Add(row.Field <DateTime>("DayStart").ToString()); lvitem.SubItems.Add(row.Field <DateTime>("DayEnd").ToString()); lvitem.SubItems.Add(row.Field <int>("Total").ToString("0,0")); lvitem.SubItems.Add(int.Parse(row.Field <string>("DiscountMoney")).ToString("0,0")); listViewData.Items.Add(lvitem); } }
public void LoadListView() { ComboBLL comboBLL = new ComboBLL(); DataTable dataTable; if (clickSearch) { dataTable = comboBLL.Search(dateSearchStart.Value, dateSearchEnd.Value, txtSearch.Text); } else { dataTable = comboBLL.GetAllCombo(); } LoadImage(dataTable); listViewCombo.Clear(); listViewCombo.View = View.Details; listViewCombo.FullRowSelect = true; listViewCombo.SmallImageList = imageList; listViewCombo.Columns.Add("Image", 120); listViewCombo.Columns.Add("Combo Name", 80); listViewCombo.Columns.Add("Date begin", 140); listViewCombo.Columns.Add("Date end", 140); listViewCombo.Columns.Add("Total", 70); listViewCombo.Columns.Add("Discount"); ListViewItem lvitem; foreach (DataRow row in dataTable.Rows) { lvitem = new ListViewItem(); lvitem.ImageKey = row.Field <int>("Id").ToString(); lvitem.SubItems.Add(row.Field <string>("ComboName")); lvitem.SubItems.Add(row.Field <DateTime>("DayStart").ToString()); lvitem.SubItems.Add(row.Field <DateTime>("DayEnd").ToString()); lvitem.SubItems.Add(row.Field <int>("Total").ToString("0,0")); lvitem.SubItems.Add(int.Parse(row.Field <string>("DiscountMoney")).ToString("0,0")); listViewCombo.Items.Add(lvitem); } }
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); } }
private void btnAdd_Click(object sender, EventArgs e) { LapDonHangBLL donHangBLL = new LapDonHangBLL(); if (newCus) { donHangBLL.AddKhach(firstname, lastname, phone, address); } int totalqty = 0; foreach (ObjCombo item in arr_combo) { totalqty += item.Quantity; ComboBLL comboBLL = new ComboBLL(); ArrayList listid = comboBLL.ListIDProduct(item.Combo.Id); foreach (int a in listid) { ProductBLL productBLL = new ProductBLL(); productBLL.EditProduct(item.Quantity, a); } } foreach (ObjProduct item in arr_product) { totalqty += item.Quantity; ProductBLL productBLL = new ProductBLL(); productBLL.EditProduct(item.Quantity, item.Product.id); } Invoice invoice = new Invoice(); if (newCus) { invoice.customer_id = donHangBLL.getIdCustommer(); } else { invoice.customer_id = idcus; } invoice.customeraddress = address; invoice.totalmoney = txtThanhtien.Text.Replace(",", ""); invoice.amount = totalqty.ToString(); invoice.creatday = DateTime.Now; invoice.ordernote = "123"; invoice.postcode = "123"; invoice.status = "Done"; donHangBLL.AddInvoice(invoice); string products = ""; if (arr_product.Count != 0) { products = JsonConvert.SerializeObject(arr_product); } string combos = ""; if (arr_combo.Count != 0) { combos = JsonConvert.SerializeObject(arr_combo); } donHangBLL.AddInvoiceDetail(products, combos); LoadListViewSelect(); arr_combo = new ArrayList(); arr_product = new ArrayList(); MessageBox.Show("Đã thêm đơn hàng thành công"); }
private void btnDeleteCombo_Click(object sender, EventArgs e) { ComboBLL.DeleteCombo(tbIDCombo.Text); tblCombo.DataSource = pro.GetAll(); }