Beispiel #1
0
        /// <summary>
        /// 绑定编辑商品的详细信息
        /// </summary>
        private void BindGoodsTest()
        {
            goods = new VipSoft.BLL.Goods();
            gs = new VipSoft.Model.Goods();
            gs = goods.GetModel(GoodsID);

            lblGoodsCode.Text = gs.GoodsCode;
            lblGoodsName.Text = gs.Name;
            lblUnitType.Text = gs.Unit;
            // lblRemark.Text = gs.Remark;
            lblNameCode.Text = gs.NameCode;
            // lblRemark.Text = gs.Remark;
            lblNameCode.Text = gs.NameCode;

            lblBuyPrice.Text = gs.BuyPrice.ToString(); //参考进价
            lblNumber.Text = gs.Number.ToString();     //当前库存
            //  txtReferencePrice.Text = gs.BuyPrice.ToString("¥0.00");
            if (goodsModify == null)  //不是修改商品
            {

                this.txtReferencePrice.Text = ((decimal)gs.BuyPrice).ToString("¥0.00");
            }
            else
            {
                this.txtCount.Text = _goodsNumber.ToString();
                this.txtReferencePrice.Text = _buyPrice;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VipSoft.Model.Goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Goods(");
            strSql.Append("GoodsCode,Name,NameCode,Unit,Number,SaleNumber,ClassID,Price,BuyPrice,Point,MinPercent,GoodsType,PointType,CreateDateTime,ShopID,ShopName,Remark)");
            strSql.Append(" values (");
            strSql.Append("@GoodsCode,@Name,@NameCode,@Unit,@Number,@SaleNumber,@ClassID,@Price,@BuyPrice,@Point,@MinPercent,@GoodsType,@PointType,@CreateDateTime,@ShopID,@ShopName,@Remark)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsCode",      SqlDbType.VarChar,   50),
                new SqlParameter("@Name",           SqlDbType.VarChar,   50),
                new SqlParameter("@NameCode",       SqlDbType.VarChar,   50),
                new SqlParameter("@Unit",           SqlDbType.VarChar,   20),
                new SqlParameter("@Number",         SqlDbType.Int,        4),
                new SqlParameter("@SaleNumber",     SqlDbType.Int,        4),
                new SqlParameter("@ClassID",        SqlDbType.Int,        4),
                new SqlParameter("@Price",          SqlDbType.Money,      8),
                new SqlParameter("@BuyPrice",       SqlDbType.Money,      8),
                new SqlParameter("@Point",          SqlDbType.Int,        4),
                new SqlParameter("@MinPercent",     SqlDbType.Float,      8),
                new SqlParameter("@GoodsType",      SqlDbType.Bit,        1),
                new SqlParameter("@PointType",      SqlDbType.Int,        4),
                new SqlParameter("@CreateDateTime", SqlDbType.DateTime),
                new SqlParameter("@ShopID",         SqlDbType.Int,        4),
                new SqlParameter("@ShopName",       SqlDbType.VarChar,   50),
                new SqlParameter("@Remark",         SqlDbType.VarChar, 1000)
            };
            parameters[0].Value  = model.GoodsCode;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.NameCode;
            parameters[3].Value  = model.Unit;
            parameters[4].Value  = model.Number;
            parameters[5].Value  = model.SaleNumber;
            parameters[6].Value  = model.ClassID;
            parameters[7].Value  = model.Price;
            parameters[8].Value  = model.BuyPrice;
            parameters[9].Value  = model.Point;
            parameters[10].Value = model.MinPercent;
            parameters[11].Value = model.GoodsType;
            parameters[12].Value = model.PointType;
            parameters[13].Value = model.CreateDateTime;
            parameters[14].Value = model.ShopID;
            parameters[15].Value = model.ShopName;
            parameters[16].Value = model.Remark;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.Goods GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,GoodsCode,Name,NameCode,Unit,Number,SaleNumber,ClassID,Price,BuyPrice,Point,MinPercent,GoodsType,PointType,CreateDateTime,ShopID,ShopName,Remark from Goods ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.Goods model = new VipSoft.Model.Goods();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.Goods DataRowToModel(DataRow row)
 {
     VipSoft.Model.Goods model=new VipSoft.Model.Goods();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["GoodsCode"]!=null)
         {
             model.GoodsCode=row["GoodsCode"].ToString();
         }
         if(row["Name"]!=null)
         {
             model.Name=row["Name"].ToString();
         }
         if(row["NameCode"]!=null)
         {
             model.NameCode=row["NameCode"].ToString();
         }
         if(row["Unit"]!=null)
         {
             model.Unit=row["Unit"].ToString();
         }
         if(row["Number"]!=null && row["Number"].ToString()!="")
         {
             model.Number=int.Parse(row["Number"].ToString());
         }
         if(row["SaleNumber"]!=null && row["SaleNumber"].ToString()!="")
         {
             model.SaleNumber=int.Parse(row["SaleNumber"].ToString());
         }
         if(row["ClassID"]!=null && row["ClassID"].ToString()!="")
         {
             model.ClassID=int.Parse(row["ClassID"].ToString());
         }
         if(row["Price"]!=null && row["Price"].ToString()!="")
         {
             model.Price=decimal.Parse(row["Price"].ToString());
         }
         if(row["BuyPrice"]!=null && row["BuyPrice"].ToString()!="")
         {
             model.BuyPrice=decimal.Parse(row["BuyPrice"].ToString());
         }
         if(row["Point"]!=null && row["Point"].ToString()!="")
         {
             model.Point=int.Parse(row["Point"].ToString());
         }
         if(row["MinPercent"]!=null && row["MinPercent"].ToString()!="")
         {
             model.MinPercent=decimal.Parse(row["MinPercent"].ToString());
         }
         if(row["GoodsType"]!=null && row["GoodsType"].ToString()!="")
         {
             if((row["GoodsType"].ToString()=="1")||(row["GoodsType"].ToString().ToLower()=="true"))
             {
                 model.GoodsType=true;
             }
             else
             {
                 model.GoodsType=false;
             }
         }
         if(row["PointType"]!=null && row["PointType"].ToString()!="")
         {
             model.PointType=int.Parse(row["PointType"].ToString());
         }
         if(row["CreateDateTime"]!=null && row["CreateDateTime"].ToString()!="")
         {
             model.CreateDateTime=DateTime.Parse(row["CreateDateTime"].ToString());
         }
         if(row["ShopID"]!=null && row["ShopID"].ToString()!="")
         {
             model.ShopID=int.Parse(row["ShopID"].ToString());
         }
         if(row["ShopName"]!=null)
         {
             model.ShopName=row["ShopName"].ToString();
         }
         if(row["Remark"]!=null)
         {
             model.Remark=row["Remark"].ToString();
         }
     }
     return model;
 }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.Goods GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,GoodsCode,Name,NameCode,Unit,Number,SaleNumber,ClassID,Price,BuyPrice,Point,MinPercent,GoodsType,PointType,CreateDateTime,ShopID,ShopName,Remark from Goods ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.Goods model=new VipSoft.Model.Goods();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
Beispiel #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.Goods DataRowToModel(DataRow row)
 {
     VipSoft.Model.Goods model = new VipSoft.Model.Goods();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["GoodsCode"] != null)
         {
             model.GoodsCode = row["GoodsCode"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["NameCode"] != null)
         {
             model.NameCode = row["NameCode"].ToString();
         }
         if (row["Unit"] != null)
         {
             model.Unit = row["Unit"].ToString();
         }
         if (row["Number"] != null && row["Number"].ToString() != "")
         {
             model.Number = int.Parse(row["Number"].ToString());
         }
         if (row["SaleNumber"] != null && row["SaleNumber"].ToString() != "")
         {
             model.SaleNumber = int.Parse(row["SaleNumber"].ToString());
         }
         if (row["ClassID"] != null && row["ClassID"].ToString() != "")
         {
             model.ClassID = int.Parse(row["ClassID"].ToString());
         }
         if (row["Price"] != null && row["Price"].ToString() != "")
         {
             model.Price = decimal.Parse(row["Price"].ToString());
         }
         if (row["BuyPrice"] != null && row["BuyPrice"].ToString() != "")
         {
             model.BuyPrice = decimal.Parse(row["BuyPrice"].ToString());
         }
         if (row["Point"] != null && row["Point"].ToString() != "")
         {
             model.Point = int.Parse(row["Point"].ToString());
         }
         if (row["MinPercent"] != null && row["MinPercent"].ToString() != "")
         {
             model.MinPercent = decimal.Parse(row["MinPercent"].ToString());
         }
         if (row["GoodsType"] != null && row["GoodsType"].ToString() != "")
         {
             if ((row["GoodsType"].ToString() == "1") || (row["GoodsType"].ToString().ToLower() == "true"))
             {
                 model.GoodsType = true;
             }
             else
             {
                 model.GoodsType = false;
             }
         }
         if (row["PointType"] != null && row["PointType"].ToString() != "")
         {
             model.PointType = int.Parse(row["PointType"].ToString());
         }
         if (row["CreateDateTime"] != null && row["CreateDateTime"].ToString() != "")
         {
             model.CreateDateTime = DateTime.Parse(row["CreateDateTime"].ToString());
         }
         if (row["ShopID"] != null && row["ShopID"].ToString() != "")
         {
             model.ShopID = int.Parse(row["ShopID"].ToString());
         }
         if (row["ShopName"] != null)
         {
             model.ShopName = row["ShopName"].ToString();
         }
         if (row["Remark"] != null)
         {
             model.Remark = row["Remark"].ToString();
         }
     }
     return(model);
 }
Beispiel #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(VipSoft.Model.Goods model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Goods set ");
            strSql.Append("GoodsCode=@GoodsCode,");
            strSql.Append("Name=@Name,");
            strSql.Append("NameCode=@NameCode,");
            strSql.Append("Unit=@Unit,");
            strSql.Append("Number=@Number,");
            strSql.Append("SaleNumber=@SaleNumber,");
            strSql.Append("ClassID=@ClassID,");
            strSql.Append("Price=@Price,");
            strSql.Append("BuyPrice=@BuyPrice,");
            strSql.Append("Point=@Point,");
            strSql.Append("MinPercent=@MinPercent,");
            strSql.Append("GoodsType=@GoodsType,");
            strSql.Append("PointType=@PointType,");
            strSql.Append("CreateDateTime=@CreateDateTime,");
            strSql.Append("ShopID=@ShopID,");
            strSql.Append("ShopName=@ShopName,");
            strSql.Append("Remark=@Remark");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsCode",      SqlDbType.VarChar,     50),
                new SqlParameter("@Name",           SqlDbType.VarChar,     50),
                new SqlParameter("@NameCode",       SqlDbType.VarChar,     50),
                new SqlParameter("@Unit",           SqlDbType.VarChar,     20),
                new SqlParameter("@Number",         SqlDbType.Int,          4),
                new SqlParameter("@SaleNumber",     SqlDbType.Int,          4),
                new SqlParameter("@ClassID",        SqlDbType.Int,          4),
                new SqlParameter("@Price",          SqlDbType.Money,        8),
                new SqlParameter("@BuyPrice",       SqlDbType.Money,        8),
                new SqlParameter("@Point",          SqlDbType.Int,          4),
                new SqlParameter("@MinPercent",     SqlDbType.Float,        8),
                new SqlParameter("@GoodsType",      SqlDbType.Bit,          1),
                new SqlParameter("@PointType",      SqlDbType.Int,          4),
                new SqlParameter("@CreateDateTime", SqlDbType.DateTime),
                new SqlParameter("@ShopID",         SqlDbType.Int,          4),
                new SqlParameter("@ShopName",       SqlDbType.VarChar,     50),
                new SqlParameter("@Remark",         SqlDbType.VarChar,   1000),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.GoodsCode;
            parameters[1].Value  = model.Name;
            parameters[2].Value  = model.NameCode;
            parameters[3].Value  = model.Unit;
            parameters[4].Value  = model.Number;
            parameters[5].Value  = model.SaleNumber;
            parameters[6].Value  = model.ClassID;
            parameters[7].Value  = model.Price;
            parameters[8].Value  = model.BuyPrice;
            parameters[9].Value  = model.Point;
            parameters[10].Value = model.MinPercent;
            parameters[11].Value = model.GoodsType;
            parameters[12].Value = model.PointType;
            parameters[13].Value = model.CreateDateTime;
            parameters[14].Value = model.ShopID;
            parameters[15].Value = model.ShopName;
            parameters[16].Value = model.Remark;
            parameters[17].Value = model.ID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #8
0
 /// <summary>
 /// 用于记次消费
 /// </summary>
 public TempOrderInfo(int number, int countid, VipSoft.Model.Goods ginfo)
 {
     _guid = System.Guid.NewGuid().ToString();
     _number = number;
     _countid = countid;
     _ginfo = ginfo;
 }
Beispiel #9
0
 /// <summary>
 /// 修改挂单
 /// </summary>
 public TempOrderInfo(int number, decimal percent, VipSoft.Model.Goods ginfo)
 {
     _guid = System.Guid.NewGuid().ToString();
     _number = number;
     _ginfo = ginfo;
     _Discount = percent;
 }
Beispiel #10
0
        private void treeView_goods_DoubleClick(object sender, EventArgs e)
        {
            TreeNode node = this.treeView_goods.SelectedNode;
            if (node == null)
                return;
            if (node.Name.IndexOf("goods_") == -1)
            {
                string msg = "双击产品名称即可选择该产品,双击类别将无效。";
                this.toolTip_Tree.Show(msg, this.treeView_goods);
            }
            else
            {
                if (memInfo==null && !IsTravelerMember)
                {
                    MessageBox.Show("请先选择要消费的会员。");
                    this.searchMember1.Focus();
                    return;
                }

                int id = int.Parse(node.Name.Replace("goods_", ""));
                goodsInfo = new VipSoft.BLL.Goods().GetModel(id);
                if (goodsInfo.Number <= 0 && goodsInfo.GoodsType == (byte)0)
                {
                    MessageBox.Show("此产品暂时缺货!");
                    return;
                }

                TempOrderInfo order = GetTempOrderItem(id);
                if (order != null)
                {
                    SelectGoods(order.GInfo.GoodsCode);
                }

                order = GetTempOrderItem(id);
                if (order == null)
                {
                    goodsInfo = new VipSoft.BLL.Goods().GetModel(id);
                    if (goodsInfo == null)
                    {
                        MessageBox.Show("未找到产品,请刷新列表,然后重新选择。");
                        return;
                    }
                    this.label_Guid.Text = "";
                    BindSelectedGoods();
                    AddOrder(goodsInfo.GoodsCode);
                }
                else
                {
                    goodsInfo = order.GInfo;
                    this.label_Guid.Text = order.Guid;
                    BindSelectedGoods(order.Number);
                }

            }
        }
Beispiel #11
0
        private void SelectGoods(string goodsCode)
        {
            TempOrderInfo order = GetTempOrderItemByCode(goodsCode);
            goodsInfo = new VipSoft.BLL.Goods().GetModel(goodsCode);
            if (goodsInfo != null)
            {
                if (goodsInfo.Number <= 0 && goodsInfo.GoodsType == (byte)0)
                {
                    MessageBox.Show("库存不足!");
                    return;
                }
            }
            if (order != null)
            {
                SelectOrderItem(order);
                int selectRows = this.dataGridView_List.SelectedRows[0].Cells[0].RowIndex;
                dataGridView_List.CurrentCell = dataGridView_List[5, selectRows];
                dataGridView_List.BeginEdit(true);
                int num = int.Parse(this.dataGridView_List.Rows[selectRows].Cells["Column_Number"].Value.ToString());
                int newnum = num + 1;
                this.dataGridView_List.Rows[selectRows].Cells["Column_Number"].Value = newnum;
                dataGridView_List.EndEdit();
            }
            else
            {
                if (goodsInfo != null)
                {
                    BindSelectedGoods();
                    AddOrder(goodsCode);
                }

                else
                {
                    MessageBox.Show("未找到此产品。");
                    this.textBox_GoodsCode.Focus();
                    this.textBox_GoodsCode.SelectAll();
                }
            }
        }