public DTOSanPhamCT(DataRow dongDL) { MaSP = (int)dongDL["MaSP"]; TenSP = dongDL["TenSP"].ToString(); Gia = (int)dongDL["Gia"]; dtoLoaiSP = new DTOLoaiSP(dongDL); }
public DTOSanPhamCT(DataRow dongDL) { MaSP = (int)dongDL["MaSP"]; TenSP = dongDL["TenSP"].ToString(); Gia = (int)dongDL["Gia"]; dtoLoaiSP = new DTOLoaiSP(dongDL); }
public DTOSanPham(DataRow dongDL) { MaSP = (int)dongDL["MaSP"]; TenSP = dongDL["TenSP"].ToString(); Gia = (int)dongDL["Gia"]; dtoLoaiSP = new DTOLoaiSP(dongDL); //LoaiSP = new DTOLoaiSP(dongDL); soluong = (int)dongDL["soluong"]; //GiaSP = (int)dongDL["GiaSP"]; }
public DTOSanPham(DataRow dongDL) { MaSP = (int)dongDL["MaSP"]; TenSP = dongDL["TenSP"].ToString(); Gia = (int)dongDL["Gia"]; dtoLoaiSP = new DTOLoaiSP(dongDL); //LoaiSP = new DTOLoaiSP(dongDL); soluong = (int)dongDL["soluong"]; //GiaSP = (int)dongDL["GiaSP"]; }
protected void btnLuuSP_Click(object sender, EventArgs e) { DTOLoaiSP dtoLSP = new DTOLoaiSP(); dtoLSP.TenLSP = txtLSP.Text; DAO_Entity daoLSP = new DAO_Entity(); if (KiemTraNhap() == "") { daoLSP.ThemLoaiSP(dtoLSP); Response.Redirect("~/QLBophan_Admin/QLCauHinhLoaiSP/LoaiSP.aspx"); } else { ThemLoaiSP.Visible = true; lbLoi.Text = KiemTraNhap(); } }
//Lấy TT loai sp do vao listbox public List<DTOLoaiSP> LayDSLSP() { List<DTOLoaiSP> dsLSP = new List<DTOLoaiSP>(); string lenh = "select * from LoaiSP"; ketnoi.TaoKetNoi(); DataTable bang = new DataTable(); try { ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); ketnoi.TichHopCSDL = new SqlDataAdapter(ketnoi.LenhKetNoi); ketnoi.TichHopCSDL.Fill(bang); foreach (DataRow dongDL in bang.Rows) { DTOLoaiSP dtoLSP = new DTOLoaiSP(dongDL); dsLSP.Add(dtoLSP); } } catch (Exception) { throw; } finally { ketnoi.DongKetNoi(); } return dsLSP; }
public DTOLoaiSP LayThongTinLoaiSP(string maSua) { ketnoi.TaoKetNoi(); DTOLoaiSP dtoloaisp = null; try { string lenh = "select * from LoaiSP where MaLoai = @maSua "; ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); ketnoi.LenhKetNoi.Parameters.Add("@maSua", SqlDbType.Int); ketnoi.LenhKetNoi.Parameters["@maSua"].Value = maSua; DataTable bang = new DataTable(); ketnoi.TichHopCSDL = new SqlDataAdapter(ketnoi.LenhKetNoi); ketnoi.TichHopCSDL.Fill(bang); DataRow dong = bang.Rows[0]; dtoloaisp = new DTOLoaiSP(dong); } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return dtoloaisp; }
//Xoa LoaiKH public bool XoaLoaiSP(DTOLoaiSP dtoloaisp) { bool kq = false; ketnoi.TaoKetNoi(); try { string lenh = "delete from LoaiSP where MaLoai = @malsp"; ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); ketnoi.LenhKetNoi.Parameters.Add("@malsp", SqlDbType.Int); ketnoi.LenhKetNoi.Parameters["@malsp"].Value = dtoloaisp.MaLSP; if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0) { kq = true; } } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return kq; }
//Them LoaiKH public bool ThemLoaiSP(DTOLoaiSP dtoloaisp) { bool kq = false; ketnoi.TaoKetNoi(); try { string lenh = " insert into LoaiSP(TenLoai) values (@tenlsp)"; ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); //ketnoi.LenhKetNoi.Parameters.Add("@malkh", SqlDbType.Int); ketnoi.LenhKetNoi.Parameters.Add("@tenlsp", SqlDbType.NVarChar); //ketnoi.LenhKetNoi.Parameters["@malkh"].Value = dtoloaikh.MaLKH; ketnoi.LenhKetNoi.Parameters["@tenlsp"].Value = dtoloaisp.TenLSP; if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0) { kq = true; } } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return kq; }