當單擊確定按鈕後會觸發btnOK_Click事件其主要代碼如程序所示
程序 ST_ProductAddaspxcs
protected void btnOK_Click(object sender SystemEventArgs e)
{
ST_BookBizST_Product st_product = new
STGROUPST_BookBizST_Product()
st_entityST_ProductName = txtNameText;
st_entityST_Price = floatParse(txtPriceTextTrim())
st_entityST_SoldPrice = floatParse(txtSoldPriceTextTrim())
st_entityST_Publisher = txtPublisherTextTrim()
st_entityST_ISBN = txtISBNTextTrim()
st_entityST_Page = intParse(txtPageTextTrim())
st_entityST_PublishDate =
DateTimeParse(txtPublishDateTextTrim())
st_entityST_ClassID =
intParse(RequestQueryString[st_classid])
st_entityST_Author = txtAuthorTextTrim()
if(Request[Action]==add)//添加圖書
{
st_entityST_IsSelling = true;
st_entityST_ProductID = st_product
InsertProduct(st_entity)
if (txtFilePostedFileContentLength > )
{
txtFilePostedFileSaveAs(
ST_BookBizST_UtilityST_ImagePhyPath +
st_entityST_ProductID + jpg)
}
st_productUpdateProductImg
(st_entityST_ProductID + jpg
st_entityST_ProductID)
}
else//更新圖書
{
st_entityST_ProductID = intParse(Request[id])
st_entityst_entityST_Image =
st_entityST_ProductID + jpg;
if (txtFilePostedFileContentLength > )
{
txtFilePostedFileSaveAs(
ST_BookBizST_UtilityST_ImagePhyPath +
st_entityST_ProductID + jpg)
}
st_productUpdateProduct(st_entity)
}
string str = <script language=javascript>alert(更新成功
)windowclose()</script>;
ResponseWrite(str)
}
【代碼說明】代碼第行進行判斷如果上個頁面傳來的Action的值為add則進行插入操作否則執行更新操作
返回目錄ASPNET項目開發指南
編輯推薦
ASPNET MVC 框架揭秘
ASPNET開發寶典
ASP NET開發培訓視頻教程
[] []
From:http://tw.wingwit.com/Article/program/net/201311/15830.html