Beispiel #1
0
        private void OnExport()
        {
            if (SaleList == null || !SaleList.Any())
            {
                MvvmUtility.ShowMessageAsync("没有要导出的销售单");
                return;
            }

            var columnDefinitions = new List <ColumnDefinition <SaleDto> >
            {
                new ColumnDefinition <SaleDto>("订单号", dto => dto.OrderNo),
                new ColumnDefinition <SaleDto>("销售单号", dto => dto.SaleOrderNo),
                new ColumnDefinition <SaleDto>("渠道订单号", dto => dto.TransNo),
                new ColumnDefinition <SaleDto>("订单渠道", dto => dto.OrderSource),
                new ColumnDefinition <SaleDto>("销售状态", dto => dto.SaleStatus),
                new ColumnDefinition <SaleDto>("销售单状态", dto => dto.StatusName),
                new ColumnDefinition <SaleDto>("收银状态", dto => dto.CashStatusName),
                new ColumnDefinition <SaleDto>("销售时间", dto => dto.SellDate),
                new ColumnDefinition <SaleDto>("销售单金额", dto => dto.SalesAmount),
                new ColumnDefinition <SaleDto>("销售单数量", dto => dto.SalesCount),
                new ColumnDefinition <SaleDto>("门店", dto => dto.StoreName),
                new ColumnDefinition <SaleDto>("收银流水号", dto => dto.CashNum),
                new ColumnDefinition <SaleDto>("收银时间", dto => dto.CashDate)
            };

            ExcelUtility.Export(SaleList, columnDefinitions, "销售单");
        }
Beispiel #2
0
 public void CommandSearchExecute()
 {
     Query();
     if (SaleList == null || !SaleList.Any())
     {
         MvvmUtility.ShowMessageAsync("没有符合条件的销售单", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 设置缺货状态
        /// </summary>
        private void OnSellOut()
        {
            List <string> salesOrderIds = SaleList.Where(n => n.SaleOrderNo == SaleSelected.SaleOrderNo).Select(e => e.SaleOrderNo).ToList();
            var           service       = AppEx.Container.GetInstance <ILogisticsService>();
            bool          succeeded     = service.SetStatusSoldOut(salesOrderIds);

            MvvmUtility.ShowMessageAsync(succeeded ? "设置缺货成功" : "设置缺货失败", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
            Query();
        }
Beispiel #4
0
        public ActionResult List(DateTime bDate, DateTime eDate)
        {
            IEnumerable <sale> SaleList;

            SaleList = SaleRepository.GetSalesByDateRange(bDate, eDate);

            ViewBag.RecordCount = SaleList.Count();

            return(View(SaleList));
        }
Beispiel #5
0
        private void OnSalesOrderPrint(bool?isRecovedPrint)
        {
            if (!PrintCommon(true, isRecovedPrint != null && isRecovedPrint.Value))
            {
                return;
            }
            //打印完 发请求设置数据库
            List <string> selectSaleIds = SaleList.Select(e => e.SaleOrderNo).ToList();
            var           iTransService = AppEx.Container.GetInstance <ILogisticsService>();

            iTransService.ExecutePrintSale(selectSaleIds);
        }
Beispiel #6
0
        /// <summary>
        /// 完成销售单打印
        /// </summary>
        public void CommandFinishExecute()
        {
            if (SaleList == null || SaleSelected == null)
            {
                MvvmUtility.ShowMessageAsync("请选择要设置打印完成状态的销售单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            List <string> selectSaleIds = SaleList.Where(e => e.SaleOrderNo == SaleSelected.SaleOrderNo).Select(e => e.SaleOrderNo).ToList();
            var           iTransService = AppEx.Container.GetInstance <ILogisticsService>();
            bool          bFalg         = iTransService.SetStatusAffirmPrintSaleFinish(selectSaleIds);

            MvvmUtility.ShowMessageAsync(bFalg ? "设置打印销售单完成成功" : "设置打印销售单失败", "提示", MessageBoxButton.OK, bFalg ? MessageBoxImage.Information : MessageBoxImage.Error);
            Query();
        }
Beispiel #7
0
        public void GetSaleByOrderId()
        {
            if (SelectOrder == null || string.IsNullOrEmpty(SelectOrder.Id.ToString()))
            {
                return;
            }
            string orderNo = string.Format("orderID={0}&pageIndex={1}&pageSize={2}", SelectOrder.OrderNo, 1, 300);

            //这个工作状态
            SaleList = AppEx.Container.GetInstance <ICustomerInquiryService>().GetSaleByOrderNo(orderNo).Result.ToList();
            if (SaleList != null && SaleList.Any())
            {
                OPC_Sale sale = SaleList.ToList()[0];
                SaleDetailList = AppEx.Container.GetInstance <ILogisticsService>().SelectSaleDetail(sale.SaleOrderNo).Result.ToList();
            }
        }
Beispiel #8
0
        public override Task <SaleList> GetSales(Empty e, ServerCallContext context)
        {
            SaleList     s            = new SaleList();
            SaleItemList SaleItemList = new SaleItemList {
                Id = -1, SaleId = -1
            };

            SaleItemList.SaleItemDetails.Add(new SaleItemDetails {
                Item = new Item {
                    Name = "Fruit", EstimatedCost = 2.5
                }
            });
            s.Sales.Add(new Sale {
                Id = -1, SaleItemList = SaleItemList
            });
            return(Task.FromResult(s));
        }
        public void QuerySalesOrderByOrderId()
        {
            if (SelectOrder == null || string.IsNullOrEmpty(SelectOrder.Id.ToString()))
            {
                return;
            }
            string orderNo = string.Format("orderID={0}&pageIndex={1}&pageSize={2}", SelectOrder.OrderNo, 1, 30);

            SaleList = AppEx.Container.GetInstance <ICustomerInquiryService>().GetSaleByOrderNo(orderNo).Result;
            MvvmUtility.WarnIfEmpty(SaleList, "销售单");
            if (SaleList != null && SaleList.Count() > 0)
            {
                OPC_Sale sale = SaleList.ToList()[0];
                SaleDetailList = AppEx.Container.GetInstance <ILogisticsService>().SelectSaleDetail(sale.SaleOrderNo).Result;
                MvvmUtility.WarnIfEmpty(SaleDetailList, "销售单明细");
            }
        }
Beispiel #10
0
        /// <summary>
        /// 物流入库确认
        /// </summary>
        private void OnInStock()
        {
            List <string> salesOrderIds = SaleList.Where(salesOrder => salesOrder.SaleOrderNo == SaleSelected.SaleOrderNo &&
                                                         ((salesOrder.OrderProductType == SalesOrderType.System && salesOrder.Status == EnumSaleOrderStatus.ShoppingGuidePickUp) ||
                                                          (salesOrder.OrderProductType == SalesOrderType.MiniIntime && !string.IsNullOrEmpty(salesOrder.CashNum)))).Select(e => e.SaleOrderNo).ToList();

            if (salesOrderIds.Count == 0)
            {
                MvvmUtility.ShowMessageAsync("销售单无法办理入库,系统商品必须是“导购已提货”,迷你银商品必须已提供补录的收银流水号", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var  service   = AppEx.Container.GetInstance <ILogisticsService>();
            bool succeeded = service.SetStatusStoreInSure(salesOrderIds);

            MvvmUtility.ShowMessageAsync(succeeded ? "销售单入库成功" : "销售单入库失败", "提示", MessageBoxButton.OK, succeeded ? MessageBoxImage.Information : MessageBoxImage.Error);

            Query();
        }
Beispiel #11
0
        private async void CannotReplenish()
        {
            if (SaleList == null || !SaleList.Any())
            {
                await MvvmUtility.ShowMessageAsync("请选择销售单", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);

                return;
            }
            var saleListSelected = SaleList.Where(e => e.IsSelected).ToList();
            var succeeded        = AppEx.Container.GetInstance <ICustomerInquiryService>().SetCannotReplenish(saleListSelected.Select(e => e.SaleOrderNo).ToList());
            await MvvmUtility.ShowMessageAsync(succeeded? "设置取销售单成功" : "设置取消销售单失败", "提示", MessageBoxButton.OK, succeeded?MessageBoxImage.Information : MessageBoxImage.Error);

            if (succeeded)
            {
                SaleList       = new List <OPC_Sale>();
                SaleDetailList = new List <OPC_SaleDetail>();
                GetSaleByOrderId();
            }
        }
Beispiel #12
0
        protected void Checkout_Click(object sender, EventArgs e)
        {
            SaleList.Visible          = true;
            totalLabel2.Visible       = true;
            TaxLabel.Visible          = true;
            subtotalLabel.Visible     = true;
            CouponTextBox.Visible     = true;
            DiscountLabel.Visible     = true;
            CheckCouponButton.Visible = true;
            Label2.Visible            = true;
            Label3.Visible            = true;
            Label6.Visible            = true;
            Label4.Visible            = true;
            Label8.Visible            = true;
            PaymentTypeDDL.Visible    = true;

            string username = User.Identity.Name;
            int    employeeid;

            if (ShoppingCartList.Items.Count == 0)
            {
                MessageUserControl.ShowInfo("Warning", "No items in current shopping cart");
            }
            else
            {
                MessageUserControl.TryRun(() =>
                {
                    ApplicationUserManager secmgr = new ApplicationUserManager(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                    EmployeeInfo info             = secmgr.User_GetEmployee(username);
                    employeeid = info.EmployeeID;
                    ShoppingCartItemController sysmgr = new ShoppingCartItemController();
                    List <UserShoppingCartItem> infos = sysmgr.List_ItemsForShoppingCart(employeeid);
                    if (infos.Count == 0)
                    {
                        MessageUserControl.ShowInfo("Warning", "No items in current shopping cart");
                    }
                    SaleList.DataSource = infos;
                    SaleList.DataBind();
                }, "Great", "Here is your chekout info");
                checkout_details();
            }
        }
Beispiel #13
0
        public bool SaveSaleInfo(SaleList objSaleList, SMMembers objSMMembers)
        {
            List <string> sqllist = new List <string>();
            string        mainsql = "insert into SalesList(SerialNum, TotalMoney, RealReceive, ReturnMoney, SalesPersonId) ";

            mainsql += "values('{0}', {1}, {2}, {3}, {4})";
            sqllist.Add(string.Format(mainsql, objSaleList.SerialNum, objSaleList.TotalMoney, objSaleList.RealReceive,
                                      objSaleList.ReturnMoney, objSaleList.SalesPersonId));
            foreach (SaleListDetail itemDetail in objSaleList.SaleListDetails)
            {
                string detailsql = "insert into SalesListDetail(SerialNum, ProductId, ProductName, UnitPrice, Discount, Quantity, SubTotalMoney) ";
                detailsql += "values('{0}','{1}', '{2}',{3}, {4}, {5}, {6})";
                detailsql  = string.Format(detailsql, itemDetail.SerialNum, itemDetail.ProductId, itemDetail.ProductName, itemDetail.UnitPrice,
                                           itemDetail.Discount, itemDetail.Quantity, itemDetail.SubTotalMoney);
                sqllist.Add(detailsql);
                string updatesql = "update ProductInventory Set TotalCount=TotalCount-{0} where ProductId='{1}'";
                updatesql = string.Format(updatesql, itemDetail.Quantity, itemDetail.ProductId);
                sqllist.Add(updatesql);
            }
            if (objSMMembers != null)
            {
                string pointsql = "update SMMembers Set Points+={0} where MemberId={1}";
                pointsql = string.Format(pointsql, objSMMembers.Points, objSMMembers.MemberId);
                sqllist.Add(pointsql);
            }

            try
            {
                return(SQLHelp.UpdateByTran(sqllist, null));
            }
            catch (SqlException ex)
            {
                throw new Exception("应用程序与数据库连接出错,具体内容: " + ex.Message);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #14
0
        public IActionResult GetSaleListOnExcel([FromQuery] string searchObject)
        {
            dynamic ret = null;

            try
            {
                SearchObject input  = JsonConvert.DeserializeObject <SearchObject>(searchObject);
                SaleList     result = GetSaleList(input);

                MemoryStream memoryStream = new MemoryStream();

                using (SpreadsheetDocument document = SpreadsheetDocument.Create(memoryStream, SpreadsheetDocumentType.Workbook))
                {
                    WorkbookPart workbookPart = document.AddWorkbookPart();
                    workbookPart.Workbook = new Workbook();

                    WorksheetPart worksheetPart = workbookPart.AddNewPart <WorksheetPart>();
                    worksheetPart.Worksheet = new Worksheet();

                    Sheets sheets = workbookPart.Workbook.AppendChild(new Sheets());

                    Sheet sheet = new Sheet()
                    {
                        Id = workbookPart.GetIdOfPart(worksheetPart), SheetId = 1, Name = "Report"
                    };

                    sheets.Append(sheet);

                    workbookPart.Workbook.Save();

                    SheetData sheetData = worksheetPart.Worksheet.AppendChild(new SheetData());

                    // Constructing header
                    DocumentFormat.OpenXml.Spreadsheet.Row row = new DocumentFormat.OpenXml.Spreadsheet.Row();

                    row.Append(
                        ConstructCell("From", CellValues.String),
                        ConstructCell(input.FromDate.ToString("dd/MM/yyyy"), CellValues.String),
                        ConstructCell("To", CellValues.String),
                        ConstructCell(input.ToDate.ToString("dd/MM/yyyy"), CellValues.String));

                    sheetData.AppendChild(row);
                    sheetData.AppendChild(new DocumentFormat.OpenXml.Spreadsheet.Row());

                    DocumentFormat.OpenXml.Spreadsheet.Row heading = new DocumentFormat.OpenXml.Spreadsheet.Row();

                    heading.Append(
                        ConstructCell("BillNo", CellValues.String),
                        ConstructCell("Customer", CellValues.String),
                        ConstructCell("Amount (Rs)", CellValues.String),
                        ConstructCell("Date(DD/MM/YYYY)", CellValues.String));

                    // Insert the header row to the Sheet Data
                    sheetData.AppendChild(heading);

                    // Inserting each employee
                    foreach (var eachSale in result.Sales)
                    {
                        row = new DocumentFormat.OpenXml.Spreadsheet.Row();

                        row.Append(
                            ConstructCell(eachSale.BillId, CellValues.Number),
                            ConstructCell(eachSale.Customer.Name, CellValues.String),
                            ConstructCell(eachSale.RoundOffTotal.ToString(), CellValues.Number),
                            ConstructCell(eachSale.BillDate.ToString("dd/MM/yyyy"), CellValues.String));

                        sheetData.AppendChild(row);
                    }
                    worksheetPart.Worksheet.Save();
                }
                memoryStream.Position = 0;
                ret = new FileStreamResult(memoryStream, "application/octet-stream");
            }
            catch (Exception ex)
            {
            }
            return(ret);
        }
Beispiel #15
0
        private SaleList GetSaleList(SearchObject input)
        {
            SaleList result = new SaleList();

            try
            {
                Expression <Func <Sale, object> >[] exp = new Expression <Func <Sale, object> >[] { x => x.SalePayments, x => x.SaleDetails, x => x.Customer };
                var predicate = PredicateBuilder.True <Sale>();
                predicate = predicate.And(x => !x.IsDeleted);

                if (input.SaleIds != null && input.SaleIds.Count > 0)
                {
                    predicate = predicate.And(x => input.SaleIds.Contains(x.Id));
                }
                else
                {
                    if (input.FromDate != null)
                    {
                        predicate = predicate.And(x => x.BillDate.Date >= input.FromDate.Date);
                    }

                    if (input.ToDate != null)
                    {
                        predicate = predicate.And(x => x.BillDate.Date <= input.ToDate.Date);
                    }
                }

                if (!string.IsNullOrWhiteSpace(input.BillIds))
                {
                    try
                    {
                        var billIds = input.BillIds.Split(',').ToList().ConvertAll(c => c.ToUpper().Trim());
                        if (billIds.Count == 1)
                        {
                            billIds = input.BillIds.Split(':').ToList().ConvertAll(c => c.ToUpper().Trim());

                            if (billIds.Count == 2)
                            {
                                long billStart = Convert.ToInt64(billIds[0].Split('-')[1]);
                                long billEnd   = Convert.ToInt64(billIds[1].Split('-')[1]);
                                billIds.Clear();

                                string billInitial   = _configuration["Configuration:BillInitial"];
                                string billSeperator = _configuration["Configuration:BillSeperator"];

                                while (billStart <= billEnd)
                                {
                                    billIds.Add(billInitial + billSeperator + billStart);
                                    billStart++;
                                }
                            }
                        }
                        predicate = predicate.And(x => billIds.Contains(x.BillId.ToUpper().Trim()));
                    }
                    catch (Exception)
                    {
                    }
                }
                if (input.CustomerIds != null && input.CustomerIds.Count > 0)
                {
                    predicate = predicate.And(x => input.CustomerIds.Contains(x.FK_CustomerId));
                }

                result.Sales = _saleOpp.GetAllUsingExpression(out int totalCount, 1, 0, predicate, null, null, exp).OrderByDescending(x => x.Id).ToList();

                var predicateProd = PredicateBuilder.True <Product>();
                predicateProd = predicateProd.And(x => !x.IsDeleted);
                var productList = _productOpp.GetAllUsingExpression(out int total, 1, 0, predicateProd).ToList();

                //nullifying to avoid object chain

                if (result.Sales != null)
                {
                    result.Sales.ForEach(x =>
                    {
                        if (x.SaleDetails != null)
                        {
                            x.SaleDetails.ForEach(y =>
                            {
                                y.Sale    = null;
                                y.Product = productList.Where(p => p.Id == y.FK_ProductId).FirstOrDefault();
                            });
                        }

                        if (x.SalePayments != null)
                        {
                            x.SalePayments.ForEach(y => { y.Sale = null; x.TotalPaid = x.TotalPaid + y.Amount; });
                        }
                        if (x.Customer != null)
                        {
                            x.Customer.Sales = null;
                        }

                        x.Due = Math.Round(x.RoundOffTotal - x.TotalPaid, 2);
                    });
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Beispiel #16
0
        private void Balance()
        {
            FrmBalance objFrmBalance = new FrmBalance(this.lblTotalMoney.Text.Trim());

            if (objFrmBalance.ShowDialog() != DialogResult.OK)
            {
                if (objFrmBalance.Tag.ToString() == "F4")//用户放弃本次购买
                {
                    //重新生成流水号等待结算下一个客户
                    RestForm();
                }
                else if (objFrmBalance.Tag.ToString() == "F5")//用户放弃部分商品购买
                {
                    this.txtProductId.Focus();
                }
            }
            else //进入正式结算,获取用户的实付金额和会员卡
            {
                SMMembers objSMM = null;
                if (objFrmBalance.Tag.ToString().Contains('|'))//如果有会员卡号
                {
                    string[] info = objFrmBalance.Tag.ToString().Split('|');
                    this.lblReceivedMoney.Text = info[0];
                    objSMM = new SMMembers()//新建一个会员卡对象
                    {
                        MemberId = info[1],
                        Points   = (int)(Convert.ToDouble(this.lblTotalMoney.Text) / 10.0)
                    };
                }
                else
                {
                    this.lblReceivedMoney.Text = objFrmBalance.Tag.ToString();
                }
                //显示找零
                this.lblReturnMoney.Text = (Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()) -
                                            Convert.ToDecimal(this.lblTotalMoney.Text)).ToString();
                SaleList objSaleList = new SaleList()
                {
                    SerialNum     = this.lblSerialNum.Text.Trim(),
                    TotalMoney    = Convert.ToDecimal(this.lblTotalMoney.Text.Trim()),
                    RealReceive   = Convert.ToDecimal(this.lblReceivedMoney.Text.Trim()),
                    ReturnMoney   = Convert.ToDecimal(this.lblReturnMoney.Text.Trim()),
                    SalesPersonId = Program.CurrentPerson.SalesPersonId
                };
                foreach (Product item in this.productlist)
                {
                    objSaleList.SaleListDetails.Add(new SaleListDetail()
                    {
                        SerialNum     = this.lblSerialNum.Text.Trim(),
                        ProductId     = item.ProductId,
                        ProductName   = item.ProductName,
                        Quantity      = item.Quantity,
                        Discount      = item.Discount,
                        SubTotalMoney = item.SubTotal,
                        UnitPrice     = item.UnitPrice
                    });
                }
                try
                {
                    objProductService.SaveSaleInfo(objSaleList, objSMM);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("保存销售数据到数据库时发生错误" + ex.Message, "错误信息");
                    return;
                }
                this.printDocument.Print(); //打印小票
                RestForm();                 //重置窗口
            }
        }
Beispiel #17
0
 private void AddProductToSaleList(SimpleSaleLineViewModel simpleSaleLineViewModel)
 {
     SaleList.Add(simpleSaleLineViewModel);
 }
Beispiel #18
0
 private bool CanExportExecute()
 {
     return(SaleList != null && SaleList.Any());
 }