private void LoadNguyenLieu() { dsnguyenlieu = NguyenLieu_BUS.LoadNguyenLieu(); if (dsnguyenlieu != null) { foreach (NguyenLieu_DTO nl in dsnguyenlieu) { ID.Add(nl.MaNL); } } dtgrvDanhSachNL.DataSource = dsnguyenlieu; if (dsnguyenlieu == null) { return; } dtgrvDanhSachNL.Columns["MaNL"].HeaderText = "Mã Nguyên Liệu"; dtgrvDanhSachNL.Columns["TenNL"].HeaderText = "Tên Nguyên Liệu"; dtgrvDanhSachNL.Columns["Donvi"].HeaderText = "Đơn Vị"; dtgrvDanhSachNL.Columns["Soluong"].HeaderText = "Số Lượng"; for (int i = 0; i < 3; i++) { dtgrvDanhSachNL.AutoResizeColumn(i); } }
private void gABXoa_Click(object sender, EventArgs e) { if (drvNL == null) { MessageBox.Show("Chọn món ăn muốn xóa"); return; } NguyenLieu_DTO nguyenLieu = new NguyenLieu_DTO(); nguyenLieu.TenNL = txtTenNL.Text; nguyenLieu.Donvi = txtDonVi.Text; nguyenLieu.Soluong = int.Parse(txtSoLuong.Text); if (MessageBox.Show("Bạn có chắc chắn muốn xóa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (dsnguyenlieu == null) { dtgrvDanhSachNL.DataSource = null; } if (NguyenLieu_BUS.XoaNguyenLieu(nguyenLieu)) { drvNL = null; txtTenNL.Text = ""; txtDonVi.Text = ""; txtSoLuong.Text = ""; LoadNguyenLieu(); MessageBox.Show("Xóa thành công"); return; } MessageBox.Show("Xóa thất bại"); } }
public void LayTTnguyenLieu(int a) { NguyenLieu_DTO nl = NguyenLieu_BUS.LayTTNguyenLieu(a); txtTenNL.Text = nl.TenNL; txtDonVi.Text = nl.Donvi; }
private void gABCapNhat_Click(object sender, EventArgs e) { if (drvNL == null) { MessageBox.Show("Chọn Món Ăn Muốn Sửa"); return; } NguyenLieu_DTO nguyenLieu = new NguyenLieu_DTO(); nguyenLieu.MaNL = int.Parse(drvNL.Cells["MaNL"].Value.ToString()); nguyenLieu.TenNL = txtTenNL.Text; nguyenLieu.Donvi = txtDonVi.Text; nguyenLieu.Soluong = int.Parse(txtSoLuong.Text); if (NguyenLieu_BUS.SuaNguyenLieu(nguyenLieu)) { drvNL = null; txtTenNL.Text = ""; txtDonVi.Text = ""; txtSoLuong.Text = ""; LoadNguyenLieu(); MessageBox.Show("Sửa thành công"); return; } MessageBox.Show("Sửa thất bại"); }
private void btnOK_Click(object sender, EventArgs e) { int SL; DonTKNguyenLieu_DTO donTK = new DonTKNguyenLieu_DTO(); donTK.IdNhanVienTK = ID; donTK.TenNhanVienTK = NhanVien_BUS.TimNV(ID).TenNhanVien; string s = ""; foreach (Control c in flplistNL.Controls) { if (c is TextBox) { if (c.Text != "0") { string DV = NguyenLieu_BUS.LayDVNguyenLieu(c.Name); SL = NguyenLieu_BUS.LaySLNguyenLieu(c.Name); SL = SL - int.Parse(c.Text); if (SL >= 0) { TongKetTK(c.Name, SL); } else { MessageBox.Show("Số lượng nguyên liệu sử dụng của " + c.Name + " không được nhiều hơn số lượng trong kho", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } s = s + c.Name + ":" + c.Text + DV + "\n"; } } } donTK.ThongKe = s; DonTKNguyenLieu_BUS.LayTTNguyenLieu(donTK); this.Close(); }
private void LoadKhoNguyenLieu() { flplistNL.Controls.Clear(); lstNL = NguyenLieu_BUS.LoadNguyenLieu(); if (lstNL == null) { return; } for (int i = 0; i < lstNL.Count; i++) { string ID = lstNL[i].MaNL.ToString(); string s = lstNL[i].TenNL; Label lb1 = new Label(); Label lb2 = new Label(); lb1.Font = new Font("Microsoft Sans Serif", 12); lb1.Margin = new Padding(3, 6, 0, 3); lb2.Font = new Font("Microsoft Sans Serif", 12); lb2.Margin = new Padding(0, 6, 0, 3); TextBox txt = new TextBox(); txt.Font = new Font("Microsoft Sans Serif", 12); txt.KeyPress += Txt_KeyPress; txt.TextChanged += Txt_TextChanged; lb1.Text = s; lb1.Name = ID; lb2.Text = lstNL[i].Donvi; lb2.Name = s; txt.Text = "0"; txt.Name = s; flplistNL.Controls.Add(lb1); flplistNL.Controls.Add(txt); flplistNL.Controls.Add(lb2); } }
private void btnTimKiemNL_Click(object sender, EventArgs e) { List <NguyenLieu_DTO> listnl = new List <NguyenLieu_DTO>(); NguyenLieu_BUS nl = new NguyenLieu_BUS(); listnl = nl.TimTheoMaNL(txtMaNLTimKiem.Text); dataGridViewQLNguyenLieu.DataSource = listnl; }
private void txtTimKiem_TextChanged(object sender, EventArgs e) { List <NguyenLieu_DTO> ketQua = NguyenLieu_BUS.TimNguyenLieu(txtTimKiem.Text); if (ketQua == null) { return; } dtgrvDanhSachNL.DataSource = ketQua; }
private void LoadDSNL() { NguyenLieu_BUS nl = new NguyenLieu_BUS(); List <NguyenLieu_DTO> dsnl = nl.LayDanhSachNguyenLieu(); dataGridViewQLNguyenLieu.MultiSelect = false; dataGridViewQLNguyenLieu.AutoGenerateColumns = false; dataGridViewQLNguyenLieu.DataSource = dsnl; dataGridViewQLNguyenLieu.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //dataGridViewQlSanPham.ReadOnly = true; dataGridViewQLNguyenLieu.RowHeadersVisible = false; }
private void tabKho_SelectedIndexChanged(object sender, EventArgs e) { NhaCungCap_BUS ncc = new NhaCungCap_BUS(); cbbNCC.DataSource = ncc.LayDanhSachNhaCungCap(); cbbNCC.DisplayMember = "TenNhaCC"; cbbNCC.ValueMember = "MaNhaCC"; NguyenLieu_BUS nl = new NguyenLieu_BUS(); cbbTenNL.DataSource = nl.LayDanhSachNguyenLieu(); cbbTenNL.DisplayMember = "TenNguyenLieu"; cbbTenNL.ValueMember = "MaNL"; Load_fromNhapHang(); }
private void cbbTenNL_SelectedIndexChanged(object sender, EventArgs e) { NguyenLieu_BUS nl = new NguyenLieu_BUS(); listnl = nl.LayDanhSachNguyenLieu(); for (int i = 0; i < listnl.Count; i++) { if (listnl[i].MaNL.ToString() == cbbTenNL.SelectedValue.ToString()) { txtDonGia.Text = listnl[i].DonGiaNL.ToString(); } } TinhThanhTien(); }
private void btnXoaNL_Click(object sender, EventArgs e) { if (dataGridViewQLNguyenLieu.SelectedRows.Count > 0) { NguyenLieu_DTO nl = (NguyenLieu_DTO)dataGridViewQLNguyenLieu.SelectedRows[0].DataBoundItem; if (MessageBox.Show("Bạn có chắc muốn xóa sản phẩm " + nl.MaNL + " không?", "Cảnh báo", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { NguyenLieu_BUS nl1 = new NguyenLieu_BUS(); nl1.XoaNguyenLieu(nl); MessageBox.Show("Đã xóa thành công sản phẩm"); LoadDSNL(); ResetNL(); } } }
private void btnSuaNL_Click(object sender, EventArgs e) { if (dataGridViewQLNguyenLieu.SelectedRows.Count > 0) { NguyenLieu_DTO nl = (NguyenLieu_DTO)dataGridViewQLNguyenLieu.SelectedRows[0].DataBoundItem; nl.TenNguyenLieu = txtTenNguyenLieu.Text; nl.DonViTinh = txtDonViTinh.Text; nl.DonGiaNL = decimal.Parse(txtDonGiaNguyenLieu.Text); NguyenLieu_BUS dtBus = new NguyenLieu_BUS(); dtBus.SuaThongTinNguyenLieu(nl); MessageBox.Show("Đã Sữa 1 Nguyên Liệu "); LoadDSNL(); ResetNL(); } }
public void DSMaNL() { try { cBMaNL.Items.Clear(); List <string> str = NguyenLieu_BUS.DSMaNL(); if (str == null) { return; } foreach (string s in str) { cBMaNL.Items.Add(s); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnThemNL_Click(object sender, EventArgs e) { if (txtTenNguyenLieu.Text.Trim() == "" || txtDonViTinh.Text.Trim() == "" || txtDonGiaNguyenLieu.Text.Trim() == "") { MessageBox.Show("Bạn chưa nhập đầy đủ thông tin", "Thông báo"); } else { NguyenLieu_DTO nl = new NguyenLieu_DTO(); nl.TenNguyenLieu = txtTenNguyenLieu.Text; nl.DonViTinh = txtDonViTinh.Text; nl.DonGiaNL = decimal.Parse(txtDonGiaNguyenLieu.Text); NguyenLieu_BUS dtBus = new NguyenLieu_BUS(); dtBus.ThemNguyenLieu(nl, 1); MessageBox.Show("Đã Thêm 1 Nguyên Liệu mới"); LoadDSNL(); ResetNL(); } }
private void TongKetTK(string Ten, int SL) { NguyenLieu_BUS.ThongKeSLNguyenLieu(Ten, SL); }