//保存数据 protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { if (this.ddlGoodsCateId.SelectedValue == "") { Common.ShowMsg("请选择商品类别!"); return; } //创建用户数据表操作类对象 Goods Goods = new Goods(); if (ViewState["OperateStatus"].ToString() == "AddData") { string Goodsid = this.txtGoodsID.Text.Trim(); string GoodsName = this.txtGoodsName.Text.Trim(); string Code = this.txtCode.Text.Trim(); string Desc = this.txtDesc.Text.Trim(); string GoodsCate = this.ddlGoodsCateId.SelectedItem.Value; double Price = Convert.ToDouble(this.txtPrice.Text.Trim()); //增加用户数据 if (Goods.AddGoods(Goodsid, GoodsName, Code, Price, GoodsCate, Desc)) { Common.ShowMsg("添加成功!"); //记录操作员操作 RecordOperate.SaveRecord(Session["UserID"].ToString(), "商品管理", "增加商品信息;商品简码:" + Code); } else { return; } } if (ViewState["OperateStatus"].ToString() == "EditData") { string Goodsname = this.txtGoodsName.Text.Trim(); string Desc = this.txtDesc.Text.Trim(); string GoodsCate = this.ddlGoodsCateId.SelectedItem.Value; string GoodsId = this.txtGoodsID.Text.Trim(); double Price = Convert.ToDouble(this.txtPrice.Text.Trim()); //更新用户数据 if (Goods.UpdateGoods(GoodsId, Goodsname, Price, GoodsCate, Desc)) { Common.ShowMsg("更新成功!"); //记录操作员操作 RecordOperate.SaveRecord(Session["UserID"].ToString(), "商品管理", "商品管理 ;商品名称:" + Goodsname); } else { return; } } } Server.Transfer("GoodsManager_View.aspx?NodeId=" + this.txtId.Text + "&PageNum=" + this.txtPageIndex.Text); }