예제 #1
0
 public SaleDetailViewModel(SaleDetail x) : base(x)
 {
     this.Product = new ProductViewModel(x.Product);
     ProductId    = x.ProductId;
     Total        = x.Total;
     Quantity     = x.Quantity;
 }
예제 #2
0
        public ActionResult Index([Bind(Include = "SaleKey,ProductKey,SaleDetailPriceCharged, SaleDetailQuantity, SaleDetailDiscount, SaleDetailSaleTaxPercent, SaleDetailEatInTax")] SaleDetail s)
        {
            try
            {
                Sale sale = new Sale();
                sale.SaleDate    = DateTime.Now;
                sale.CustomerKey = (int)Session["PersonKey"];
                sale.EmployeeKey = (int)2;
                s.Sale           = sale;


                s.SaleDetailDiscount       = (int)0;
                s.SaleDetailSaleTaxPercent = (decimal).1;
                s.SaleDetailEatInTax       = (decimal).1;
                db.SaleDetails.Add(s);
                db.SaveChanges();

                Message msg = new Message("Thank you for your purchase");
                return(RedirectToAction("Result", msg));
            }
            catch (Exception e)
            {
                Message msg = new Message();
                msg.MessageText = e.Message;
                return(RedirectToAction("Result", msg));
            }
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("SaleDetailId,SaleId,ProductId,Quantity,Discount")] SaleDetail saleDetail)
        {
            if (id != saleDetail.SaleDetailId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    saleDetail.Sale = await _context.Sales.FirstOrDefaultAsync(d => d.SaleId == saleDetail.SaleId);

                    SaleDetail oldSaleDetail = await _context.SaleDetails.FirstOrDefaultAsync(d => d.SaleDetailId == id);

                    //restar valores de detalle viejos

                    saleDetail.Sale.Quantity = saleDetail.Sale.Quantity - oldSaleDetail.Quantity;

                    saleDetail.Sale.Discount     = saleDetail.Sale.Discount - oldSaleDetail.Discount;
                    saleDetail.Sale.TotalNoITBIS = saleDetail.Sale.TotalNoITBIS - (oldSaleDetail.UnitPrice * oldSaleDetail.Quantity) - oldSaleDetail.Discount;
                    saleDetail.Sale.ITBIS        = saleDetail.Sale.ITBIS - oldSaleDetail.ITBIS;
                    saleDetail.Sale.Total        = saleDetail.Sale.Total - oldSaleDetail.Total;

                    Product product = await _context.Products.FirstOrDefaultAsync(d => d.ProductId == saleDetail.ProductId);

                    saleDetail.UserId    = User.Identity.Name;
                    saleDetail.UnitPrice = product.UnitPrice;
                    decimal _totalNoItbis = (saleDetail.Quantity * saleDetail.UnitPrice) - saleDetail.Discount;
                    saleDetail.ITBIS = _totalNoItbis * (product.ITBIS / 100);
                    saleDetail.Total = _totalNoItbis + saleDetail.ITBIS;

                    saleDetail.Sale.Quantity     = saleDetail.Sale.Quantity + saleDetail.Quantity;
                    saleDetail.Sale.TotalNoITBIS = saleDetail.Sale.TotalNoITBIS + _totalNoItbis;
                    saleDetail.Sale.Discount     = saleDetail.Sale.Discount + saleDetail.Discount;
                    saleDetail.Sale.ITBIS        = saleDetail.Sale.ITBIS + saleDetail.ITBIS;
                    saleDetail.Sale.Total        = saleDetail.Sale.Total + saleDetail.Total;

                    saleDetail.Sale.Debt = saleDetail.Sale.Total - saleDetail.Sale.Paid;

                    _context.Entry(oldSaleDetail).State = EntityState.Detached;
                    _context.Update(saleDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SaleDetailExists(saleDetail.SaleDetailId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            CreateInitial(saleDetail.ProductId, saleDetail.SaleId);
            return(View(saleDetail));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("SaleDetailId,SaleId,ProductId,Quantity,Discount")] SaleDetail saleDetail)
        {
            if (ModelState.IsValid)
            {
                Product product = await _context.Products.FirstOrDefaultAsync(d => d.ProductId == saleDetail.ProductId);

                saleDetail.Sale = await _context.Sales.FirstOrDefaultAsync(d => d.SaleId == saleDetail.SaleId);

                saleDetail.UserId    = User.Identity.Name;
                saleDetail.UnitPrice = product.UnitPrice;
                decimal _totalNoItbis = (saleDetail.Quantity * saleDetail.UnitPrice) - saleDetail.Discount;
                saleDetail.ITBIS = _totalNoItbis * (product.ITBIS / 100);
                saleDetail.Total = _totalNoItbis + saleDetail.ITBIS;

                saleDetail.Sale.Quantity     = saleDetail.Sale.Quantity + saleDetail.Quantity;
                saleDetail.Sale.TotalNoITBIS = saleDetail.Sale.TotalNoITBIS + _totalNoItbis;
                saleDetail.Sale.Discount     = saleDetail.Discount;
                saleDetail.Sale.ITBIS        = saleDetail.Sale.ITBIS + saleDetail.ITBIS;
                saleDetail.Sale.Total        = saleDetail.Sale.Total + saleDetail.Total;

                saleDetail.Sale.Debt = saleDetail.Sale.Total - saleDetail.Sale.Paid;

                _context.Add(saleDetail);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            CreateInitial(saleDetail.ProductId, saleDetail.SaleId);
            return(View(saleDetail));
        }
예제 #5
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,TransactionID,ProductName,Quantity,Amount")] SaleDetail saleDetail)
        {
            if (id != saleDetail.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(saleDetail);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SaleDetailExists(saleDetail.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(saleDetail));
        }
예제 #6
0
        public void SaveSale(SaleModel saleInfo, string cashierId)
        {
            List <SaleDetail> details = new List <SaleDetail>();
            var TaxRate = ConfigHelper.GetTaxRate() / 100;

            foreach (var item in saleInfo.SaleDetails)
            {
                var detail = new SaleDetail
                {
                    ProductId = item.ProductId,
                    Quantity  = item.Quantity
                };

                var productInfo = productData.GetProductById(detail.ProductId);

                if (productInfo == null)
                {
                    throw new Exception($"The product Id of {detail.ProductId} could not be found in the database.");
                }

                detail.PurchasePrice = productInfo.RetailPrice * detail.Quantity;

                if (productInfo.IsTaxable)
                {
                    detail.Tax = detail.PurchasePrice * TaxRate;
                }

                details.Add(detail);
            }

            Sale sale = new Sale
            {
                SubTotal  = details.Sum(x => x.PurchasePrice),
                Tax       = details.Sum(x => x.Tax),
                CashierId = cashierId
            };

            sale.Total = sale.SubTotal + sale.Tax;


            try
            {
                sql.StartTransaction(Constants.ARMDATA);

                sale.Id = sql.SaveAndLoadDataInTransaction <int, dynamic>("CreateSale", sale).FirstOrDefault();

                foreach (var item in details)
                {
                    item.SaleId = sale.Id;
                    sql.SaveDataInTransaction("CreateSaleDetail", item);
                }

                sql.CommitTransaction();
            }
            catch
            {
                sql.RollbackTransaction();
                throw;
            }
        }
예제 #7
0
        public void Checkout(int userId)
        {
            var cartItems = _cartRepository.GetItemCart(userId);
            var sale      = new Sale
            {
                UserId = userId,
                Total  = cartItems.Sum(x => x.SubTotal),
                Amount = cartItems.Sum(x => x.Amount),
            };

            sale.Products = new Collection <SaleDetail>();

            foreach (var item in cartItems)
            {
                var saleProduct = new SaleDetail
                {
                    Amount    = item.Amount,
                    subTotal  = item.SubTotal,
                    SaleId    = sale.Id,
                    Date      = DateTime.Now,
                    ProductId = item.ProductId
                };

                sale.Products.Add(saleProduct);
            }

            var result = _saleRepository.Save(sale);

            clearCart(cartItems);
            _cartRepository.SaveChanges();
        }
        public ActionResult Index([Bind(Include = "CustomerKey, EmployeeKey, SaleDetailQuantity, ProductKey")] NewOrder no)
        {
            Sale sale = new Sale();

            sale.SaleDate    = DateTime.Now;
            sale.CustomerKey = no.CustomerKey;
            sale.EmployeeKey = no.EmployeeKey;
            db.Sale.Add(sale);

            SaleDetail sd      = new SaleDetail();
            int        salekey = (from order in db.Sale
                                  where order.SaleDate == (sale.SaleDate)
                                  select order.SaleKey).FirstOrDefault();

            sd.SaleKey = salekey;
            sd.SaleDetailPriceCharged = (from product in db.Products
                                         where product.ProductKey.Equals(no.ProductKey)
                                         select product.ProductPrice).FirstOrDefault();
            sd.ProductKey               = no.ProductKey;
            sd.SaleDetailQuantity       = no.SaleDetailQuantity;
            sd.SaleDetailSaleTaxPercent = (decimal)0.09;
            db.SaleDetail.Add(sd);
            db.SaveChanges();

            Message m = new Message();

            m.MessageText = "Order Complete!";

            return(View("Result", m));
        }
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (MetroFramework.MetroMessageBox.Show(this,
                                             "¿Quieres eliminar el registro?",
                                             "Eliminar",
                                             MessageBoxButtons.OKCancel,
                                             MessageBoxIcon.Question) == DialogResult.OK)
     {
         using (DataContext dataContext = new DataContext())
         {
             SaleDetail saleDetail =
                 saleDetailBindingSource.Current as SaleDetail;
             if (saleDetail != null)
             {
                 if (dataContext.Entry <SaleDetail>(saleDetail).State == EntityState.Detached)
                 {
                     dataContext.Set <SaleDetail>().Attach(saleDetail);
                 }
                 dataContext.Entry <SaleDetail>(saleDetail).State = EntityState.Deleted;
                 dataContext.SaveChanges();
                 MetroFramework.MetroMessageBox.Show(this, "Detalle de venta eliminado");
                 saleDetailBindingSource.RemoveCurrent();
                 pnlDatos.Enabled = false;
             }
         }
     }
 }
 public void PlaceOrder(Sale sale, ShoppingCart cart)
 {
     using (var context = new eToolsContext())
     {
         context.Sales.Add(sale);
         List <ShoppingCartItem> cartItems = context.ShoppingCartItems.Where(x => x.ShoppingCartID.Equals(cart.ShoppingCartID)).Select(x => x).ToList();
         foreach (ShoppingCartItem cartItem in cartItems)
         {
             StockItem  stockItem  = context.StockItems.Where(x => x.StockItemID.Equals(cartItem.StockItemID)).FirstOrDefault();
             SaleDetail saleDetail = new SaleDetail();
             saleDetail.StockItemID  = cartItem.StockItemID;
             saleDetail.SellingPrice = stockItem.SellingPrice;
             saleDetail.Quantity     = cartItem.Quantity;
             if (saleDetail.Quantity > (stockItem.QuantityOnHand + stockItem.QuantityOnOrder))
             {
                 throw new Exception("Sale cannot proceed. " + stockItem.Description + " is out of stock.");
             }
             saleDetail.Backordered = saleDetail.Quantity > stockItem.QuantityOnHand ? true : false;
             sale.SaleDetails.Add(saleDetail);
             stockItem.QuantityOnHand       = saleDetail.Quantity > stockItem.QuantityOnHand ? 0 : stockItem.QuantityOnHand - saleDetail.Quantity;
             context.Entry(stockItem).State = System.Data.Entity.EntityState.Modified;
             context.ShoppingCartItems.Remove(cartItem);
         }
         ShoppingCart theCart = context.ShoppingCarts.Where(x => x.ShoppingCartID.Equals(cart.ShoppingCartID)).FirstOrDefault();
         context.ShoppingCarts.Remove(theCart);
         context.SaveChanges();
     }
 }
예제 #11
0
        protected override void ShowSimpleView()
        {
            int row = grid.FocusedCell.Row;

            if (row < 0)
            {
                return;
            }

            SaleDetail saleRow = operation.Details [row];

            if (!string.IsNullOrEmpty(saleRow.ItemName))
            {
                string text = string.Format("{0}\t{1} {2} x {3} = {4}",
                                            saleRow.ItemName, saleRow.Quantity, saleRow.MUnitName, Currency.ToString(saleRow.PriceOutPlusVAT), Currency.ToString(saleRow.TotalPlusVAT, operation.TotalsPriceType));

                lblSimpleView.SetText(text);
                base.ShowSimpleView();
            }
            else if (operation.Details.Count <= 1)
            {
                lblSimpleView.SetText(string.Empty);
                base.ShowSimpleView();
            }
        }
예제 #12
0
        public async Task <IActionResult> Edit(int id, SaleDetail saleDetail)
        {
            if (id != saleDetail.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await this.saleDetailRepository.UpdateAsync(saleDetail);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!await SaleDetailExists(saleDetail.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(saleDetail));
        }
예제 #13
0
        private void txtBarcodeData_KeyPress(object sender, KeyPressEventArgs e)
        {
            Product p;

            if (e.KeyChar == (char)Keys.Enter)
            {
                if (saleDetail != null)
                {
                    saleDetail = new SaleDetail();
                }
                if (txtBarcodeData.Text != "")
                {
                    p = context.Products.FirstOrDefault(x => x.BarcodeData == txtBarcodeData.Text);
                    if (p != null)
                    {
                        txtBarcodeData.Text     = p.Name;
                        txtBarcodeData.ReadOnly = true;
                        saleDetail.Product      = p;
                        saleDetail.ProductBatch = p.Batches.FirstOrDefault();
                        txtQty.Focus();
                    }
                }
            }
            else if (e.KeyChar == (char)Keys.Escape)
            {
                p = null;
                txtBarcodeData.ReadOnly = false;
                txtBarcodeData.Text     = "";
            }
        }
        public ActionResult TodayTotalSale()
        {
            var status = "";

            if (Authenticated)
            {
                try
                {
                    var Todaydate    = DateTime.Now.Date;
                    var TomorrowDate = DateTime.Now.Date.AddDays(1);
                    var obj          = db.SaleDetails.Where(x => x.CreatedOn > Todaydate && x.CreatedOn < TomorrowDate && x.RefundStatus == null).Select(x => x.AmountAfterDiscount);
                    if (obj.Count() > 0)
                    {
                        var sale = new SaleDetail();
                        sale.AmountAfterDiscount = 0;
                        foreach (var item in obj)
                        {
                            sale.AmountAfterDiscount += item;
                        }

                        status = JsonConvert.SerializeObject(sale.AmountAfterDiscount);
                    }
                    else
                    {
                        status = JsonConvert.SerializeObject(0);
                    }
                }
                catch (Exception ex)
                {
                    ApplicationExceptionLogging(ex.Message, ex.StackTrace, " AdminDashboard", "TodayTotalSale");
                }
            }
            return(Content(status));
        }
예제 #15
0
        private void ItemColumnChoose(string filter)
        {
            using (ChooseEditItem dialog = new ChooseEditItem(true, filter)) {
                if (dialog.Run() != ResponseType.Ok)
                {
                    EditGridCell(grid.EditedCell.Row, 0);
                    return;
                }

                for (int i = selectedDetails.Count - 1; i >= 0; i--)
                {
                    if (selectedDetails [i].ItemId == -1)
                    {
                        selectedDetails.RemoveAt(i);
                    }
                }

                foreach (Item item in dialog.SelectedItems)
                {
                    OperationDetail saleDetail;
                    if (grid.EditedCell.Row >= selectedDetails.Count)
                    {
                        saleDetail = new SaleDetail();
                        selectedDetails.Add((SaleDetail)saleDetail);
                    }
                    else
                    {
                        saleDetail = selectedDetails [grid.EditedCell.Row];
                    }
                    saleDetail.ItemEvaluate(item, PriceGroup.RegularPrice);
                }
            }

            EditGridCell(grid.EditedCell.Row, 1);
        }
예제 #16
0
        public IActionResult Put(int id, [FromBody] SaleDetail saledDetails)
        {
            var retriveSalesDetails = _iSalesDetailsManager.GetById(id);

            if (retriveSalesDetails == null)
            {
                return(BadRequest(new { error = "product not Found!" }));
            }


            retriveSalesDetails.UnitPrice   = saledDetails.UnitPrice;
            retriveSalesDetails.Description = saledDetails.Description;
            retriveSalesDetails.Qty         = saledDetails.Qty;
            retriveSalesDetails.TotalPrice  = saledDetails.TotalPrice;
            retriveSalesDetails.ProductId   = saledDetails.ProductId;
            retriveSalesDetails.SaleId      = saledDetails.SaleId;

            bool isUpdate = _iSalesDetailsManager.Update(retriveSalesDetails);

            if (isUpdate)
            {
                return(Ok(retriveSalesDetails));
            }

            return(BadRequest(new { error = "Failed!" }));
        }
예제 #17
0
        public void AddSaleDetail()
        {
            var item = new SaleDetail();

            Model.SaleDetails
            .Add(item);
        }
 private void btnEditar_Click(object sender, EventArgs e)
 {
     pnlDatos.Enabled = true;
     txtName.Focus();
     SaleDetail saleDetail =
         saleDetailBindingSource.Current as SaleDetail;
 }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     using (DataContext dataContext = new DataContext())
     {
         SaleDetail saleDetail =
             saleDetailBindingSource.Current as SaleDetail;
         if (saleDetail != null)
         {
             if (dataContext.Entry <SaleDetail>(saleDetail).State == EntityState.Detached)
             {
                 dataContext.Set <SaleDetail>().Attach(saleDetail);
             }
             if (saleDetail.Id == 0)
             {
                 dataContext.Entry <SaleDetail>(saleDetail).State = EntityState.Added;
             }
             else
             {
                 dataContext.Entry <SaleDetail>(saleDetail).State = EntityState.Modified;
             }
             dataContext.SaveChanges();
             MetroFramework.MetroMessageBox.Show(this, "Detalle de venta guardado");
             grdDatos.Refresh();
             pnlDatos.Enabled = false;
         }
     }
 }
예제 #20
0
        public bool Sale(SaleDetail detail)
        {
            var p = GetById(detail.ProductId);

            p.Sold   = p.Sold + detail.Quantity;
            p.OnHand = p.OnHand - detail.Quantity;
            return(base.Edit(p));
        }
예제 #21
0
        // GET: Sale/Delete/5
        public ActionResult Delete(SaleDetail IdtoDel)
        {
            var d = Entities_MVC.SaleDetails.Where(x => x.id == IdtoDel.id).FirstOrDefault();

            Entities_MVC.SaleDetails.Remove(d);
            Entities_MVC.SaveChanges();
            return(RedirectToAction("AllSale"));
        }
예제 #22
0
        public ActionResult DeleteConfirmed(int id)
        {
            SaleDetail saleDetail = db.SaleDetails.Find(id);

            db.SaleDetails.Remove(saleDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #23
0
 public bool InsertSaleDetail(SaleDetail detail)
 {
     using (EShopDB db = new EShopDB())
     {
         db.SaleDetail.Add(detail);
         bool isSuccess = db.SaveChanges() > 0;
         return(isSuccess);
     }
 }
예제 #24
0
        public ActionResult Order([Bind(Include = "ItemsOrdered, SubTotal, Total, EatIn")] Order or)
        {
            SaleDetail de = new SaleDetail();

            or.ItemsOrdered = de.SaleDetailQuantity;
            or.Total        = or.ItemsOrdered * de.SaleDetailPriceCharged;

            return(View("Result", or));
        }
예제 #25
0
 public async Task <IActionResult> SdSaver([FromBody] SaleDetail order)
 {
     if (order != null)
     {
         _context.SalesDetails.Add(order);
         await _context.SaveChangesAsync();
     }
     return(View());
 }
예제 #26
0
 private void SetSaleDetailItem(SaleDetailExtn saleDetailItemExtn, SaleDetail saleDetail)
 {
     saleDetail.Discount     = saleDetailItemExtn.Discount;
     saleDetail.PriceId      = saleDetailItemExtn.PriceId;
     saleDetail.ProductId    = saleDetailItemExtn.ProductId;
     saleDetail.Qty          = saleDetailItemExtn.Qty;
     saleDetail.SellingPrice = saleDetailItemExtn.SellingPrice;
     saleDetail.BillId       = _billSales.BillId;
 }
예제 #27
0
 public void DeleteRecord(Sale sale, Item item, SaleDetail saleDetail)
 {
     context.Sales.Detach(sale);
     context.SaleDetails.Detach(saleDetail);
     context.Sales.Attach(context.Sales.Single(c => c.SaleId == sale.SaleId));
     context.SaleDetails.Attach(context.SaleDetails.Single(sd => sd.SaleId == sale.SaleId && sd.ItemId == item.ItemId));
     context.SaleDetails.DeleteObject(saleDetail);
     context.SaveChanges();
 }
예제 #28
0
        // Save Sale
        public string SaveSale(SaleDetail objSaleDetail)
        {
            int noOfAffacted = 0;

            objDataAccess = DataAccess.NewDataAccess();
            objDbCommand  = objDataAccess.GetCommand(true, IsolationLevel.Serializable);

            // Insert sale

            objDbCommand.AddInParameter("CustomerId", objSaleDetail.Sales.CustomerId);
            objDbCommand.AddInParameter("ConsignmentNumber", objSaleDetail.Sales.ConsignmentNumber);
            objDbCommand.AddInParameter("SellingDate", objSaleDetail.Sales.SellingDate);
            objDbCommand.AddInParameter("SellingAmount", objSaleDetail.Sales.SellingAmount);
            objDbCommand.AddInParameter("PaymentMethod", objSaleDetail.Sales.PaymentMethod);
            objDbCommand.AddInParameter("ChequeNumber", objSaleDetail.Sales.ChequeNumber);
            objDbCommand.AddInParameter("TotalAmount", objSaleDetail.Sales.TotalAmount);
            objDbCommand.AddInParameter("PaidAmount", objSaleDetail.Sales.PaidAmount);
            objDbCommand.AddInParameter("AdjustmentAmount", objSaleDetail.Sales.AdjustmentAmount);
            objDbCommand.AddInParameter("Remarks", objSaleDetail.Sales.Remarks);
            objDbCommand.AddInParameter("OrderNumber", objSaleDetail.Sales.OrderNumber);
            // Insert sale details

            objDbCommand.AddInParameter("ProductId", objSaleDetail.ProductId);
            objDbCommand.AddInParameter("TruckNumber", objSaleDetail.TruckNumber);
            //objDbCommand.AddInParameter("TruckDetailId", objSaleDetail.TruckDetailId);
            objDbCommand.AddInParameter("SalePrice", objSaleDetail.SalePrice);
            objDbCommand.AddInParameter("SaleUnitBag", objSaleDetail.SaleUnitBag);
            objDbCommand.AddInParameter("SaleUnitKG", objSaleDetail.SaleUnitKG);
            objDbCommand.AddInParameter("CreatedBy", SessionUtility.STSessionContainer.UserID);



            try
            {
                noOfAffacted = objDataAccess.ExecuteNonQuery(objDbCommand, "[dbo].[uspCreateSales]", CommandType.StoredProcedure);
                if (noOfAffacted > 0)
                {
                    objDbCommand.Transaction.Commit();
                    return("saved");
                }
                else
                {
                    objDbCommand.Transaction.Rollback();
                    return("failed");
                }
            }
            catch (Exception ex)
            {
                objDbCommand.Transaction.Rollback();
                throw new Exception("Database Error Occured", ex);
            }

            finally
            {
                objDataAccess.Dispose(objDbCommand);
            }
        }
예제 #29
0
        public DateTime RefundAll(int reason, string paySn, decimal amount, string uid, string apicodes, string newOrderSn, string newCustomOrderSn, DateTime createdt)
        {
            var order    = SaleOrdersService.CurrentRepository.Entities.FirstOrDefault(o => o.CompanyId == CompanyId && o.CustomOrderSn == paySn && o.StoreId == StoreId && o.State == 0);
            var newOrder = new SaleOrders()
            {
                StoreId                  = order.StoreId,           //门店id
                MachineSN                = order.MachineSN,         //pos机号
                PaySN                    = newOrderSn,              //订单流水号
                CustomOrderSn            = newCustomOrderSn,        //订单流水号
                ReFundOrderCustomOrderSn = order.CustomOrderSn,     //原订单流水号
                TotalAmount              = -order.TotalAmount,      //优惠后金额
                PreferentialPrice        = order.PreferentialPrice, //优惠金额
                ApiCode                  = apicodes,                //支付方式
                CreateUID                = uid,                     //收银员工号
                ReturnOrderUID           = uid,
                ReturnDT                 = createdt,
                CreateDT                 = createdt,
                CompanyId                = order.CompanyId,
                ProductCount             = -order.ProductCount,
                Reason                   = reason,
                Type          = 3,
                State         = 1,
                MemberId      = order.MemberId,
                ActivityId    = order.ActivityId,
                Salesman      = order.Salesman,
                Receive       = -order.Receive,
                IsTest        = IsSalesclerkTest,
                OrderDiscount = order.OrderDiscount,
                InInventory   = 0,
                IsProcess     = false
            };
            var saleOrdersDetails = SaleDetailService.FindList(o => o.PaySN == order.PaySN).ToList();

            foreach (var item in saleOrdersDetails)
            {
                SaleDetail _saleDetail = new SaleDetail()
                {
                    PaySN           = newOrderSn,
                    ProductCode     = item.ProductCode,
                    AveragePrice    = item.AveragePrice,//均价
                    CompanyId       = CompanyId,
                    Total           = -item.Total,
                    Barcode         = item.Barcode,         //商品条码
                    PurchaseNumber  = -item.PurchaseNumber, //销售数量
                    BuyPrice        = item.BuyPrice,        //系统进价
                    SysPrice        = item.SysPrice,        //系统售价
                    ActualPrice     = item.ActualPrice,     //销售价
                    Title           = item.Title,
                    ScanBarcode     = item.ScanBarcode,
                    SalesClassifyId = item.SalesClassifyId,//销售分类id
                };
                SaleDetailService.CurrentRepository.Add(_saleDetail, false);
            }
            SaleOrdersService.CurrentRepository.Add(newOrder);
            return(createdt);
        }
 private void FrmSaleDetail_Load(object sender, EventArgs e)
 {
     using (DataContext dataContext = new DataContext())
     {
         saleDetailBindingSource.DataSource =
             dataContext.SaleDetails.ToList();
     }
     pnlDatos.Enabled = false;
     SaleDetail saleDetail = saleDetailBindingSource.Current as SaleDetail;
 }
예제 #31
0
        public async Task <IActionResult> Create(SaleDetail saleDetail)
        {
            if (ModelState.IsValid)
            {
                await this.saleDetailRepository.CreateAsync(saleDetail);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(saleDetail));
        }
예제 #32
0
 private void addToCart_Click(object sender, EventArgs e)
 {
     int itemId = (int)showItems.SelectedRows[0].Cells["ItemId"].Value;
     SaleDetail detail = new SaleDetail { SaleId = sale.SaleId, ItemId = itemId, Quantity = (int) quantityBox.Value };
     if (details.Exists(s => s.SaleId == detail.SaleId && s.ItemId == detail.ItemId))
     {
         details.Remove(details.Find(s => s.SaleId == detail.SaleId && s.ItemId == detail.ItemId));
     }
     details.Add(detail);
     refreshCartBinding();
 }
예제 #33
0
파일: SaleLogic.cs 프로젝트: ErickMC/Llama
 public void DeleteDetailFromSale(Sale sale, Item item, SaleDetail detail)
 {
     sale.SaleTotal -= item.Cost * detail.Quantity;
     Sale_Manager.UpdateRecord(sale, item, detail); //Updates the total in the database
     Sale_Manager.DeleteRecord(sale, item, detail);
 }
예제 #34
0
 public void AddRecord(SaleDetail saleDetail)
 {
     TestContext context = new TestContext();
     context.SaleDetails.AddObject(saleDetail);
     context.SaveChanges();
 }
예제 #35
0
 public void UpdateRecord(SaleDetail record)
 {
     throw new NotImplementedException();
 }
예제 #36
0
 public void UpdateRecord(Sale sale, Item item, SaleDetail saleDetail)
 {
     context.Sales.Detach(sale);
     context.SaleDetails.Detach(saleDetail);
     if (sale.EntityState == System.Data.EntityState.Detached)
     {
         context.Sales.Attach(context.Sales.Single(c => c.SaleId == sale.SaleId));
     }
     if (saleDetail.EntityState == System.Data.EntityState.Detached)
     {
       context.SaleDetails.Attach(context.SaleDetails.Single(sd => sd.SaleId == sale.SaleId && sd.ItemId == item.ItemId));
     }
     context.Sales.ApplyCurrentValues(sale);
     context.SaleDetails.ApplyCurrentValues(saleDetail);
     context.SaveChanges();
 }
예제 #37
0
파일: SaleLogic.cs 프로젝트: ErickMC/Llama
 public void UpdateSale(Sale sale, Item item, SaleDetail detail)
 {
     Sale_Manager.UpdateRecord(sale, item, detail);
 }