public DTOVatLieu(DataRow dongDL) { MaVL = (int)dongDL["MaVL"]; TenVL = dongDL["TenVL"].ToString(); dtoNCC = new DTONhacungcap(dongDL); Donvi = dongDL["Donvi"].ToString(); Gia = (decimal)dongDL["Gia"]; Soluong = (int)dongDL["Soluong"]; }
public DTOPhieuDatVatLieuCC(DataRow dongDL) { MaPDVLCC = dongDL["MaPDVLCC"].ToString(); dtoNhaCungCap = new DTONhacungcap(dongDL); TenNCC = dongDL["TenNCC"].ToString(); dtoncc = new DTONhacungcap(dongDL); NgayLap = (DateTime)dongDL["NgayLap"]; NgayGiao = (DateTime)dongDL["NgayGiao"]; TongTien = (decimal)dongDL["TongTien"]; CongNoNCC = (decimal)dongDL["CongNoNCC"]; int tt = (int)dongDL["TrangThai"]; TrangThai = tt == 1 ? "Chưa xử lý" : "Đã xử lý"; }
protected void btnLu_Click(object sender, EventArgs e) { DTONhacungcap dtoncc = new DTONhacungcap(); dtoncc.TenNCC = txtTen.Text; dtoncc.Sdt = txtSDT.Text; dtoncc.Diachi = txtDiaChi.Text; DAO_Entity daoncc = new DAO_Entity(); if (KiemTraNhap() == "") { daoncc.ThemNhaCungCap(dtoncc); Response.Redirect("~/QLBophan_Admin/QLCauHinhNCC/NCC.aspx"); } else { ThemNCC.Visible = true; lbLoi.Text = KiemTraNhap(); } }
public List<DTONhacungcap> LayDSNCC() { List<DTONhacungcap> dsNCC = new List<DTONhacungcap>(); string lenh = "select * from NhaCungCap"; 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) { DTONhacungcap dtoNCC = new DTONhacungcap(dongDL); dsNCC.Add(dtoNCC); } } catch (Exception) { throw; } finally { ketnoi.DongKetNoi(); } return dsNCC; }
public DTONhacungcap LayThongTinNhaCungCap(string maSua) { ketnoi.TaoKetNoi(); DTONhacungcap dtoNCC = null; try { string lenh = "select * from NhaCungCap where MaNCC = @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]; dtoNCC = new DTONhacungcap(dong); } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return dtoNCC; }
public bool XoaVatLieu(DTONhacungcap dtoNCC) { bool kq = false; ketnoi.TaoKetNoi(); try { string lenh = "delete from NhaCungCap where MaNCC = @mancc"; ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); ketnoi.LenhKetNoi.Parameters.Add("@mancc", SqlDbType.Int); ketnoi.LenhKetNoi.Parameters["@mancc"].Value = dtoNCC.MaNCC; if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0) { kq = true; } } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return kq; }
public bool capnhatdanhsach(DTONhacungcap dtoNCC) { bool kq = false; ketnoi.TaoKetNoi(); try { string lenh = "update NhaCungCap set TenNCC = @tenncc, Sdt = @sdt ,Diachi= @diachi where MaNCC= @mancc"; ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); ketnoi.LenhKetNoi.Parameters.Add("@mancc", SqlDbType.Int); ketnoi.LenhKetNoi.Parameters.Add("@tenncc", SqlDbType.NVarChar); ketnoi.LenhKetNoi.Parameters.Add("@sdt", SqlDbType.Int); ketnoi.LenhKetNoi.Parameters.Add("@diachi", SqlDbType.NVarChar); ketnoi.LenhKetNoi.Parameters["@mancc"].Value = dtoNCC.MaNCC; ketnoi.LenhKetNoi.Parameters["@tenncc"].Value = dtoNCC.TenNCC; ketnoi.LenhKetNoi.Parameters["@sdt"].Value = dtoNCC.Sdt; ketnoi.LenhKetNoi.Parameters["@diachi"].Value = dtoNCC.Diachi; if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0) { kq = true; } } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return kq; }
//ThemNCC public bool ThemNhaCungCap(DTONhacungcap dtoNCC) { bool kq = false; ketnoi.TaoKetNoi(); try { string lenh = " insert into NhaCungCap (TenNCC ,Sdt ,Diachi) values (@tenncc ,@sdt ,@diachi)"; ketnoi.LenhKetNoi = new SqlCommand(lenh, ketnoi.KetNoi); //ketnoi.LenhKetNoi.Parameters.Add("@mancc", SqlDbType.Int); ketnoi.LenhKetNoi.Parameters.Add("@tenncc", SqlDbType.NVarChar); ketnoi.LenhKetNoi.Parameters.Add("@sdt", SqlDbType.VarChar); ketnoi.LenhKetNoi.Parameters.Add("@diachi", SqlDbType.NVarChar); // ketnoi.LenhKetNoi.Parameters["@mancc"].Value = dtoNCC.MaNCC; ketnoi.LenhKetNoi.Parameters["@tenncc"].Value = dtoNCC.TenNCC; ketnoi.LenhKetNoi.Parameters["@sdt"].Value = dtoNCC.Sdt; ketnoi.LenhKetNoi.Parameters["@diachi"].Value = dtoNCC.Diachi; if (ketnoi.LenhKetNoi.ExecuteNonQuery() != 0) { kq = true; } } catch (Exception) { } finally { ketnoi.DongKetNoi(); } return kq; }