public void layDSLoai() { DataTable dtLoai = LoaiSPControl.layDSLoai(idMH); for (int i = 0; i < dtLoai.Rows.Count; ++i) { listLoai.Add(new LoaiSP(Convert.ToInt32(dtLoai.Rows[i][0].ToString()), dtLoai.Rows[i][1].ToString())); } }
private void frmThemSP_Load(object sender, EventArgs e) { List <LoaiSP> list = new List <LoaiSP>(); DataTable dt = LoaiSPControl.layDSLoai(); for (int i = 0; i < dt.Rows.Count; ++i) { list.Add(new LoaiSP(Convert.ToInt32(dt.Rows[i]["MaLoaiSP"].ToString()), dt.Rows[i]["TenLoaiSP"].ToString())); } cbLoai.DataSource = list; cbLoai.DisplayMember = "TenLoai"; }
private void btnXoaLoai_Click(object sender, EventArgs e) { if (tvLoaiSP.SelectedNode.Name.Equals("TatCa")) { return; } else if (tvLoaiSP.SelectedNode.Parent.Name.Equals("TatCa")) // mặt hàng { MatHangControl.xoaDuLieu(Convert.ToInt32(tvLoaiSP.SelectedNode.Name)); loadLoaiSP(); } else { LoaiSPControl.xoaDuLieu(Convert.ToInt32(tvLoaiSP.SelectedNode.Name)); loadLoaiSP(); } }
private void btnLuu_Click(object sender, EventArgs e) { string ten = txtTenLoai.Text; MatHang mh = cbMatHang.SelectedValue as MatHang; if (mh.IdMH == 0) // thêm mặt hàng { int ketqua = MatHangControl.themDuLieu(ten); if (ketqua > 0) { this.Close(); } } else // thêm loại sản phẩm { int ketqua = LoaiSPControl.themDuLieu(ten, mh.IdMH); if (ketqua > 0) { this.Close(); } } }