c.部分相关代码
private void productAdd_Click(object sender, System.EventArgs e)
{
//get imageData
HttpPostedFile UpFile = imageFile.PostedFile;
int FileLength = UpFile.ContentLength;
Byte[] ImageData =new Byte[FileLength];
Stream StreamObject= UpFile.InputStream ;
StreamObject.Read(ImageData,0,FileLength);
int CompanyID= int.Parse(Session["CompanyID"].ToString()) ;
float UnitPrice=float.Parse(unitPrice.Text);
float ListPrice=float.Parse(listPrice.Value);
int CategoryID=int.Parse(Session["CategoryID"].ToString() );
int Mailing;
int Express;
if(freightStyle.SelectedValue.Equals("买家承担运费"))
{
Mailing =int.Parse(mailing.Text);
Express =int.Parse(express.Text );
}
else
{
Mailing=0;
Express=0;
}
int Amount =int.Parse(amount.Text);
String Shelf="是";
if(shelf.Checked==false)
{
Shelf="否";
}
//产品状态
//1.有库存 2.无库存 3.一折 4. 。。。。。。
int StatusID=1;
productDB PDB = new productDB() ;
//注意 :系统正式运行时,要重新考虑给产品状态赋值 stateID
PDB.Add(CompanyID,name.Text,UnitPrice,ListPrice,intro.Value,DateTime.Now,CategoryID,
ImageData,StatusID,freightStyle.SelectedValue,
Mailing,Express,payStyle.SelectedValue,guarantee.SelectedValue,invoice.
SelectedValue,province.Text
,city.Text ,Amount,newGrade.SelectedValue,Shelf);
}
private void freightStyle_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(freightStyle.SelectedValue.Equals("买家承担运费"))
{
Panel1.Visible=true;
}
else
{
Panel1.Visible =false;
}
}
6.1.3相关类库
public class productDB
{
public productDB()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
/*增加商品*/
public void Add(int CompanyID,String ProductName,float UnitPrice,float ListPrice,String Introduce,DateTime UpdateTime,int CategoryID,Byte[] ImageData ,int StatusID,
String FreightStyle,int Mailing,int Express,String PayStyle,String Guarantee,String Invoice,String Province,String City,int Amount,
String NewGrade,String Shelf)
{
// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ESMS"]);
SqlCommand myCommand = new SqlCommand("ProductsAdd", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter parameterCompanyID = new SqlParameter("@CompanyID", SqlDbType.Int );
parameterCompanyID.Value = CompanyID;
myCommand.Parameters.Add(parameterCompanyID);
SqlParameter parameterProductName = new SqlParameter("@ProductName", SqlDbType.Char, 30);
parameterProductName.Value = ProductName;
myCommand.Parameters.Add(parameterProductName);
SqlParameter parameterUnitPrice = new SqlParameter("@UnitPrice", SqlDbType.Float);
parameterUnitPrice.Value = UnitPrice;
myCommand.Parameters.Add(parameterUnitPrice);
SqlParameter parameterListPrice = new SqlParameter("@ListPrice", SqlDbType.Float);
parameterListPrice.Value = ListPrice;
myCommand.Parameters.Add(parameterListPrice);
SqlParameter parameterIntroduce = new SqlParameter("@Introduce", SqlDbType.VarChar ,300);
parameterIntroduce.Value = Introduce;
myCommand.Parameters.Add(parameterIntroduce);
SqlParameter parameterUpdateTime = new SqlParameter("@UpdateTime", SqlDbType.DateTime);
parameterUpdateTime.Value = UpdateTime;
myCommand.Parameters.Add(parameterUpdateTime);
SqlParameter parameterCategoryID = new SqlParameter("@CategoryID", SqlDbType.Int);
parameterCategoryID.Value = CategoryID;
myCommand.Parameters.Add(parameterCategoryID);
SqlParameter parameterImageData = new SqlParameter("@ImageData ", SqlDbType.Image);
parameterImageData.Value = ImageData ;
myCommand.Parameters.Add(parameterImageData );
SqlParameter parameterStatusID = new SqlParameter("@StatusID", SqlDbType.Int);
parameterStatusID.Value = StatusID;
myCommand.Parameters.Add(parameterStatusID);
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] ... 下一页 >>
ASP+SQL SERVER2000电子商城系统 第18页下载如图片无法显示或论文不完整,请联系qq752018766