//加载产品列表信息
private void JIAZAIchanpin(int xiaolei)
{
this.PanelPINFO.Controls.Clear();
DataBase db = new DataBase();
string sql = "select * from product where product_t=" + xiaolei;
DataTable dt = db.GetDataTable(sql);
if (dt.Rows.Count > 0)
{
this.PanelPINFO.Controls.Clear();
RadioButton[] rpn = new RadioButton[dt.Rows.Count];
for (int i = 1; i < dt.Rows.Count; i++)
{
rpn[i] = new RadioButton();
rpn[i].Text = dt.Rows[i]["product_n"].ToString();
rpn[i].ID = "p" + dt.Rows[i]["product_id"].ToString();
rpn[i].GroupName = "pro";
rpn[i].AutoPostBack = true;
rpn[i].CheckedChanged += new EventHandler(rpn_CheckedChanged);
PanelPINFO.Controls.Add(rpn[i]);
}
}
}
//点击自动生成的商品列表里面的任意一个商品名称
private void rpn_CheckedChanged(object sender, EventArgs e)
{
RadioButton rb = (RadioButton)sender;
Session["pmpid"] = rb.ID.ToString().Substring(1);
DataBase db2 = new DataBase();
string sql2 = "select * from product_info where product_id=" + Convert.ToInt32(Session["pmpid"]);
DataTable dt2 = db2.GetDataTable(sql2);
DDLsmalltype.SelectedValue = dt2.Rows[0]["product_t"].ToString();
Txtcount.Text = dt2.Rows[0]["product_count"].ToString();
Txtpdescribe.Text = dt2.Rows[0]["product_d"].ToString();
Txtpname.Text = dt2.Rows[0]["product_n"].ToString();
Txtsellprice.Text = dt2.Rows[0]["product_sell_price"].ToString();
Imgproduct.ImageUrl = dt2.Rows[0]["product_i"].ToString();
Txtyjcount.Text = dt2.Rows[0]["product_yjcount"].ToString();
Txtzhibao.Text = dt2.Rows[0]["product_zhibao"].ToString();
DDLdanwei.SelectedValue = dt2.Rows[0]["product_danwei"].ToString();
}
//对产品信息进行更新,相当于点击按钮B
protected void BtnUpdate_Click(object sender, EventArgs e)
{
Productcs pcs = new Productcs();
pcs.productname = Txtpname.Text.ToString();
pcs.productid = Convert.ToInt32(Session["pmpid"]);
pcs.productt =Convert .ToInt32 (DDLsmalltype .SelectedValue );
pcs.product_sellp =Convert.ToDouble(Txtsellprice .Text.ToString ());
pcs.product_yj = Convert.ToInt32(Txtyjcount.Text.ToString());
pcs.producti = "~/productimage/" + Session["pmpid"].ToString() + ".jpg";
pcs.productd = Txtpdescribe.Text.ToString();
pcs.product_danwei = Convert.ToInt32(DDLdanwei.SelectedValue);//数量单位
try
{
pcs.product_zhibao = Convert.ToInt32(Txtzhibao.Text.ToString());//质保月份
}
catch { }
if (FUimage.FileName != "")
{
try
{
string fileadress = Server.MapPath("~//productimage//") + Session["pmpid"].ToString() + ".jpg";
File.Delete(fileadress);
}
catch { }
imagename = Session["pmpid"].ToString();
UpdateImage();
}
bool suc = pcs.UpdateProduct(pcs);
if (suc)
{
Session["pmpid"] = null;
Session["pmtid"] = null;
Response.Write("<script>alert('商品信息更新成功!');window.location.href ='productmanage.aspx'</script>");
}
else
{
}
}