public bool insertdata(En_SanPham en) { string query = string.Format("INSERT INTO SanPham(TenSP, DonViTinh, DonGiaMua, SoTon, MaLoai) VALUES(@TenSP,@DonViTinh,@DonGiaMua,@SoTon,@MaLoai)"); SqlParameter[] sqlPara = new SqlParameter[5]; sqlPara[0] = new SqlParameter("@TenSP", en.TenSP); sqlPara[1] = new SqlParameter("@DonViTinh", en.DonVi); sqlPara[2] = new SqlParameter("@DonGiaMua", en.DonGia); sqlPara[3] = new SqlParameter("@SoTon", en.SoTon); sqlPara[4] = new SqlParameter("@MaLoai", en.MaLoai); return(cnn.executeInsertQuery(query, sqlPara)); }
public int insertdata(En_LoaiSanPham en) { string query = string.Format("INSERT INTO LoaiSanPham(TenLoai, MoTa) VALUES(@TenLoai,@MoTa)"); SqlParameter[] sqlPara = new SqlParameter[2]; sqlPara[0] = new SqlParameter("@TenLoai", en.TenLoai); sqlPara[1] = new SqlParameter("@MoTa", en.MoTa); int rows = 0; try { cnn.executeInsertQuery(query, sqlPara); rows += 1; } catch (Exception ex) { throw ex; } return(rows); }