//---------------------------------------------------------------------------------------------------------// public static void Insert(ELOAISANPHAM OLOAISANPHAM) { SqlParameter[] pr = new SqlParameter[3]; pr[0] = new SqlParameter(@"MAL", OLOAISANPHAM.MAL); pr[1] = new SqlParameter(@"TENL", OLOAISANPHAM.TENL); pr[2] = new SqlParameter(@"MOTA", OLOAISANPHAM.MOTA); DataAccseL.ExecuteNonQuery(CommandType.StoredProcedure, "LOAISANPHAM_Insert", pr); }
public ELOAISANPHAM(string vMAL) { ELOAISANPHAM OLOAISANPHAM = BLOAISANPHAM.SelectByID(vMAL); this.MAL = OLOAISANPHAM.MAL; this.TENL = OLOAISANPHAM.TENL; this.MOTA = OLOAISANPHAM.MOTA; }
private void btnThem_Click(object sender, EventArgs e) { ELOAISANPHAM el = new ELOAISANPHAM(); el.MAL = txtma.Text.Trim(); el.TENL = txtten.Text.Trim(); el.MOTA = txtmota.Text.Trim(); BLOAISANPHAM.Insert(el); FormLoaiSP_Load(sender, e); }
//---------------------------------------------------------------------------------------------------------// private static ELOAISANPHAM GetOneLOAISANPHAM(IDataReader idr) { ELOAISANPHAM OLOAISANPHAM = new ELOAISANPHAM(); if (idr["MAL"] != DBNull.Value) OLOAISANPHAM.MAL = (string)idr["MAL"]; if (idr["TENL"] != DBNull.Value) OLOAISANPHAM.TENL = (string)idr["TENL"]; if (idr["MOTA"] != DBNull.Value) OLOAISANPHAM.MOTA = (string)idr["MOTA"]; return OLOAISANPHAM; }
public static ELOAISANPHAM SelectByID(string MAL) { ELOAISANPHAM OLOAISANPHAM = new ELOAISANPHAM(); SqlParameter[] pr = new SqlParameter[1]; pr[0] = new SqlParameter(@"MAL", MAL); IDataReader idr = DataAccseL.ExecuteReader(CommandType.StoredProcedure, "LOAISANPHAM_SelectByID", pr); if (idr.Read()) OLOAISANPHAM = GetOneLOAISANPHAM(idr); idr.Close(); idr.Dispose(); return OLOAISANPHAM; }
public static void Update(ELOAISANPHAM OLOAISANPHAM) { SqlParameter[] pr = new SqlParameter[3]; pr[0] = new SqlParameter(@"MAL", OLOAISANPHAM.MAL); pr[1] = new SqlParameter(@"TENL", OLOAISANPHAM.TENL); pr[2] = new SqlParameter(@"MOTA", OLOAISANPHAM.MOTA); SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "LOAISANPHAM_Update", pr); }