protected void Page_Load(object sender, EventArgs e) { ddlSanPham.DataSource = LoaiSanPhamBUS.LayDSLoaiSanPham(); ddlSanPham.DataTextField = "TenLoaiSP"; ddlSanPham.DataValueField = "MaLoaiSP"; ddlSanPham.DataBind(); }
private void FormChonSanPham_Load(object sender, EventArgs e) { List <SanPhamDTO> sanPhamDTO = new List <SanPhamDTO>(); sanPhamDTO = SanPhamBUS.SelectSanPhamAll(); for (int i = 0; i < sanPhamDTO.Count; i++) { dataGridView_ChoSanPham.Rows.Add(i + 1, sanPhamDTO[i].MaSanPham, sanPhamDTO[i].TenSanPham, LoaiSanPhamBUS.SelectLoaiSanPhamById(sanPhamDTO[i].MaLoaiSanPham).TenLoaiSanPham, false); } List <LoaiSanPhamDTO> lstcbspDTO = LoaiSanPhamBUS.SelectLoaiSanPhamAll(); LoaiSanPhamDTO all = new LoaiSanPhamDTO(); all.MaLoaiSanPham = "Tất cả"; all.TenLoaiSanPham = "Tất cả"; lstcbspDTO.Insert(0, all); comboBoxLoaiSanPham.DisplayMember = "TenLoaiSanPham"; comboBoxLoaiSanPham.ValueMember = "TenLoaiSanPham"; comboBoxLoaiSanPham.DataSource = lstcbspDTO; comboBoxLoaiSanPham.SelectedIndex = 0; }
protected void LoadLoaiSP() { drlLoaiSP.DataSource = LoaiSanPhamBUS.LayDSLoaiSP(); drlLoaiSP.DataValueField = "MaLoaiSP"; drlLoaiSP.DataTextField = "TenLoaiSP"; drlLoaiSP.DataBind(); }
public void Test_DeleteLoaiSP_Success() { lspBUS = new LoaiSanPhamBUS(); Assert.AreEqual(7, lspBUS.LoadLoaiSPBUS().Count); lspBUS.DeleteLoaiSPBUS(7); Assert.AreEqual(6, lspBUS.LoadLoaiSPBUS().Count); }
private void btnSuaLoaiSP_Click(object sender, EventArgs e) { if (this.txtTenLoaiSP.Text == string.Empty) { MessageBox.Show("Bạn chưa điền đầy đủ thông tin !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } LOAISANPHAM loaisp = new LOAISANPHAM(); loaisp.MALOAI = this.txtMaLoai.Text; loaisp.TENLOAI = this.txtTenLoaiSP.Text; if (LoaiSanPhamBUS.SuaLoaiSanPham(loaisp)) { MessageBox.Show("Cập nhật thông tin loại sản phẩm thành công !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadDataDSLoaiSP(); AutoCompleteMaLoai(); LoadComboBoxData(); ResetTabQLLoaiSP(); string lsth = "[" + DateTime.Now.ToString("dd/MM/yyyy-h:m:s") + "] " + this.manv + " đã cập nhật thông tin loại sản phẩm " + loaisp.MALOAI; LichSuHeThongBUS.ThemLSHT(new LICHSUHETHONG { NGAYTAO = DateTime.Now.Date, NV_THAOTAC = this.manv, VITRI_THAOTAC = this.vitrithaotacLoaiSP, GHICHU = lsth }); } else { MessageBox.Show("Sửa loại sản phẩm thất bại!!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtMaLoai_Validated(object sender, EventArgs e) { if (this.txtMaLoai.Text != string.Empty) { var kq = LoaiSanPhamBUS.LayDanhSachMaLoai().Where(p => p.MALOAI == this.txtMaLoai.Text).FirstOrDefault(); if (kq != null) { MessageBox.Show("Mã loại đã tồn tại !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMaLoai.Focus(); return; } if (this.txtMaLoai.Text == string.Empty) { return; } if (this.txtMaLoai.Text.Length > 10) { MessageBox.Show("Mã loại không được vượt quá 10 kí tự !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMaLoai.Focus(); return; } if (!KiemtraDinhDangMALOAI(this.txtMaLoai.Text)) { MessageBox.Show("Mã loại không đúng định dạng !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtMaLoai.Focus(); return; } } }
// GET: Admin/LoaiSanPhamAdmin/Edit/5 public ActionResult Edit(String id) // biến truyền vào là id { //load db theo id var db = LoaiSanPhamBUS.ChiTietAdmin(id); return(View(db)); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { SanPhamDTO sp = SanPhamBUS.LaySanPhamTheoMaSp(Request.QueryString["qqq"]); lblTenSP.Text = sp.TenSP; imgAnhMinhHoa.ImageUrl = "images/" + sp.AnhMinhHoa; lblThongTin.Text = sp.ThongTin; lblMaSP.Text = sp.MaSP; lblGia.Text = sp.GiaTien.ToString(); lblMaSP.Visible = false; DropDownList_size.DataSource = SanPhamBUS.LaySanPhamTheoTheoSise(Request.QueryString["qqq"]); DropDownList_size.DataTextField = "sizenumber"; DropDownList_size.DataValueField = "SoLuongTonKho"; DropDownList_size.DataBind(); lblSLTK.Text = DropDownList_size.Items[0].Value.ToString(); rpt_LoaiGiay.DataSource = LoaiSanPhamBUS.LayDSLoaiSanPham(); rpt_LoaiGiay.DataBind(); rpt_SizeGiay.DataSource = SizeGiayBUS.LayDSSize(); rpt_SizeGiay.DataBind(); rpt_spcungloai.DataSource = SanPhamBUS.LaySanPhamCungLoaiTrongTrangChiTiet(sp.MaLoaiSP); rpt_spcungloai.DataBind(); } }
protected void grvDSLoaiSP_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "ChonLoaiSP") { string maLoaiSP = e.CommandArgument.ToString(); LoaiSanPhamDTO loaisp = LoaiSanPhamBUS.LayThongTinLoaiSanPham(maLoaiSP); if (loaisp != null) { txtMaLoaiSP.Text = loaisp.MaLoaiSP; txtTenLoaiSP.Text = loaisp.TenLoaiSP; chkTrangThai.Checked = loaisp.TrangThai; GiaoDienThem(false); } } if (e.CommandName == "XoaLoaiSP") { string maLoaiSP = e.CommandArgument.ToString(); if (TaiKhoanBUS.XoaTK(maLoaiSP)) { XoaForm(); LoadDSLoaiSanPham(); } else { Response.Write("<script>alert('Xóa tài khoản thất bại');</script>"); } } }
public void Test_AddLoaiSP_Suscess() { lspBUS = new LoaiSanPhamBUS(); Assert.AreEqual(6, lspBUS.LoadLoaiSPBUS().Count); lsp = new LoaiSanPham(); lsp.TenLoai = "lspTest"; lspBUS.AddLoaiSPBUS(lsp); Assert.AreEqual(7, lspBUS.LoadLoaiSPBUS().Count); }
private void buttonYes_Click(object sender, EventArgs e) { bool flag = true; if (dataGridView_QuanLyLoaiSanPham.Rows[Index].Cells["ColTenLoaiSanPham"].Value == null) { MessageBox.Show("Tên loại sản phẩm không được để trống"); dataGridView_QuanLyLoaiSanPham.CurrentCell = dataGridView_QuanLyLoaiSanPham.Rows[Index].Cells["ColTenLoaiSanPham"]; dataGridView_QuanLyLoaiSanPham.BeginEdit(true); flag = false; } if (flag) { LoaiSanPhamDTO lspDTO = new LoaiSanPhamDTO(); lspDTO.TenLoaiSanPham = dataGridView_QuanLyLoaiSanPham.Rows[Index].Cells["ColTenLoaiSanPham"].Value.ToString(); if (Status == 1)//Them tham so { lspDTO.MaLoaiSanPham = LoaiSanPhamBUS.CreateLoaiSanPhamId(); dataGridView_QuanLyLoaiSanPham.Rows[Index].Cells["ColMaLoaiSanPham"].Value = lspDTO.MaLoaiSanPham; dataGridView_QuanLyLoaiSanPham.Rows[Index].Cells["ColSTT"].Value = (Index + 1).ToString(); if (LoaiSanPhamBUS.InsertLoaiSanPham(lspDTO)) { dataGridView_QuanLyLoaiSanPham.Rows[Index].ReadOnly = true; MessageBox.Show("Thêm thành công"); } else { dataGridView_QuanLyLoaiSanPham.Rows.RemoveAt(Index); MessageBox.Show("Thêm thất bại"); } } else if (Status == 2) { lspDTO.MaLoaiSanPham = dataGridView_QuanLyLoaiSanPham.Rows[Index].Cells["ColMaLoaiSanPham"].Value.ToString(); if (LoaiSanPhamBUS.UpdateLoaiSanPhamById(lspDTO)) { dataGridView_QuanLyLoaiSanPham.Rows[Index].ReadOnly = true; MessageBox.Show("Cập nhật thành công"); } else { MessageBox.Show("Cập nhật thất bại"); dataGridView_QuanLyLoaiSanPham.Rows[Index].Cells["ColTenLoaiSanPham"].Value = BackupLoaiSanPhamDTO.TenLoaiSanPham; dataGridView_QuanLyLoaiSanPham.Rows[Index].ReadOnly = true; } } Reset(); } }
protected void btncapnhat(object sender, RepeaterCommandEventArgs e) { if (e.CommandName == "ChonTK") { string ID = e.CommandArgument.ToString(); LoaiSanPhamDTO lsp = LoaiSanPhamBUS.LayDSLoaiSanPhamID(ID); txtid.Text = lsp.MaLoaiSP; txttenloai.Text = lsp.TenLoaiSP; txtid.Enabled = false; } }
private void txtLoaiSanPham_Validated(object sender, EventArgs e) { if (this.txtLoaiSanPham.Text != string.Empty) { if (!LoaiSanPhamBUS.KiemTraMaLoaiTonTai(this.txtLoaiSanPham.Text)) { MessageBox.Show("Mã loại không tồn tại !!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtLoaiSanPham.Focus(); } } }
protected void btnXoa_Click(object sender, EventArgs e) { if (LoaiSanPhamBUS.XoaLSP(txtid.Text)) { load(); Response.Write("<script>alert('Xóa loại sản phẩm thành công!')</script>"); } else { Response.Write("<script>alert('Xóa loại sản phẩm thất bại!')</script>"); } }
public ActionResult Create(LoaiSanPham lsp) // return view ở create sau đó request ở httppost { try { LoaiSanPhamBUS.InsertLSP(lsp); // gọi hàm InsertLSP của LoaiSanPhamBUS vào return(RedirectToAction("Index")); } catch { return(View()); } }
public void Test_UpdateLoaiSP_Suscess() { lsp = new LoaiSanPham(); lsp.MaLoaiSP = 5; lsp.TenLoai = "Thép"; lspBUS = new LoaiSanPhamBUS(); Assert.AreEqual(0, lspBUS.SearchTenLoaiSPBUS(lsp.TenLoai).Count); lspBUS.UpdateLoaiSPBUS(lsp); Assert.AreEqual(1, lspBUS.SearchTenLoaiSPBUS(lsp.TenLoai).Count); }
//string AutoTaoMaSP() //{ // List<SANPHAM> lstMaSP = SanPhamBUS.LayDanhSachSP(); // string ma = string.Empty; // if (lstMaSP.Count == 0) // { // ma = "SP1"; // return ma; // } // else // { // ma = lstMaSP.Select(p => p.MASP).LastOrDefault(); // int automa = Convert.ToInt32(ma.Remove(0, 2)) + 1; // ma = "SP" + automa; // for (int i = 0; i < lstMaSP.Count(); i++) // { // if (ma == lstMaSP[i].MASP) // { // automa = Convert.ToInt32(ma.Remove(0, 2)) + 1; // ma = "SP" + automa; // } // } // return ma; // } //} void AutoCompleteMaLoai() { lstLoaiSp = LoaiSanPhamBUS.LayDanhSachLoaiSanPham(); AutoCompleteStringCollection collection = new AutoCompleteStringCollection(); foreach (LOAISANPHAM item in lstLoaiSp) { collection.Add(item.MALOAI); } this.txtLoaiSanPham.AutoCompleteCustomSource = collection; this.txtLoaiSanPham.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.txtLoaiSanPham.AutoCompleteSource = AutoCompleteSource.CustomSource; }
public ActionResult Create(LOAISANPHAM lsp) { try { // TODO: Add insert logic here LoaiSanPhamBUS.InsertLSP(lsp); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Edit(String id, LOAISANPHAM lsp) { try { // TODO: Add update logic here LoaiSanPhamBUS.EditLoaiSanPham(id, lsp); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult XoaTamThoi(String id, LoaiSanPham lsp) { try { // TODO: Add delete logic here lsp.TinhTrang = "1"; LoaiSanPhamBUS.EditLSP(id, lsp); return(RedirectToAction("Index")); } catch { return(View()); } }
private void btnXoaLoaisp_Click(object sender, EventArgs e) { try { LoaiSanPhamDTO loaisp = new LoaiSanPhamDTO(); loaisp.ma_loai = cbxLoaiSP.SelectedValue.ToString(); LoaiSanPhamBUS.Delete_LSP(loaisp); load_data(); MessageBox.Show("Xóa thành công !", "Thông báo", MessageBoxButtons.OK); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
protected void btnThemMoi_Click(object sender, EventArgs e) { LoaiSanPhamDTO lsp = new LoaiSanPhamDTO(); lsp.TenLoaiSP = txttenloai.Text; if (LoaiSanPhamBUS.ThemLoaiSp(lsp)) { load(); Response.Write("<script>alert('Thêm mới loại sản phẩm thành công!')</script>"); } else { Response.Write("<script>alert('Thêm mới loại sản phẩm thất bại!')</script>"); } }
protected void btnThem_Click(object sender, EventArgs e) { LoaiSanPhamDTO dto = new LoaiSanPhamDTO() { MaLoaiSP = txtMaLoaiSP.Text, TenLoaiSP = txtTenLoaiSP.Text, TrangThai = ckTrangThai.Checked }; if (LoaiSanPhamBUS.ThemLoaiSP(dto) != -1) { lbTrangThai.Text = "Thêm thành công"; LoadDS(); } }
protected void btnCapNhat_Click(object sender, EventArgs e) { LoaiSanPhamDTO lsp = LoaiSanPhamBUS.LayDSLoaiSanPhamID(txtid.Text); lsp.TenLoaiSP = txttenloai.Text; if (LoaiSanPhamBUS.CapNhatLSP(lsp, txtid.Text)) { load(); Response.Write("<script>alert('Cập nhật loại sản phẩm thành công!')</script>"); } else { Response.Write("<script>alert('Cập nhật loại phẩm thất bại!')</script>"); } }
protected void btnSua_Click(object sender, EventArgs e) { LoaiSanPhamDTO loaisp = LoaiSanPhamBUS.LayThongTinLoaiSanPham(txtMaLoaiSP.Text); loaisp.MaLoaiSP = txtMaLoaiSP.Text; loaisp.TenLoaiSP = txtTenLoaiSP.Text; loaisp.TrangThai = chkTrangThai.Checked; if (LoaiSanPhamBUS.SuaLoaiSP(loaisp)) { XoaForm(); LoadDSLoaiSanPham(); GiaoDienThem(true); } else { Response.Write("<script>alert('Thêm tài khoản thất bại');</script>"); } }
void LoadComboBoxData() { this.cbDSLoaiSP.DataSource = LoaiSanPhamBUS.LayDanhSachLoaiSanPham(); this.cbDSLoaiSP.DisplayMember = "TENLOAI"; this.cbDSLoaiSP.ValueMember = "MALOAI"; this.cbDSNPP.DataSource = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); this.cbDSNPP.DisplayMember = "TENNPP"; this.cbDSNPP.ValueMember = "MANPP"; this.cbQLTimKiemLoaiSP.DataSource = LoaiSanPhamBUS.LayDanhSachLoaiSanPham(); this.cbQLTimKiemLoaiSP.DisplayMember = "TENLOAI"; this.cbQLTimKiemLoaiSP.ValueMember = "MALOAI"; this.cbQLTimKiemNPP.DataSource = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); this.cbQLTimKiemNPP.DisplayMember = "TENNPP"; this.cbQLTimKiemNPP.ValueMember = "MANPP"; }
void load_data() { PhieuNhapDTO pn = new PhieuNhapDTO(); pn.ma_phieu_nhap = txtMaPN.Text; dgvSanPham.DataSource = SanPhamBUS.Load_DSSP(); cbxLSP.DataSource = cbxLoaiSP.DataSource = LoaiSanPhamBUS.Load_DSLSP(); dgvChitietPN.DataSource = PhieuNhapBUS.Load_DSMaPN(pnh); cbxLSP.DisplayMember = cbxLoaiSP.DisplayMember = "ten_loai_sp"; cbxLSP.ValueMember = cbxLoaiSP.ValueMember = "ma_loai"; cbxNVLPN.DataSource = NhanVienBUS.GetDSNV(); cbxNVLPN.DisplayMember = "ten_nv"; cbxNVLPN.ValueMember = "ma_nv"; cbxNCC.DataSource = NhaCCBUS.Load_DSNCC(); cbxNCC.DisplayMember = "ten_ncc"; cbxNCC.ValueMember = "ma_ncc"; groupBox2.Enabled = false; }
private void buttonXoa_Click(object sender, EventArgs e) { DialogResult res = MessageBox.Show("Xóa loại sản phẩm", "Loại sản phẩm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); //Lấy vị trí cần xóa if (res == DialogResult.Yes) { Index = dataGridView_QuanLyLoaiSanPham.CurrentRow.Index; string id = dataGridView_QuanLyLoaiSanPham.CurrentRow.Cells["ColMaLoaiSanPham"].Value.ToString().Trim(); int stt = int.Parse(dataGridView_QuanLyLoaiSanPham.CurrentRow.Cells["ColSTT"].Value.ToString()); if (LoaiSanPhamBUS.DeleteLoaiSanPhamById(id)) { dataGridView_QuanLyLoaiSanPham.Rows.RemoveAt(Index); if (dataGridView_QuanLyLoaiSanPham.Rows.Count > 0) { bool flag = false; for (int i = 0; i < Index; i++) { if (dataGridView_QuanLyLoaiSanPham.Rows[i].Visible == true) { flag = true; } } for (int i = Index; i < dataGridView_QuanLyLoaiSanPham.RowCount; i++) { if (dataGridView_QuanLyLoaiSanPham.Rows[i].Visible == true) { dataGridView_QuanLyLoaiSanPham.Rows[i].Cells["ColSTT"].Value = stt.ToString(); stt++; flag = true; } } if (flag == false) { buttonDisabled(); } } else { buttonDisabled(); } } } }
/* * Hàm KhoiTao * Tải toàn bộ danh sách tham số */ private void KhoiTao() { List <SanPhamDTO> listSanPhamDTO = SanPhamBUS.SelectSanPhamAll(); List <LoaiSanPhamDTO> lstcbspDTO = LoaiSanPhamBUS.SelectLoaiSanPhamAll(); LoaiSanPhamDTO all = new LoaiSanPhamDTO(); all.MaLoaiSanPham = ""; all.TenLoaiSanPham = "Tất cả"; lstcbspDTO.Insert(0, all); cmbMaLoaiSanPham.DisplayMember = "TenLoaiSanPham"; cmbMaLoaiSanPham.ValueMember = "MaLoaiSanPham"; cmbMaLoaiSanPham.DataSource = lstcbspDTO; cmbMaLoaiSanPham.SelectedIndex = 0; List <LoaiSanPhamDTO> lstcbspDTO2 = LoaiSanPhamBUS.SelectLoaiSanPhamAll(); ColLoaiSanPham.DisplayMember = "TenLoaiSanPham"; ColLoaiSanPham.ValueMember = "MaLoaiSanPham"; ColLoaiSanPham.DataSource = lstcbspDTO2; ColLoaiSanPham.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; if (listSanPhamDTO != null) { SanPhamDTO item = new SanPhamDTO(); dataGridView_QuanLySanPham.Rows.Clear(); for (int i = 0; i < listSanPhamDTO.Count; i++) { item = listSanPhamDTO[i]; dataGridView_QuanLySanPham.Rows.Add((i + 1).ToString(), item.MaSanPham, item.TenSanPham, item.CV.ToString(), item.DonGia.ToString(), item.DonGiaTV.ToString(), item.SoLuongTon.ToString(), item.MaLoaiSanPham); dataGridView_QuanLySanPham.Rows[i].ReadOnly = true; } buttonLamLai.Enabled = true; buttonEnabled(); } else { buttonLamLai.Enabled = false; buttonDisabled(); } }
protected void btnCapNhat_Click(object sender, EventArgs e) { LoaiSanPhamDTO dto = new LoaiSanPhamDTO() { MaLoaiSP = txtMaLoaiSP.Text, TenLoaiSP = txtTenLoaiSP.Text, TrangThai = ckTrangThai.Checked }; if (LoaiSanPhamBUS.CapNhatLoaiSP(dto) > 0) { lbTrangThai.Text = "Cập nhật thành công"; LoadDS(); } else { lbTrangThai.Text = "Cập nhật thất bại"; } }