Ejemplo n.º 1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(VipSoft.Model.Goods model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(VipSoft.Model.Goods model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 3
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            if (!CheckInput())
                return;
            VipSoft.BLL.Goods bllGoods = new BLL.Goods();
            VipSoft.Model.Goods model = new Model.Goods();
            model.GoodsCode=this.textBox_GoodsCode.Text.Trim();
            model.Name = this.textBox_GoodsName.Text.Trim();
            model.NameCode = this.textBox_NameCode.Text.Trim();
            model.ClassID = int.Parse(this.comboBox_Class.SelectedValue.ToString());
            model.Unit = this.comboBox_Unit.Text == null ? this.comboBox_Unit.SelectedItem.ToString() : this.comboBox_Unit.Text;
            model.Number = int.Parse(this.textBox_Number.Text);
            model.Point = int.Parse(this.textBox_Point.Text);
            model.Price = decimal.Parse(this.textBox_Price.Text.Replace("¥", ""));
            model.BuyPrice = decimal.Parse(this.myMoneyTextBox1.Text.Replace("¥", ""));
            model.MinPercent = decimal.Parse(this.textBox_MinPercent.Text);
            model.PointType = int.Parse(this.rdoIsPoint.Checked ? "1" : "0");
            model.GoodsType = this.checkBox_GoodsType.Checked?(byte)0:(byte)1;
            model.ShopID = PublicState.Master.ShopID;
            model.ShopName = PublicState.Master.ShopName;
            if (CurrentGoodsID == 0)
            {
                if (bllGoods.Exists(this.textBox_GoodsCode.Text.Trim()))
                {
                    MessageBox.Show("编号为" + this.textBox_GoodsCode.Text + "的产品或服务已经存在,请重新输入编号或增加其他的产品。");
                    this.textBox_GoodsCode.Focus();
                    this.textBox_GoodsCode.SelectAll();
                }
                if (bllGoods.Add(model) > 0)
                {
                    // 加入日志
                    VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog();
                    log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品入库",
                        string.Format("产品添加,编号:{0}名称:{1}数量:{2}", model.GoodsCode, this.textBox_GoodsName.Text, this.textBox_Number.Text),
                        DateTime.Now));
                    // 提示
                    MessageBox.Show("产品添加成功。");
                    // 刷新
                    if (GoodsListRefresh != null)
                        GoodsListRefresh();
                }
                else
                {
                    MessageBox.Show("产品添加失败,请重试。");
                    return;
                }
            }
            else
            {
                model.ID = CurrentGoodsID;
                if (bllGoods.Update(model))
                {
                    // 日志记录
                    VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog();
                    log.Add(new VipSoft.Model.SysLog(PublicState.Master, "产品信息修改", "修改产品信息(编号:" + this.textBox_GoodsCode.Text + " 名称:" + this.textBox_GoodsName.Text + ")", DateTime.Now));
                    // 提示
                    MessageBox.Show("产品信息修改成功。");
                    // 刷新
                    if (GoodsListRefresh != null)
                        GoodsListRefresh();
                }
                else
                {
                    MessageBox.Show("产品信息修改失败,请重试。");
                    return;
                }
            }

            // 窗口处理
            if (this.checkBox_save.Checked)
            {
                this.checkBox_AutoCode.Checked = false;
                this.textBox_GoodsCode.Text = "";
                this.textBox_GoodsName.Text = "";
                this.textBox_Number.Text = "0";
                this.textBox_Point.Text = "0";
                this.textBox_MinPercent.Text = "0";
                this.textBox_Price.Text = "¥0.00";
                this.myMoneyTextBox1.Text = "¥0.00";
                this.textBox_MinPercent.Text = "0";
            }
            else
                this.Close();
        }