protected void BtnUpdate_Click(object sender, EventArgs e)
{
SaveImgeName();
string proName = this.TxtProductsName.Text.Trim(); //商品名称
int parID = Convert.ToInt32(this.TxtID.Text.Trim());
decimal proPriceA = Convert.ToDecimal(this.TxtProductsPriceA.Text.Trim()); //雅湾价格
DateTime proDate = Convert.ToDateTime(this.TxtDate.Text.Trim());
string re = this.TxtRe.Text.Trim(); //标签
string particular = this.FCKeditor1.Value; //详细介绍 string summary = this.TxtSummary.Text.Trim(); //商品摘要
int grade = this.level.SelectedIndex; //商品的星级
int pinpaiID = Convert.ToInt32(this.ddl_pinpai.SelectedValue.ToString());
string[] keyWords = this.TxtKeyWords.Text.Replace(" "," ").Split(' '); //商品的关键字
if (this.TxtID.Text == "0" || this.TxtID.Text.Trim() == "")
{
Response.Write("<script>alert('请修改类别')</script>");
这里,满足条件就是不弹提示框!谁能指点下,谢谢!~
}
int isHot = 0;
int isNew = 0;
int iSuggest = 0; //强力推荐
int isLowPrice = 0; //低价促销
int isearch = 0;
if (this.ChkHot.Checked)
{
isHot = 1; //热销产品
}
if (this.ChkNew.Checked)
{
isNew = 1; //新品
}
if (this.ChkSuggest.Checked)
{
iSuggest = 1; //强力推荐
}
if (this.ChkLowPrice.Checked)
{
isLowPrice = 1; //低价促销
}
if (this.ChkSearch.Checked)
{
isearch = 1; //搜索推荐
}
string newNames = ""; //6张商品展示图片的名字
if (ViewState["ImgeA"] != null)
{ newNames = ViewState["ImgeA"].ToString();
//Response.Write(newNames);
//Response.End();
}
if (newNames == "")
newNames = "noimg.gif";
int updateID=this.RequestPar(); ProDB updatePro = new ProDB(); //实例化商品类
//修改商品
updatePro.Pro_Data.IsTran = true; //开始事务
string[] oldKeys = null; //关键字修改前ID的数组
if (ViewState["oldKeys"] != null)
{
oldKeys = ViewState["oldKeys"].ToString().Split(' ');
}
CategoryClass cate = new CategoryClass();
try
{
updatePro.Update_Pro(updateID, proName, parID, proPriceA,proDate, newNames, grade, re, summary, particular, isHot, isNew,iSuggest,isLowPrice, isearch,pinpaiID); try
{
//if (this.TxtKeyWords.Text != "")
//{
// updatePro.DeleteKeys(updateID);
//}
DataSet dst = updatePro.SelIdByProID(updateID);
if (dst.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dst.Tables[0].Rows.Count; i++)
{
updatePro.DeleteKeys(Convert.ToInt32(dst.Tables[0].Rows[i]["Id"].ToString()));
cate.UpCount(Convert.ToInt32(dst.Tables[0].Rows[i]["Tag"].ToString()),-1);
}
}
foreach (string keys in keyWords)
{
if (keys != "")
{
DataSet ds = cate.GetCateIDByName(keys);
if (ds.Tables[0].Rows.Count == 1)
{
string key = ds.Tables[0].Rows[0][0].ToString();
updatePro.Add_Key(updateID, key);
cate.UpCount(Convert.ToInt32(key), 1);
}
else
{
updatePro.Add_Key(updateID, keys); //添加商品的关键字
}
}
}
}
catch
{
RegisterStartupScript("alert", "<script language=javascript>alert('添加失败!')</script>");
}
if (ViewState["ID"].ToString() != parID.ToString())
{
cate.UpCount(parID, 1);
cate.UpCount(Convert.ToInt32(ViewState["ID"]), -1);
} updatePro.Pro_Data.TranCommit(); //提交事务
updatePro.Pro_Data.IsTran = false; //事务完成
Response.Redirect("~/WebMain/Manage/Shop/UpdateSuccess.aspx");
}
catch
{
updatePro.Pro_Data.TranRollBack(); //事务回滚
RegisterStartupScript("alert", "<script language=javascript>alert('修改失败!')</script>");
}
}
{
SaveImgeName();
string proName = this.TxtProductsName.Text.Trim(); //商品名称
int parID = Convert.ToInt32(this.TxtID.Text.Trim());
decimal proPriceA = Convert.ToDecimal(this.TxtProductsPriceA.Text.Trim()); //雅湾价格
DateTime proDate = Convert.ToDateTime(this.TxtDate.Text.Trim());
string re = this.TxtRe.Text.Trim(); //标签
string particular = this.FCKeditor1.Value; //详细介绍 string summary = this.TxtSummary.Text.Trim(); //商品摘要
int grade = this.level.SelectedIndex; //商品的星级
int pinpaiID = Convert.ToInt32(this.ddl_pinpai.SelectedValue.ToString());
string[] keyWords = this.TxtKeyWords.Text.Replace(" "," ").Split(' '); //商品的关键字
if (this.TxtID.Text == "0" || this.TxtID.Text.Trim() == "")
{
Response.Write("<script>alert('请修改类别')</script>");
这里,满足条件就是不弹提示框!谁能指点下,谢谢!~
}
int isHot = 0;
int isNew = 0;
int iSuggest = 0; //强力推荐
int isLowPrice = 0; //低价促销
int isearch = 0;
if (this.ChkHot.Checked)
{
isHot = 1; //热销产品
}
if (this.ChkNew.Checked)
{
isNew = 1; //新品
}
if (this.ChkSuggest.Checked)
{
iSuggest = 1; //强力推荐
}
if (this.ChkLowPrice.Checked)
{
isLowPrice = 1; //低价促销
}
if (this.ChkSearch.Checked)
{
isearch = 1; //搜索推荐
}
string newNames = ""; //6张商品展示图片的名字
if (ViewState["ImgeA"] != null)
{ newNames = ViewState["ImgeA"].ToString();
//Response.Write(newNames);
//Response.End();
}
if (newNames == "")
newNames = "noimg.gif";
int updateID=this.RequestPar(); ProDB updatePro = new ProDB(); //实例化商品类
//修改商品
updatePro.Pro_Data.IsTran = true; //开始事务
string[] oldKeys = null; //关键字修改前ID的数组
if (ViewState["oldKeys"] != null)
{
oldKeys = ViewState["oldKeys"].ToString().Split(' ');
}
CategoryClass cate = new CategoryClass();
try
{
updatePro.Update_Pro(updateID, proName, parID, proPriceA,proDate, newNames, grade, re, summary, particular, isHot, isNew,iSuggest,isLowPrice, isearch,pinpaiID); try
{
//if (this.TxtKeyWords.Text != "")
//{
// updatePro.DeleteKeys(updateID);
//}
DataSet dst = updatePro.SelIdByProID(updateID);
if (dst.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dst.Tables[0].Rows.Count; i++)
{
updatePro.DeleteKeys(Convert.ToInt32(dst.Tables[0].Rows[i]["Id"].ToString()));
cate.UpCount(Convert.ToInt32(dst.Tables[0].Rows[i]["Tag"].ToString()),-1);
}
}
foreach (string keys in keyWords)
{
if (keys != "")
{
DataSet ds = cate.GetCateIDByName(keys);
if (ds.Tables[0].Rows.Count == 1)
{
string key = ds.Tables[0].Rows[0][0].ToString();
updatePro.Add_Key(updateID, key);
cate.UpCount(Convert.ToInt32(key), 1);
}
else
{
updatePro.Add_Key(updateID, keys); //添加商品的关键字
}
}
}
}
catch
{
RegisterStartupScript("alert", "<script language=javascript>alert('添加失败!')</script>");
}
if (ViewState["ID"].ToString() != parID.ToString())
{
cate.UpCount(parID, 1);
cate.UpCount(Convert.ToInt32(ViewState["ID"]), -1);
} updatePro.Pro_Data.TranCommit(); //提交事务
updatePro.Pro_Data.IsTran = false; //事务完成
Response.Redirect("~/WebMain/Manage/Shop/UpdateSuccess.aspx");
}
catch
{
updatePro.Pro_Data.TranRollBack(); //事务回滚
RegisterStartupScript("alert", "<script language=javascript>alert('修改失败!')</script>");
}
}
Response.Write("<script language='javascript'>alert('你错了');</script>")