public void SuaPhanLoai(PhanLoaiBO phanloaiBO) { SqlConnection cnn = new SqlConnection(cnnstr); string query = "update PhanLoai set tenphanloai=@TenPhanLoai where maphanloai=@MaPhanLoai "; SqlCommand cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@TenPhanLoai", phanloaiBO.TenPhanLoai); cmd.Parameters.AddWithValue("@MaPhanLoai", phanloaiBO.MaPhanLoai); cnn.Open(); cmd.ExecuteNonQuery(); cnn.Close(); }
public bool Compare(PhanLoaiBO phanloaiBO) { if (this.MaPhanLoai != phanloaiBO.MaPhanLoai) return false; if (this.TenPhanLoai != phanloaiBO.TenPhanLoai) return false; if (this.chitietphanloaiColl.Count != phanloaiBO.chitietphanloaiColl.Count) return false; for (int i = 0; i < this.chitietphanloaiColl.Count; i++) { if (this.chitietphanloaiColl.Index(i) != phanloaiBO.chitietphanloaiColl.Index(i)) return false; } return true; }
public bool SuaPhanLoai(string maphanloai, string tenphanloai) { try { PhanLoaiBO phanloaiBO = new PhanLoaiBO(); phanloaiBO.MaPhanLoai = maphanloai; phanloaiBO.TenPhanLoai = tenphanloai; phanloaiDAO.SuaPhanLoai(phanloaiBO); return true; } catch { return false; } }
public void NapTheLoai() { TheLoaiDropdown.Items.Clear(); PhanLoaiCollection source = new PhanLoaiCollection(); PhanLoaiBO phanloaiBO = new PhanLoaiBO(); phanloaiBO.TenPhanLoai = "Tất cả"; phanloaiBO.MaPhanLoai = ""; source.Add(phanloaiBO); //add PhanLoaiCollection temp = new PhanLoaiCollection(); temp=phanloaiBUS.TimDSPhanLoai(); for (int i = 0; i < temp.Count; i++) { source.Add(temp.Index(i)); } TheLoaiDropdown.DataSource = source; TheLoaiDropdown.DataTextField = "Tenphanloai"; TheLoaiDropdown.DataValueField = "Maphanloai"; TheLoaiDropdown.DataBind(); }
public void Add(PhanLoaiBO phanloaiBO) { List.Add(phanloaiBO); }
public PhanLoaiBO Tim1PhanLoai(string MaPhanLoai) { PhanLoaiBO plBO = new PhanLoaiBO(); CTPhanLoaiCollection ctPhanLoaiColl = new CTPhanLoaiCollection(); SqlConnection cnn = new SqlConnection(cnnstr); SqlCommand cmd = new SqlCommand("select * from chitietPhanLoai where MaPhanLoai=@maphanloai", cnn); cmd.Parameters.AddWithValue("@maphanloai", MaPhanLoai); cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { //lấy thông tin của phân loại plBO.MaPhanLoai = dr["MaPhanLoai"].ToString(); plBO.TenPhanLoai = dr["TenPhanLoai"].ToString(); //lấy chi tiết phân lọai CTPhanLoai ctphanloai = new CTPhanLoai(); ctphanloai.MaCTPhanLoai = dr["MaCTPhanLoai"].ToString(); ctphanloai.TenCTPhanLoai=dr["TenCTPhanLoai"].ToString(); ctPhanLoaiColl.Add(ctphanloai); } //gán chi tiết phân lọai plBO.chitietphanloaiColl = ctPhanLoaiColl; cnn.Close(); return plBO; }
public PhanLoaiCollection TimDSPhanLoai() { PhanLoaiCollection plColl = new PhanLoaiCollection(); SqlConnection cnn = new SqlConnection(cnnstr); SqlCommand cmd = new SqlCommand("select * from PhanLoai order by TenPhanLoai", cnn); cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { PhanLoaiBO plBO = new PhanLoaiBO(); plBO.MaPhanLoai = dr["MaPhanLoai"].ToString(); plBO.TenPhanLoai=dr["TenPhanLoai"].ToString(); plColl.Add(plBO); // string mapl = dr["maphanloai"].ToString(); // plColl.Add(Tim1PhanLoai(mapl)); } cnn.Close(); return plColl; }
public PhanLoaiCollection TimDSCapNhatPhanLoai(string tenphanloai) { PhanLoaiCollection phanloaicoll = new PhanLoaiCollection(); SqlConnection cnn = new SqlConnection(cnnstr); string query = "select * from PhanLoai where tenphanloai <> '' "; query += "order by tenphanloai"; SqlCommand cmd = new SqlCommand(query, cnn); if (tenphanloai != "") { query = "select * from PhanLoai where tenphanloai like @tenphanloai and tenphanloai <>''"; query += "order by tenphanloai"; cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@tenphanloai", "%" + tenphanloai + "%"); } cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { PhanLoaiBO phanloaiBO = new PhanLoaiBO(); phanloaiBO.MaPhanLoai = dr["maphanloai"].ToString(); phanloaiBO.TenPhanLoai = dr["tenphanloai"].ToString(); phanloaicoll.Add(phanloaiBO); } cnn.Close(); return phanloaicoll; }
public PhanLoaiBO Tim1PhanLoai_CT(string mactphanloai) { PhanLoaiBO phanloaiBO = new PhanLoaiBO(); SqlConnection cnn = new SqlConnection(cnnstr); string query = "SELECT phanloai.maphanloai maphanloai,tenphanloai FROM phanloai,chitietphanloai where phanloai.maphanloai =chitietphanloai.maphanloai AND mactphanloai=@mactphanloai"; SqlCommand cmd = new SqlCommand(query, cnn); cmd.Parameters.AddWithValue("@mactphanloai", mactphanloai); cnn.Open(); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { phanloaiBO.MaPhanLoai = dr["maphanloai"].ToString(); phanloaiBO.TenPhanLoai = dr["tenphanloai"].ToString(); break; } cnn.Close(); return phanloaiBO; }