Esempio n. 1
0
        /// <summary>
        /// 获取商品销售单视图
        /// </summary>
        /// <returns></returns>
        public IEnumerable <GoodsSellNoteVM> GetGoodsSellNote()
        {
            GoodsSellNote       note = new GoodsSellNote();
            Employee            emp  = new Employee();
            CustomerContactInfo cst  = new CustomerContactInfo();
            OQL joinQ = OQL.From(note)
                        .InnerJoin(emp).On(note.SalesmanID, emp.WorkNumber)
                        .InnerJoin(cst).On(note.CustomerID, cst.CustomerID)
                        .Select(note.NoteID, cst.CustomerName, note.ManchinesNumber, emp.EmployeeName, note.SalesType, note.SellDate)
                        .OrderBy(note.NoteID, "desc")
                        .END;

            PWMIS.DataProvider.Data.AdoHelper db = PWMIS.DataProvider.Adapter.MyDB.GetDBHelper();
            EntityContainer ec = new EntityContainer(joinQ, db);

            ec.Execute();
            //可以使用下面的方式获得各个成员元素列表
            //var noteList = ec.Map<GoodsSellNote>().ToList();
            //var empList = ec.Map<Employee>().ToList();
            //var cstList = ec.Map<CustomerContactInfo>().ToList();
            //直接使用下面的方式获得新的视图对象
            var result = ec.Map <GoodsSellNoteVM>(e =>
            {
                e.NoteID          = ec.GetItemValue <int>(0);
                e.CustomerName    = ec.GetItemValue <string>(1);
                e.ManchinesNumber = ec.GetItemValue <string>(2);
                e.EmployeeName    = ec.GetItemValue <string>(3);
                e.SalesType       = ec.GetItemValue <string>(4);
                e.SellDate        = ec.GetItemValue <DateTime>(5);
                return(e);
            }
                                                  );

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 等待并对所有客户收银(循环等待模式)
        /// </summary>
        public void CashierRegister()
        {
            //队伍过来,按先后顺序挨个收银喽
            do
            {
                if (customerQueue.Count > 0)
                {
                    var customer = customerQueue.Dequeue();
                    //收银,如果客户同意付款
                    if (this.CurrCashier.CashRegister(customer))
                    {
                        //收款
                        if (Gathering(this.CurrCRManchines.ShowAmount()))
                        {
                            //写入销售记录
                            GoodsSellNote note = SaveSalesInfo(customer, 0);
                            //打印销售回单
                            PrintSalesNote(note, customer);

                            Console.Write(customer.SalesNote);
                        }
                    }
                }
                else
                {
                    Console.WriteLine("收银台空闲,等待顾客中...");
                    System.Threading.Thread.Sleep(10000);
                }
            } while (true);
        }
Esempio n. 3
0
        private void PrintSalesNote(GoodsSellNote note, Customer customer)
        {
            System.Text.StringBuilder sb = new StringBuilder();
            sb.Append("\r\n=======销售单信息=========================");
            sb.Append("\r\n流水号:" + note.NoteID.ToString("N8"));
            sb.Append("\r\n客户号:" + note.CustomerID);
            sb.Append("\r\n终端号:" + note.ManchinesNumber);
            sb.Append("\r\n销售员:" + note.SalesmanID);
            sb.Append("\r\n日  期:" + note.SellDate);
            sb.Append("\r\n------- 销售明细--------------------------");
            sb.Append("\r\n商品名称|\t单价    |\t数量    |\t价格    ");
            sb.Append("\r\n------------------------------------------");

            int allIntegral = 0;

            foreach (Goods goods in customer.Goodss)
            {
                sb.Append("\r\n" + goods.GoodsName);
                sb.Append("\t\t" + goods.GoodsPrice.ToString("c"));
                sb.Append("\t" + goods.GoodsNumber);
                sb.Append("\t" + (goods.GoodsPrice * goods.GoodsNumber).ToString("c"));
                allIntegral += goods.Integral;
            }
            sb.Append("\r\n------------------------------------------");
            sb.Append("\r\n金额合计:" + this.CurrCRManchines.ShowAmount().ToString("c"));
            sb.Append("\r\n");
            if (allIntegral > 0)
            {
                sb.Append("本次消费可以获得的积分:" + allIntegral);
            }

            customer.SalesNote = sb.ToString();
        }
Esempio n. 4
0
        /// <summary>
        /// (待客户确认后的)收银处理
        /// </summary>
        public void Processing()
        {
            if (this.processingCustomer != null)
            {
                if (this.CurrCashier.CashRegister(this.processingCustomer))
                {
                    //收款
                    if (Gathering(this.CurrCRManchines.ShowAmount()))
                    {
                        //本次销售可获得的总积分
                        int allIntegral = this.processingCustomer.Goodss.Sum(p => p.Integral);

                        //写入销售记录
                        GoodsSellNote note = SaveSalesInfo(this.processingCustomer, allIntegral);
                        //打印销售回单
                        PrintSalesNote(note, this.processingCustomer);

                        Console.Write(this.processingCustomer.SalesNote);
                    }
                }
                this.processingCustomer.Goodss.Clear();
            }

            if (customerQueue.Count > 0)
            {
                //准备进行下一个客户的处理
                this.processingCustomer = customerQueue.Dequeue();
            }
            else
            {
                this.processingCustomer = null;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 保存销售信息
        /// </summary>
        /// <param name="customer">客户信息</param>
        /// <param name="integral">要增加的积分</param>
        /// <returns></returns>
        private GoodsSellNote SaveSalesInfo(Customer customer, int integral)
        {
            GoodsSellNote note = new GoodsSellNote();

            note.CustomerID       = customer.CustomerID;
            note.ManchinesNumber  = this.CurrCRManchines.CashRegisterNo;
            note.SalesmanID       = this.CurrCashier.WorkNumber;
            note.SalesType        = "店内销售";
            note.SellDate         = DateTime.Now;
            note.GoodsSellDetails = new List <GoodsSellDetail>();

            AdoHelper db = MyDB.GetDBHelper();

            db.BeginTransaction();
            try
            {
                EntityQuery <GoodsSellNote> query = new EntityQuery <GoodsSellNote>(db);
                if (query.Insert(note) > 0)
                {
                    foreach (Goods goods in customer.Goodss)
                    {
                        if (goods.GoodsNumber > 0)
                        {
                            //处理详单
                            GoodsSellDetail detail = new GoodsSellDetail();
                            detail.GoodsPrice   = goods.GoodsPrice;
                            detail.NoteID       = note.NoteID;
                            detail.SellNumber   = goods.GoodsNumber;
                            detail.SerialNumber = goods.SerialNumber;

                            note.GoodsSellDetails.Add(detail);

                            //更新库存
                            SuperMarketDAL.Entitys.GoodsStock stock = new SuperMarketDAL.Entitys.GoodsStock();
                            stock.GoodsID = goods.GoodsID;
                            stock.Stocks  = goods.GoodsNumber;

                            OQL q = OQL.From(stock)
                                    .UpdateSelf('-', stock.Stocks)
                                    .Where(stock.GoodsID)
                                    .END;
                            EntityQuery <SuperMarketDAL.Entitys.GoodsStock> .ExecuteOql(q, db);
                        }
                    }

                    EntityQuery <GoodsSellDetail> queryDetail = new EntityQuery <GoodsSellDetail>(db);
                    queryDetail.Insert(note.GoodsSellDetails);

                    //更新会员的积分
                    if (integral > 0)
                    {
                        SuperMarketDAL.Entitys.CustomerContactInfo ccInfo = new CustomerContactInfo();
                        ccInfo.CustomerID = customer.CustomerID;
                        ccInfo.Integral   = integral;
                        OQL qc = OQL.From(ccInfo)
                                 .UpdateSelf('+', ccInfo.Integral)
                                 .Where(ccInfo.CustomerID)
                                 .END;
                        EntityQuery <SuperMarketDAL.Entitys.GoodsStock> .ExecuteOql(qc, db);
                    }
                }
                db.Commit();
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw new Exception("插入销售记录失败,内部错误原因:" + ex.Message);
            }
            return(note);
        }