public static void printDuplicateRecipt(int saleId)
        {
            tbl_Sale                   sale           = Sale.getById(saleId);
            tbl_Customer               customer       = Customer.getById((int)sale.Customer_Id);
            List <tbl_SaleItem>        soldItems      = SaleItem.getAllBySaleId(saleId);
            List <ItemOrDealSaleModel> allMappedItems = Sale.getMappedListofDealsAndItemsToItemOrDealSaleModel();
            List <ItemOrDealSaleModel> newSaleList    = new List <ItemOrDealSaleModel>();

            foreach (tbl_SaleItem item in soldItems)
            {
                ItemOrDealSaleModel s  = new ItemOrDealSaleModel();
                ItemOrDealSaleModel s1 = allMappedItems.Where(a => a.Id == (int)item.Item_id).FirstOrDefault();
                s.Id        = s1.Id;
                s.Name      = s1.Name;
                s.Quantity  = (int)item.Quantity;
                s.SalePrice = s1.SalePrice;
                s.Total     = s1.SalePrice * s.Quantity;

                newSaleList.Add(s);
            }
            //int salesId, List< ItemOrDealSaleModel > list, int totalBill,int remaining, int saleType,string customerAddress
            string customerAddress;

            if (customer != null)
            {
                customerAddress = customer.Address + " " + customer.PhoneNo;
            }
            else
            {
                customerAddress = "";
            }

            PrintingUtils.printSaleReceipt(sale.Id, newSaleList, (int)sale.Amount, 0, (int)sale.SaleType, customerAddress);
        }
        public static void performANewSale(List <ItemOrDealSaleModel> saleList, double discount, int totalBill, int remaining, int customerId, bool receipt1, bool receipt2, bool receipt3, int saletype, string customerAddress, int deliveryBoyId)
        {
            RMSDBEntities db   = DBContext.getInstance();
            tbl_Sale      sale = new tbl_Sale();

            sale.Staff_id  = 0;
            sale.Date_Time = DateTime.Now;

            tbl_Customer c = Customer.getById(customerId);

            if (c != null)
            {
                sale.Customer_Id = customerId;
            }

            sale.Amount   = totalBill;
            sale.SaleType = saletype;
            db.tbl_Sale.Add(sale);
            db.SaveChanges();
            //3 is for delivery. therefor we have to add in Delivery Queue
            if (saletype == 3)
            {
                tbl_DeliveryQueue dq = new tbl_DeliveryQueue();
                dq.Customer_Id = customerId;
                dq.Sale_Id     = sale.Id;
                dq.Delivered   = false;
                dq.DatenTime   = DateTime.Now;
                if (deliveryBoyId != 0)
                {
                    dq.DeliveryBoyId = deliveryBoyId;
                }

                DeliveryQueue.insert(dq);
            }
            // printing
            if (receipt1)
            {
                PrintingUtils.printSaleReceipt(sale.Id, saleList, totalBill, remaining, saletype, customerAddress);
            }
            if (receipt2)
            {
                PrintingUtils.printSaleReceipt(sale.Id, saleList, totalBill, remaining, saletype, customerAddress);
            }
            if (receipt3)
            {
                PrintingUtils.printSaleReceipt(sale.Id, saleList, totalBill, remaining, saletype, customerAddress);
            }
            foreach (ItemOrDealSaleModel item in saleList)
            {
                tbl_SaleItem saleItem = new tbl_SaleItem();
                saleItem.Item_id  = item.Id;
                saleItem.Sale_id  = sale.Id;
                saleItem.Quantity = item.Quantity;
                SaleItem.insert(saleItem);
            }
            DetuctInventory.detuctInventoryOfList(saleList);
        }