public object InsertScalar(frmPro Pro) { return(base.ExecScalar("INSERT INTO " + "Product(PName, PSize, Color, Quantity, MID, PTypeID,TID,Saleprice,Unitprice) " + "OUTPUT INSERTED.PID VALUES(@pname, @Psize, @Color, @Quantity, @MID, @PTypeID, @TID, @Saleprice, @Unitprice)", GetParameter(Pro))); }
public int Insert(frmPro Pro) { return(base.ExecNonQuery("INSERT INTO " + "Product(PName, PSize, Color, Quantity, MID, PTypeID,TID,Saleprice,Unitprice,Image) " + "VALUES(@pname, @Psize, @Color, @Quantity, @MID, @PTypeID, @TID, @Saleprice, @Unitprice,Convert(varbinary(max),@img))", GetParameter(Pro))); }
private frmPro GetPro() { frmPro pro = new frmPro(); try { pro.pro_id = Convert.ToInt32(txtPID.Text); pro.pro_code = txtPCode.Text; pro.pro_name = txtPName.Text; pro.pro_size = txtPSize.Text; pro.color = txtColor.Text; pro.quantity = Convert.ToInt32(txtQuantity.Text); pro.model = Convert.ToInt32(cbBMo.SelectedValue); pro.ph_type = Convert.ToInt32(cbBPT.SelectedValue); pro.type = Convert.ToInt32(cbbType.SelectedValue); pro.saleprice = (float.Parse)(txtSalePrice.Text); pro.unitprice = float.Parse(txtUnitprice.Text); MemoryStream mem = new MemoryStream(); pro_img.Image.Save(mem, System.Drawing.Imaging.ImageFormat.Jpeg); pro.img = mem.ToArray(); return(pro); } catch (Exception) { return(null); } }
public SqlParameter[] GetParameter(frmPro Pro) { SqlParameter[] param = new SqlParameter[12]; try { param[0] = new SqlParameter("PID", Pro.pro_id); param[1] = new SqlParameter("PCode", Pro.pro_code); param[2] = new SqlParameter("PName", Pro.pro_name); param[3] = new SqlParameter("PSize", Pro.pro_size); param[4] = new SqlParameter("color", Pro.color); param[5] = new SqlParameter("quantity", Pro.quantity); param[6] = new SqlParameter("mid", Pro.model); param[7] = new SqlParameter("PTypeID", Pro.ph_type); param[8] = new SqlParameter("TID", Pro.type); param[9] = new SqlParameter("Saleprice", Pro.saleprice); param[10] = new SqlParameter("Unitprice", Pro.unitprice); param[11] = new SqlParameter("img", Pro.img); return(param); } catch (Exception) { return(null); } }
public int Update(frmPro Pro) { return(base.ExecNonQuery("UPDATE Product " + "SET PName=@PName, PSize=@PSize, Color=@Color, Quantity=@Quantity, MID=@MID, PTypeID=@PTypeID, TID=@TID, Saleprice=@Saleprice, Unitprice=@Unitprice,Image=convert(varbinary(max),@img) WHERE PID=@PID", GetParameter(Pro))); }