主题:怎样修改商品的相关数据呢?(包括图片)
public void update()
{
HttpPostedFile hhh=UploadFile.PostedFile;
char[] de={'\\'};
string[] AFilename=hhh.FileName.Split(de);
string strFilename=AFilename[AFilename.Length-1];//??????????
hhh.SaveAs(Server.MapPath(".")+"..\\../images\\"+strFilename);
string intb= strFilename;
string cstring=data.constr ;
SqlConnection myConnection=new SqlConnection (ConfigurationSettings.AppSettings["ConnectionString"]);
myConnection.Open ();
//string sql="update Goods set GoodsImage=@GoodsImage,CategoryID=@CategoryID,ModelName=@ModelName,ModelNumber=@ModelNumber,OriginalPrice=@OriginalPrice,SalePrice=@SalePrice,GoodsDescription=@GoodsDescription ";
SqlCommand myCommand=new SqlCommand ("update Goods set GoodsImage=@GoodsImage,CategoryID=@CategoryID,ModelName=@ModelName,ModelNumber=@ModelNumber,OriginalPrice=@OriginalPrice,SalePrice=@SalePrice,GoodsDescription=@GoodsDescription",myConnection);
SqlParameter parameterGoodsImages=new SqlParameter ("@GoodsImage",SqlDbType.NVarChar ,50);
parameterGoodsImages.Value =intb;
myCommand.Parameters .Add (parameterGoodsImages);
SqlParameter parameterCategoryID=new SqlParameter ("@CategoryID",SqlDbType.Int ,4);
parameterCategoryID.Value =int.Parse(this.DropDownList1.SelectedValue);
myCommand.Parameters .Add (parameterCategoryID);
SqlParameter parameterModelName=new SqlParameter ("@ModelName",SqlDbType.NVarChar ,50);
parameterModelName.Value =this.ProdName.Value ;
myCommand.Parameters .Add (parameterModelName);
SqlParameter parameterModelNumber=new SqlParameter ("@ModelNumber",SqlDbType.NVarChar ,50);
parameterModelNumber.Value =this.quantitytxt .Text ;
myCommand.Parameters .Add (parameterModelNumber);
SqlParameter parameterOrigimalPrice=new SqlParameter ("@OriginalPrice",SqlDbType.Money ,8);
parameterOrigimalPrice.Value =this.PriceOrigin .Value ;
myCommand.Parameters .Add (parameterOrigimalPrice);
SqlParameter parameterSalePrice=new SqlParameter ("@SalePrice'",SqlDbType.Money ,8);
parameterSalePrice.Value =this.PriceList .Value ;
myCommand.Parameters .Add (parameterSalePrice);
SqlParameter parameterDes=new SqlParameter ("@GoodsDescription",SqlDbType.NVarChar ,2000);
parameterDes.Value =this.FreeTextBox1 .Text ;
myCommand.Parameters .Add (parameterDes);
myCommand.ExecuteNonQuery();
myConnection.Close ();
}
{
HttpPostedFile hhh=UploadFile.PostedFile;
char[] de={'\\'};
string[] AFilename=hhh.FileName.Split(de);
string strFilename=AFilename[AFilename.Length-1];//??????????
hhh.SaveAs(Server.MapPath(".")+"..\\../images\\"+strFilename);
string intb= strFilename;
string cstring=data.constr ;
SqlConnection myConnection=new SqlConnection (ConfigurationSettings.AppSettings["ConnectionString"]);
myConnection.Open ();
//string sql="update Goods set GoodsImage=@GoodsImage,CategoryID=@CategoryID,ModelName=@ModelName,ModelNumber=@ModelNumber,OriginalPrice=@OriginalPrice,SalePrice=@SalePrice,GoodsDescription=@GoodsDescription ";
SqlCommand myCommand=new SqlCommand ("update Goods set GoodsImage=@GoodsImage,CategoryID=@CategoryID,ModelName=@ModelName,ModelNumber=@ModelNumber,OriginalPrice=@OriginalPrice,SalePrice=@SalePrice,GoodsDescription=@GoodsDescription",myConnection);
SqlParameter parameterGoodsImages=new SqlParameter ("@GoodsImage",SqlDbType.NVarChar ,50);
parameterGoodsImages.Value =intb;
myCommand.Parameters .Add (parameterGoodsImages);
SqlParameter parameterCategoryID=new SqlParameter ("@CategoryID",SqlDbType.Int ,4);
parameterCategoryID.Value =int.Parse(this.DropDownList1.SelectedValue);
myCommand.Parameters .Add (parameterCategoryID);
SqlParameter parameterModelName=new SqlParameter ("@ModelName",SqlDbType.NVarChar ,50);
parameterModelName.Value =this.ProdName.Value ;
myCommand.Parameters .Add (parameterModelName);
SqlParameter parameterModelNumber=new SqlParameter ("@ModelNumber",SqlDbType.NVarChar ,50);
parameterModelNumber.Value =this.quantitytxt .Text ;
myCommand.Parameters .Add (parameterModelNumber);
SqlParameter parameterOrigimalPrice=new SqlParameter ("@OriginalPrice",SqlDbType.Money ,8);
parameterOrigimalPrice.Value =this.PriceOrigin .Value ;
myCommand.Parameters .Add (parameterOrigimalPrice);
SqlParameter parameterSalePrice=new SqlParameter ("@SalePrice'",SqlDbType.Money ,8);
parameterSalePrice.Value =this.PriceList .Value ;
myCommand.Parameters .Add (parameterSalePrice);
SqlParameter parameterDes=new SqlParameter ("@GoodsDescription",SqlDbType.NVarChar ,2000);
parameterDes.Value =this.FreeTextBox1 .Text ;
myCommand.Parameters .Add (parameterDes);
myCommand.ExecuteNonQuery();
myConnection.Close ();
}