Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(VipSoft.Model.OrderLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OrderLog(");
            strSql.Append("OrderCode,OrderType,MemID,CardID,MemName,TotalNumber,TotalMoney,DisCountMoney,PayInfo,Point,CreateDateTime,PayType,MasterID,MasterName,ShopID,ShopName)");
            strSql.Append(" values (");
            strSql.Append("@OrderCode,@OrderType,@MemID,@CardID,@MemName,@TotalNumber,@TotalMoney,@DisCountMoney,@PayInfo,@Point,@CreateDateTime,@PayType,@MasterID,@MasterName,@ShopID,@ShopName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderCode",      SqlDbType.NChar,     10),
                new SqlParameter("@OrderType",      SqlDbType.Int,        4),
                new SqlParameter("@MemID",          SqlDbType.Int,        4),
                new SqlParameter("@CardID",         SqlDbType.VarChar,   50),
                new SqlParameter("@MemName",        SqlDbType.VarChar,   20),
                new SqlParameter("@TotalNumber",    SqlDbType.Int,        4),
                new SqlParameter("@TotalMoney",     SqlDbType.Money,      8),
                new SqlParameter("@DisCountMoney",  SqlDbType.Money,      8),
                new SqlParameter("@PayInfo",        SqlDbType.VarChar,   50),
                new SqlParameter("@Point",          SqlDbType.Int,        4),
                new SqlParameter("@CreateDateTime", SqlDbType.DateTime),
                new SqlParameter("@PayType",        SqlDbType.Int,        4),
                new SqlParameter("@MasterID",       SqlDbType.Int,        4),
                new SqlParameter("@MasterName",     SqlDbType.VarChar,   50),
                new SqlParameter("@ShopID",         SqlDbType.Int,        4),
                new SqlParameter("@ShopName",       SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.OrderCode;
            parameters[1].Value  = model.OrderType;
            parameters[2].Value  = model.MemID;
            parameters[3].Value  = model.CardID;
            parameters[4].Value  = model.MemName;
            parameters[5].Value  = model.TotalNumber;
            parameters[6].Value  = model.TotalMoney;
            parameters[7].Value  = model.DisCountMoney;
            parameters[8].Value  = model.PayInfo;
            parameters[9].Value  = model.Point;
            parameters[10].Value = model.CreateDateTime;
            parameters[11].Value = model.PayType;
            parameters[12].Value = model.MasterID;
            parameters[13].Value = model.MasterName;
            parameters[14].Value = model.ShopID;
            parameters[15].Value = model.ShopName;

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

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

            strSql.Append("select  top 1 ID,OrderCode,OrderType,MemID,CardID,MemName,TotalNumber,TotalMoney,DisCountMoney,PayInfo,Point,CreateDateTime,PayType,MasterID,MasterName,ShopID,ShopName from OrderLog ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.OrderLog model = new VipSoft.Model.OrderLog();
            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 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public VipSoft.Model.OrderLog GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,OrderCode,OrderType,MemID,CardID,MemName,TotalNumber,TotalMoney,DisCountMoney,PayInfo,Point,CreateDateTime,PayType,MasterID,MasterName,ShopID,ShopName from OrderLog ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

            VipSoft.Model.OrderLog model=new VipSoft.Model.OrderLog();
            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.OrderLog DataRowToModel(DataRow row)
 {
     VipSoft.Model.OrderLog model=new VipSoft.Model.OrderLog();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["OrderCode"]!=null)
         {
             model.OrderCode=row["OrderCode"].ToString();
         }
         if(row["OrderType"]!=null && row["OrderType"].ToString()!="")
         {
             model.OrderType=int.Parse(row["OrderType"].ToString());
         }
         if(row["MemID"]!=null && row["MemID"].ToString()!="")
         {
             model.MemID=int.Parse(row["MemID"].ToString());
         }
         if(row["CardID"]!=null)
         {
             model.CardID=row["CardID"].ToString();
         }
         if(row["MemName"]!=null)
         {
             model.MemName=row["MemName"].ToString();
         }
         if(row["TotalNumber"]!=null && row["TotalNumber"].ToString()!="")
         {
             model.TotalNumber=int.Parse(row["TotalNumber"].ToString());
         }
         if(row["TotalMoney"]!=null && row["TotalMoney"].ToString()!="")
         {
             model.TotalMoney=decimal.Parse(row["TotalMoney"].ToString());
         }
         if(row["DisCountMoney"]!=null && row["DisCountMoney"].ToString()!="")
         {
             model.DisCountMoney=decimal.Parse(row["DisCountMoney"].ToString());
         }
         if(row["PayInfo"]!=null)
         {
             model.PayInfo=row["PayInfo"].ToString();
         }
         if(row["Point"]!=null && row["Point"].ToString()!="")
         {
             model.Point=int.Parse(row["Point"].ToString());
         }
         if(row["CreateDateTime"]!=null && row["CreateDateTime"].ToString()!="")
         {
             model.CreateDateTime=DateTime.Parse(row["CreateDateTime"].ToString());
         }
         if(row["PayType"]!=null && row["PayType"].ToString()!="")
         {
             model.PayType=int.Parse(row["PayType"].ToString());
         }
         if(row["MasterID"]!=null && row["MasterID"].ToString()!="")
         {
             model.MasterID=int.Parse(row["MasterID"].ToString());
         }
         if(row["MasterName"]!=null)
         {
             model.MasterName=row["MasterName"].ToString();
         }
         if(row["ShopID"]!=null && row["ShopID"].ToString()!="")
         {
             model.ShopID=int.Parse(row["ShopID"].ToString());
         }
         if(row["ShopName"]!=null && row["ShopName"].ToString()!="")
         {
             model.ShopName=row["ShopName"].ToString();
         }
     }
     return model;
 }
Beispiel #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public VipSoft.Model.OrderLog DataRowToModel(DataRow row)
 {
     VipSoft.Model.OrderLog model = new VipSoft.Model.OrderLog();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["OrderCode"] != null)
         {
             model.OrderCode = row["OrderCode"].ToString();
         }
         if (row["OrderType"] != null && row["OrderType"].ToString() != "")
         {
             model.OrderType = int.Parse(row["OrderType"].ToString());
         }
         if (row["MemID"] != null && row["MemID"].ToString() != "")
         {
             model.MemID = int.Parse(row["MemID"].ToString());
         }
         if (row["CardID"] != null)
         {
             model.CardID = row["CardID"].ToString();
         }
         if (row["MemName"] != null)
         {
             model.MemName = row["MemName"].ToString();
         }
         if (row["TotalNumber"] != null && row["TotalNumber"].ToString() != "")
         {
             model.TotalNumber = int.Parse(row["TotalNumber"].ToString());
         }
         if (row["TotalMoney"] != null && row["TotalMoney"].ToString() != "")
         {
             model.TotalMoney = decimal.Parse(row["TotalMoney"].ToString());
         }
         if (row["DisCountMoney"] != null && row["DisCountMoney"].ToString() != "")
         {
             model.DisCountMoney = decimal.Parse(row["DisCountMoney"].ToString());
         }
         if (row["PayInfo"] != null)
         {
             model.PayInfo = row["PayInfo"].ToString();
         }
         if (row["Point"] != null && row["Point"].ToString() != "")
         {
             model.Point = int.Parse(row["Point"].ToString());
         }
         if (row["CreateDateTime"] != null && row["CreateDateTime"].ToString() != "")
         {
             model.CreateDateTime = DateTime.Parse(row["CreateDateTime"].ToString());
         }
         if (row["PayType"] != null && row["PayType"].ToString() != "")
         {
             model.PayType = int.Parse(row["PayType"].ToString());
         }
         if (row["MasterID"] != null && row["MasterID"].ToString() != "")
         {
             model.MasterID = int.Parse(row["MasterID"].ToString());
         }
         if (row["MasterName"] != null)
         {
             model.MasterName = row["MasterName"].ToString();
         }
         if (row["ShopID"] != null && row["ShopID"].ToString() != "")
         {
             model.ShopID = int.Parse(row["ShopID"].ToString());
         }
         if (row["ShopName"] != null && row["ShopName"].ToString() != "")
         {
             model.ShopName = int.Parse(row["ShopName"].ToString());
         }
     }
     return(model);
 }
Beispiel #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(VipSoft.Model.OrderLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update OrderLog set ");
            strSql.Append("OrderCode=@OrderCode,");
            strSql.Append("OrderType=@OrderType,");
            strSql.Append("MemID=@MemID,");
            strSql.Append("CardID=@CardID,");
            strSql.Append("MemName=@MemName,");
            strSql.Append("TotalNumber=@TotalNumber,");
            strSql.Append("TotalMoney=@TotalMoney,");
            strSql.Append("DisCountMoney=@DisCountMoney,");
            strSql.Append("PayInfo=@PayInfo,");
            strSql.Append("Point=@Point,");
            strSql.Append("CreateDateTime=@CreateDateTime,");
            strSql.Append("PayType=@PayType,");
            strSql.Append("MasterID=@MasterID,");
            strSql.Append("MasterName=@MasterName,");
            strSql.Append("ShopID=@ShopID,");
            strSql.Append("ShopName=@ShopName");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderCode",      SqlDbType.NChar,     10),
                new SqlParameter("@OrderType",      SqlDbType.Int,        4),
                new SqlParameter("@MemID",          SqlDbType.Int,        4),
                new SqlParameter("@CardID",         SqlDbType.VarChar,   50),
                new SqlParameter("@MemName",        SqlDbType.VarChar,   20),
                new SqlParameter("@TotalNumber",    SqlDbType.Int,        4),
                new SqlParameter("@TotalMoney",     SqlDbType.Money,      8),
                new SqlParameter("@DisCountMoney",  SqlDbType.Money,      8),
                new SqlParameter("@PayInfo",        SqlDbType.VarChar,   50),
                new SqlParameter("@Point",          SqlDbType.Int,        4),
                new SqlParameter("@CreateDateTime", SqlDbType.DateTime),
                new SqlParameter("@PayType",        SqlDbType.Int,        4),
                new SqlParameter("@MasterID",       SqlDbType.Int,        4),
                new SqlParameter("@MasterName",     SqlDbType.VarChar,   50),
                new SqlParameter("@ShopID",         SqlDbType.Int,        4),
                new SqlParameter("@ShopName",       SqlDbType.Int,        4),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.OrderCode;
            parameters[1].Value  = model.OrderType;
            parameters[2].Value  = model.MemID;
            parameters[3].Value  = model.CardID;
            parameters[4].Value  = model.MemName;
            parameters[5].Value  = model.TotalNumber;
            parameters[6].Value  = model.TotalMoney;
            parameters[7].Value  = model.DisCountMoney;
            parameters[8].Value  = model.PayInfo;
            parameters[9].Value  = model.Point;
            parameters[10].Value = model.CreateDateTime;
            parameters[11].Value = model.PayType;
            parameters[12].Value = model.MasterID;
            parameters[13].Value = model.MasterName;
            parameters[14].Value = model.ShopID;
            parameters[15].Value = model.ShopName;
            parameters[16].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #7
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 #8
0
        // 确认结算时
        // 订单表中插入记录、订单详细表、账户金额积分处理
        // 系统日志
        void exp_ExpenseResultSelected(OrderPayType expType, decimal payMoney, decimal payCard, decimal payCash, decimal payCredit, decimal payVoucher, decimal moneyZero)
        {
            string orderCode = CreateOrderCode();
            payInfo = payCard + "|" + payCash + "|" + payCredit + "|" + payVoucher;
            // 如果修改了金额,积分需要重新计算一下的
            int point = totalPoint;

            List<VipSoft.Model.OrderDetail> ListDetail = new List<VipSoft.Model.OrderDetail>();
            VipSoft.Model.OrderDetail detail;

            foreach (TempOrderInfo temp in listOrder)
            {
                detail = new VipSoft.Model.OrderDetail();
                detail.OrderCode=orderCode;
                detail.GoodsID=temp.GInfo.ID;
                detail.GoodsCode=temp.GInfo.GoodsCode;
                detail.GoodsName=temp.GInfo.Name;
                detail.OrderCode=orderCode;
                detail.Number=temp.Number;
                detail.Percent=temp.Discount;
                detail.IsService=temp.GInfo.GoodsType==(byte)0?true:false;
                detail.Price=temp.GInfo.Price;
                detail.DiscountPrice=temp.DiscountPrice;
                ListDetail.Add(detail);
            }
            VipSoft.BLL.OrderLog oLog = new VipSoft.BLL.OrderLog();
            bool ok;
            string logStrType, logStrOk, logStrErr;
            if (IsTravelerMember)
            {
                order = new Model.OrderLog();
                order.OrderCode = orderCode;
                order.OrderType = 0;
                order.MemID = 59;
                order.MemName = "散客消费";
                order.CardID = "0";
                order.CreateDateTime = DateTime.Now;
                order.DisCountMoney = discountPrice;
                order.MasterID = PublicState.Master.ID;
                order.MasterName = PublicState.Master.Name;
                order.PayInfo = payInfo;
                order.PayType = (int)expType;
                order.Point = totalPoint;
                order.ShopID = PublicState.Master.ShopID;
                order.ShopName = PublicState.Master.ShopName;
                order.TotalMoney = totalPrice;
                order.TotalNumber = totalNumber;

                ok = oLog.Add(order, ListDetail);

                logStrType = "散客消费";
                logStrOk = string.Format("消费成功,订单号:{0}消费金额:{1}", order.OrderCode, order.DisCountMoney);
                logStrErr = string.Format("消费失败,消费金额:{0}", order.DisCountMoney);
            }
            else
            {
                order = new Model.OrderLog();
                order.OrderCode = orderCode;
                order.OrderType = 0;
                order.MemID = memInfo.ID;
                order.MemName = memInfo.Name;
                order.CardID = memInfo.CardID;
                order.CreateDateTime = DateTime.Now;
                order.DisCountMoney = discountPrice;
                order.MasterID = PublicState.Master.ID;
                order.MasterName = PublicState.Master.Name;
                order.PayInfo = payInfo;
                order.PayType = (int)expType;
                order.Point = totalPoint;
                order.TotalMoney = totalPrice;
                order.TotalNumber = totalNumber;
                order.ShopID = PublicState.Master.ShopID;
                order.ShopName = PublicState.Master.ShopName;

                ok = oLog.Add(order, ListDetail);
                if (ok)
                {
                    VipSoft.BLL.MemCard bllMemCard = new BLL.MemCard();
                    VipSoft.BLL.PointLog bllPointLog = new BLL.PointLog();
                    memInfo.Point += totalPoint;
                    memInfo.TotalMoney += discountPrice;
                    memInfo.LastTime = DateTime.Now;
                    memInfo.Money -= payCard;
                    bllMemCard.Update(memInfo);
                    memInfo = bllMemCard.GetModel(memInfo.ID);

                    VipSoft.Model.PointLog modelPointLog = new Model.PointLog();
                    modelPointLog.CardID = memInfo.CardID;
                    modelPointLog.CreateDateTime = DateTime.Now;
                    modelPointLog.MemName = memInfo.Name;
                    modelPointLog.Point = totalPoint;
                    modelPointLog.ShopID = PublicState.Master.ShopID;
                    modelPointLog.ShopName = PublicState.Master.ShopName;
                    modelPointLog.Type = (int)PointLogType.OrderPoint;
                    bllPointLog.Add(modelPointLog);
                }

                logStrType = "会员消费";
                logStrOk = string.Format("消费成功,订单号:{0}会员卡号:{1}姓名:{2}消费金额:{3}所得积分:{4}付费方式:{5}",
                    order.OrderCode, order.CardID, order.MemName, order.DisCountMoney, order.Point, order.PayType.ToString());
                logStrErr = string.Format("消费失败,会员卡号:{0}姓名:{1}消费金额:{2}所得积分:{3}付费方式:{4}",
                    order.CardID, order.MemName, order.DisCountMoney, order.Point, order.PayType.ToString());
            }

            if (ok)
            {
                VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog();
                log.Add(new VipSoft.Model.SysLog(PublicState.Master, logStrType, logStrOk, DateTime.Now));

                // 更新当前会员的财务信息,因为打印的时候和更新等级的时候都需要显示出来
                if (!IsTravelerMember)
                {
                    memInfo = new VipSoft.BLL.MemCard().GetModel(memInfo.ID);
                    Function.UpdateMemberLevel(1, memInfo);
                }
                MessageBox.Show("消费成功。");

                // 清除数据
                this.label_OTMoney.Text = "";
                this.label_OTMoney2.Text = "";
                this.label_OTNumber.Text = "";
                this.label_OTPoint.Text = "";
                this.label_OTActivity.Text = "";
                listOrder = new List<TempOrderInfo>();
                order = null;
                this.dataGridView_List.Rows.Clear();
                ClearFormText();
                memInfo = null;
            }
            else
            {
                MessageBox.Show("系统错误导致消费失败,请重试。");
                // 记录日志
                VipSoft.BLL.SysLog log = new VipSoft.BLL.SysLog();
                log.Add(new VipSoft.Model.SysLog(PublicState.Master, logStrType,  logStrErr, DateTime.Now));
            }
        }