Esempio n. 1
0
        public int Insert(SaleInvoice saleInvoice)
        {
            InsertCommand.Parameters["@ReferenceNo"].Value     = saleInvoice.ReferenceNo;
            InsertCommand.Parameters["@InventoryItemID"].Value = saleInvoice.InventoryItemID;
            InsertCommand.Parameters["@ItemName"].Value        = saleInvoice.ItemName;
            InsertCommand.Parameters["@Description"].Value     = saleInvoice.Description;
            InsertCommand.Parameters["@Price"].Value           = saleInvoice.Price;
            InsertCommand.Parameters["@Qty"].Value             = saleInvoice.Qty;
            InsertCommand.Parameters["@Amount"].Value          = saleInvoice.Amount;
            InsertCommand.Parameters["@Status"].Value          = saleInvoice.Status;


            int returnValue = -1;

            try
            {
                InsertCommand.Connection.Open();
                returnValue = (int)InsertCommand.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                InsertCommand.Connection.Close();
            }
            return(returnValue);
        }
Esempio n. 2
0
        public int Update(SaleInvoice saleInvoice)
        {
            UpdateCommand.Parameters["@ID"].Value              = saleInvoice.ID;
            UpdateCommand.Parameters["@ReferenceNo"].Value     = saleInvoice.ReferenceNo;
            UpdateCommand.Parameters["@InventoryItemID"].Value = saleInvoice.InventoryItemID;
            UpdateCommand.Parameters["@ItemName"].Value        = saleInvoice.ItemName;
            UpdateCommand.Parameters["@Description"].Value     = saleInvoice.Description;
            UpdateCommand.Parameters["@Price"].Value           = saleInvoice.Price;
            UpdateCommand.Parameters["@Qty"].Value             = saleInvoice.Qty;
            UpdateCommand.Parameters["@Amount"].Value          = saleInvoice.Amount;
            UpdateCommand.Parameters["@Status"].Value          = saleInvoice.Status;

            int returnValue = -1;

            try
            {
                UpdateCommand.Connection.Open();
                returnValue = UpdateCommand.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                Logger.Write(ex);
            }
            finally
            {
                UpdateCommand.Connection.Close();
            }
            return(returnValue);
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("SaleInvoiceId,CustomerId,OnDate,InvoiceNo,TotalItems,TotalQty,TotalBillAmount,TotalDiscountAmount,RoundOffAmount,TotalTaxAmount")] SaleInvoice saleInvoice)
        {
            if (id != saleInvoice.SaleInvoiceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(saleInvoice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SaleInvoiceExists(saleInvoice.SaleInvoiceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(saleInvoice));
        }
        public IActionResult AddProductSales(Object jsonResult)
        {
            dynamic reqBody = JObject.Parse(jsonResult.ToString());
            //var productDtos = _inventoryService.GetProducts(reqBody.productIds.ToObject<List<int>>());
            //var saleProducts = _mapper.Map<List<ProductDto>, List<Product>>(productDtos);
            var         saleProducts = _inventoryService.GetProducts(reqBody.productIds.ToObject <List <int> >());
            int         saleId       = reqBody.saleId;
            SaleInvoice sale         = _saleService.GetSale(saleId);

            if (sale == null)
            {
                return(BadRequest("This sale does not exist"));
            }
            else if (sale.Finalised == true)
            {
                return(BadRequest("This Sale Has Already Been Finalised"));
            }
            else if (sale != null && saleProducts.Count > 0)
            {
                var productSales = _saleService.ApplyPromotionsToSale(sale.Id, saleProducts);
                _saleService.ProcessProductSales(sale, productSales);
                SaleInvoiceDto invoice = _mapper.Map <SaleInvoice, SaleInvoiceDto>(sale);
                invoice.Products = _mapper.Map <IList <ProductSale>, IList <ProductSaleDto> >(productSales);
                return(Ok(invoice));
            }
            else
            {
                return(BadRequest("There are no products to add"));
            }
        }
        public static void InsertSaleInvoice(SaleInvoice saleInvoice)
        {
            MySqlCommand command = new MySqlCommand();

            connection.Open();

            MySqlTransaction transaction = connection.BeginTransaction();

            command.Connection  = connection;
            command.CommandText = "SELECT MAX(" + SaleInvoice.Columns.NumberColumn + ") FROM saleinv;";

            try
            {
                saleInvoice.Number = (int)command.ExecuteScalar() + 1;
            }
            catch (InvalidCastException)
            {
                saleInvoice.Number = 1;
            }

            command.CommandText  = "INSERT INTO saleinv VALUES(";
            command.CommandText += saleInvoice.Number + ", ";
            command.CommandText += saleInvoice.ProductId + ", ";
            command.CommandText += saleInvoice.PricePerUnit + ", ";
            command.CommandText += saleInvoice.Quantity.ToString();
            command.CommandText += ");";

            command.ExecuteNonQuery();

            transaction.Commit();
            connection.Close();
        }
        /// <summary>
        /// Writing the sale information to a text file with the COB.
        /// </summary>
        private void finishingSaleInvoice()
        {
            DateTime nowDate = DateTime.Now;

            SaleInvoice saleInvoice = new SaleInvoice();

            saleInvoice.int_SaleInvoiceNumber   = 999;
            saleInvoice.str_InvoiceProductName  = "Total Sales For:" + nowDate.ToString("yyyy/MM/dd");
            saleInvoice.dec_InvoiceSellingPrice = 0;
            saleInvoice.int_SaleQuantity        = int_finalQty;
            saleInvoice.dec_ValueOfSale         = dec_finalSalesValue;


            btn_closeBus.Visible = true;
            pnl_panel1.Enabled   = true;
            pnl_panel1.Visible   = false;

            System.IO.StreamWriter saleFile = new System.IO.StreamWriter("sales.txt");
            for (int count = 0; count < int_updateCounter; count++)
            {
                saleFile.Write(arr_sales[count].print() + saleFile.NewLine);
            }
            saleFile.Write(saleInvoice.int_SaleInvoiceNumber + "," +
                           saleInvoice.str_InvoiceProductName + "," +
                           saleInvoice.dec_InvoiceSellingPrice + "," +
                           saleInvoice.int_SaleQuantity + "," +
                           saleInvoice.dec_ValueOfSale.ToString("c") +
                           saleFile.NewLine);

            saleFile.Write("From left to right:" + saleFile.NewLine);
            saleFile.Write("Invoice Number, Product Name, Cost of the product, Amount sold, and the Value of sale.");
            saleFile.Close();
        }
Esempio n. 7
0
 public void Delete(SaleInvoice SaleInvoice)
 {
     if (SaleInvoice.Id == -1)
     {
         return;
     }
 }
        private void totalSale()
        {
            try
            {
                var         now          = DateTime.Now;
                var         startOfMonth = new DateTime(now.Year, now.Month, 1);
                var         endOfMonth   = new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month));
                SalesTarget repository   = new SalesTarget();

                String currentMonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(now.Month);
                currentMonthName += " " + now.Year;

                lblPurchaseMonth.InnerHtml = "Total purchase of " + currentMonthName;
                lblSaleMonth.InnerHtml     = "Total sale of " + currentMonthName;

                var currentMonthtarget = repository.GetAll().Where(r => r.MonthName.Equals(currentMonthName)).FirstOrDefault();

                SaleInvoice repo      = new SaleInvoice();
                decimal     totalSale = repo.totalSaleByMonth(startOfMonth, endOfMonth);
                lblTotalSale.InnerHtml = "$" + totalSale.ToString();
                double percentage = Math.Round(Convert.ToDouble((totalSale / currentMonthtarget.TargetAmount) * 100), 2);

                lbltarget.InnerHtml = "Congratulations! You have achieved " + percentage + "% of total sale";

                string rateBar = "<div style='float: left;'>" +
                                 "   <div class='meter red animate' style='width: 970px;;'>" +
                                 "<span style='width: " + percentage + "%'><span></span>" +
                                 "</div></div>";

                divRate.InnerHtml = rateBar;
            }
            catch (Exception)
            {
            }
        }
Esempio n. 9
0
        private SaleInvoice CreateSaleInvoice(VoyagerContext db, ImportSaleItemWise item, SaleInvoice invoice)
        {
            if (invoice != null)
            {
                if (invoice.InvoiceNo == item.InvoiceNo)
                {
                    // invoice.InvoiceNo = item.InvoiceNo;
                    //invoice.OnDate = item.InvoiceDate;
                    invoice.TotalDiscountAmount += item.Discount;
                    invoice.TotalBillAmount     += item.LineTotal;
                    invoice.TotalItems          += 1;//TODO: Check for count
                    invoice.TotalQty            += item.Quantity;
                    invoice.RoundOffAmount      += item.RoundOff;
                    invoice.TotalTaxAmount      += item.SGST; //TODO: Check

                    invoice.PaymentDetail = CreatePaymentDetails(db, item);
                    invoice.CustomerId    = GetCustomerId(db, item);
                }
                else
                {
                    db.SaleInvoices.Add(invoice);
                    db.SaveChanges();

                    invoice = new SaleInvoice
                    {
                        InvoiceNo           = item.InvoiceNo,
                        OnDate              = item.InvoiceDate,
                        TotalDiscountAmount = item.Discount,
                        TotalBillAmount     = item.LineTotal,
                        TotalItems          = 1,//TODO: Check for count
                        TotalQty            = item.Quantity,
                        RoundOffAmount      = item.RoundOff,
                        TotalTaxAmount      = item.SGST, //TODO: Check
                        PaymentDetail       = CreatePaymentDetails(db, item),
                        CustomerId          = GetCustomerId(db, item),
                        SaleItems           = new List <SaleItem>()
                    };
                }
            }
            else
            {
                invoice = new SaleInvoice
                {
                    InvoiceNo           = item.InvoiceNo,
                    OnDate              = item.InvoiceDate,
                    TotalDiscountAmount = item.Discount,
                    TotalBillAmount     = item.LineTotal,
                    TotalItems          = 1,//TODO: Check for count
                    TotalQty            = item.Quantity,
                    RoundOffAmount      = item.RoundOff,
                    TotalTaxAmount      = item.SGST, //TODO: Check
                    PaymentDetail       = CreatePaymentDetails(db, item),
                    CustomerId          = GetCustomerId(db, item),
                    SaleItems           = new List <SaleItem>()
                };
            }

            return(invoice);
        }
 private void load_dropdown()
 {
     SaleInvoice repository = new SaleInvoice();
     var result = repository.GetAll().Where(r => r.Deleted == false).Select(r => new { id = r.InvoiceId, name = r.InvoiceNo }).ToList();
     result.Insert(0, new { id = 0, name = "--SELECT ID--" });
     DropDownList1.DataSource = result;
     DropDownList1.DataBind();
 }
        public void CompleteTransaction(int saleInvoiceId)
        {
            SaleInvoice sale = _context.SaleInvoices.Find(saleInvoiceId);

            sale.Finalised             = true;
            _context.Entry(sale).State = EntityState.Modified;
            _context.SaveChanges();
        }
        public void DeleteSaleInvoice(int saleInvoiceId)
        {
            SaleInvoice sale = _context.SaleInvoices.Find(saleInvoiceId);

            //Delete ProductSales?
            _context.SaleInvoices.Remove(sale);
            _context.SaveChanges();
        }
 public void FinaliseSale(SaleInvoice sale)
 {
     sale.Finalised = true;
     _salesRepo.UpdateSale(sale);
     foreach (var productSale in sale.ProductSales)
     {
         _inventoryRepo.DecreaseProductQty(productSale.ProductId, 1);
     }
 }
Esempio n. 14
0
 public void SaleInvLineLog(SaleInvoice sai)
 {
     sw = new StreamWriter("Track" + sai.TransactionDate.ToString("yyyyMMdd") + ".log", true);
     for (int i = 0; i < sai.LineItems.Count; i++)
     {
         sw.WriteLine(sai.Customer.Id + "," + sai.SaleInvoiceNo + "," + sai.LineItems[i].Item.ItemId + "," + sai.LineItems[i].DiscPct);
     }
     sw.Close();
 }
Esempio n. 15
0
        public async Task <bool> QuoteEmailPush(SaleInvoice saleInvoice)
        {
            bool sendsuccess = false;

            try
            {
                if (!string.IsNullOrEmpty(saleInvoice.EmailSentTo))
                {
                    //------------------------
                    string[] BccList   = null;
                    string[] CcList    = null;
                    string[] EmailList = saleInvoice.EmailSentTo.Split(',');
                    if (saleInvoice.Cc != null)
                    {
                        CcList = saleInvoice.Cc.Split(',');
                    }
                    if (saleInvoice.Bcc != null)
                    {
                        BccList = saleInvoice.Bcc.Split(',');
                    }
                    string      mailBody = File.ReadAllText(HttpContext.Current.Server.MapPath("~/Content/MailTemplate/DocumentEmailBody.html"));
                    MailMessage _mail    = new MailMessage();
                    PDFTools    pDFTools = new PDFTools();
                    string      link     = WebConfigurationManager.AppSettings["AppURL"] + "/Content/images/Pilot1.png";
                    _mail.Body               = mailBody.Replace("$Customer$", saleInvoice.Customer.ContactPerson).Replace("$Document$", "Sale Invoice").Replace("$DocumentNo$", saleInvoice.SaleInvNo).Replace("$DocumentDate$", saleInvoice.SaleInvDateFormatted).Replace("$Logo$", link);
                    pDFTools.Content         = saleInvoice.MailContant;
                    pDFTools.ContentFileName = "SaleInvoice";
                    _mail.Attachments.Add(new Attachment(new MemoryStream(_pDFGeneratorBusiness.GetPdfAttachment(pDFTools)), saleInvoice.SaleInvNo + ".pdf"));
                    _mail.Subject    = saleInvoice.Subject;
                    _mail.IsBodyHtml = true;
                    foreach (string email in EmailList)
                    {
                        _mail.To.Add(email);
                    }
                    if (saleInvoice.Cc != null)
                    {
                        foreach (string email in CcList)
                        {
                            _mail.CC.Add(email);
                        }
                    }
                    if (saleInvoice.Bcc != null)
                    {
                        foreach (string email in BccList)
                        {
                            _mail.Bcc.Add(email);
                        }
                    }
                    sendsuccess = await _mailBusiness.MailMessageSendAsync(_mail);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(sendsuccess);
        }
Esempio n. 16
0
        public async Task <IActionResult> Create([Bind("SaleInvoiceId,CustomerId,OnDate,InvoiceNo,TotalItems,TotalQty,TotalBillAmount,TotalDiscountAmount,RoundOffAmount,TotalTaxAmount")] SaleInvoice saleInvoice)
        {
            if (ModelState.IsValid)
            {
                _context.Add(saleInvoice);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(saleInvoice));
        }
Esempio n. 17
0
 public void Save(SaleInvoice saleInvoice)
 {
     if (saleInvoice.Id == -1)
     {
         this.Add(saleInvoice);
     }
     else
     {
         this.Update(saleInvoice);
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         Load_Data_Grid();
         load_dropdown();
         SaleInvoice    s            = new SaleInvoice();
         tblSaleInvoice salesinvoice = new tblSaleInvoice();
         int            maxid        = s.GetId();
         lblInvoiceNo.Text = (maxid + 1).ToString();
     }
 }
Esempio n. 19
0
 public object InsertUpdateSaleInvoice(SaleInvoice saleInvoice)
 {
     if (saleInvoice.SaleInvoiceDetailList.Count > 0)
     {
         saleInvoice.DetailXML = _commonBusiness.GetXMLfromSaleInvoiceObject(saleInvoice.SaleInvoiceDetailList, "ProductID,ProductModelID,UnitCode,Qty,Rate");
     }
     if (saleInvoice.SaleInvoiceOtherChargeDetailList.Count > 0)
     {
         saleInvoice.OtherChargeDetailXML = _commonBusiness.GetXMLfromSaleInvoiceOtherChargeObject(saleInvoice.SaleInvoiceOtherChargeDetailList, "OtherChargeCode,ChargeAmount");
     }
     return(_saleInvoiceRepository.InsertUpdateSaleInvoice(saleInvoice));
 }
Esempio n. 20
0
        public int SaleInvoice_Add(SaleInvoice s)
        {
            Database  db      = DatabaseFactory.CreateDatabase("ABC");
            DbCommand command = db.GetStoredProcCommand("SaleInvoice_Add");

            db.AddOutParameter(command, "SaleInvoiceCode", DbType.Int32, -1);
            db.AddInParameter(command, "CustomerName", DbType.String, s.CustomerName);
            db.AddInParameter(command, "InvoiceDate", DbType.DateTime, s.InvoiceDate);
            db.AddInParameter(command, "GrandTotal", DbType.Decimal, s.GrandTotal);
            db.ExecuteNonQuery(command);
            return(Convert.ToInt32(db.GetParameterValue(command, "SaleInvoiceCode")));
        }
        public SaleInvoice CreateNewSaleInvoice()
        {
            SaleInvoice newSale = new SaleInvoice {
                InvoiceDate = DateTime.Now
            };

            _context.SaleInvoices.Add(newSale);
            //      Store store = new Store { StoreName = "Procamp", Address = "Hamilton", GstNum = "123-234432-332", Contact = "07-801-2345" };
            //     _context.Store.Add(store);
            _context.SaveChanges();
            return(newSale);
        }
Esempio n. 22
0
        public void ProcessCashRegisterEInvoice()
        {
            using (IDAL dal = this.DAL)
            {
                DataTable dt = dal.ExecuteDataset("ACC_LST_NEWINVOICES_SP").Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        EInvoiceOperations invOp   = new EInvoiceOperations(dal);
                        EInvoiceClient     eInvCli = invOp.CheckIfEInvoiceCustomer(long.Parse(dr["IDENTITYNO_TXT"].ToString()));
                        // kaydı oluştur.
                        dal.BeginTransaction();
                        try
                        {
                            SaleInvoice i = new SaleInvoice();
                            i.EInvoiceFlag = (eInvCli.EInvoiceClientId != 0);
                            if (eInvCli.EInvoiceClientId != 0)
                            {
                                i.EInvoiceClient = eInvCli.EInvoiceClientId;
                            }
                            i.CustomerIdNumber = long.Parse(dr["IDENTITYNO_TXT"].ToString());
                            i.Email            = dr["EMAIL_TXT"].ToString();
                            i.Event            = 1;
                            i.Organization     = 1;
                            i.PhoneNumber      = dr["PHONENUMBER_TXT"].ToString();
                            i.Sale             = (long)dr["SALE"];
                            i.Title            = dr["CUSTOMER_NM"].ToString();
                            i.StatusCode       = 1;
                            i.Address          = dr["ADDRESS_TXT"].ToString();
                            i.SaleStore        = int.Parse(dr["STORE"].ToString());
                            i.SaleAmount       = decimal.Parse(dr["SALE_AMT"].ToString());
                            i.SaleDate         = (DateTime)dr["TRANSACTION_DT"];
                            i.SaleInvoiceId    = dal.Create <SaleInvoice>(i);

                            startEInvoiceProcess(i, dal);
                            dal.CommitTransaction();
                        }
                        catch (Exception ex)
                        {
                            dal.RollbackTransaction();
                            throw ex;
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger.Error($"serviceName : SaleInvoiceService, methodName : ProcessCashRegisterEInvoice, identityInfo : {dr["IDENTITYNO_TXT"].ToString()}, Exception : {ex.ToString()}");
                    }
                }
            }
        }
        public static async Task <SaleInvoice> UpdateSaleAsync(IRestDataMapper mapper, SaleInvoice data)
        {
            SaleInvoice reds = new SaleInvoice();

            if (mapper == null)
            {
                return(reds);
            }
            string url = $"selling/api/v1/sales/{data.id}";

            reds = await mapper.PutDataAsync(url, data);

            return(reds);
        }
        public static async Task <SaleInvoice> GetAllSaleByInvoiceNoAsync(IRestDataMapper mapper, int bid, string inv)
        {
            SaleInvoice data = new SaleInvoice();

            if (mapper == null)
            {
                return(data);
            }
            string url = $"selling/api/v1/sales/invNo/{bid}/{inv}";

            data = await mapper.GetDataAsync <SaleInvoice>(url);

            return(data);
        }
Esempio n. 25
0
        //Reading data for Entry

        private int ReadAllData( )
        {
            SaleInvoice        inv       = ReadSaleInvoiceFeilds();
            SalePaymentDetails payment   = ReadPaymentDetails();
            DataTable          saleitems = (DGVSaleItems.DataSource as BindingSource).DataSource as DataTable;

            if (inv != null && payment != null && saleitems != null)
            {
                return(SaveAllData(inv, payment, saleitems));
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 26
0
 public void SendEInvoice(SaleInvoice rec)
 {
     using (IDAL dal = this.DAL)
     {
         dal.BeginTransaction();
         try
         {
             startEInvoiceProcess(rec, dal);
             dal.CommitTransaction();
         }
         catch (Exception ex)
         {
             dal.RollbackTransaction();
             throw (ex);
         }
     }
 }
        private void loadGrid_Report(DateTime startDate, DateTime endDate)
        {
            SaleInvoice repository = new SaleInvoice();
            var         result     = repository.getProductByTime(startDate, endDate);

            if (result.Count > 0)
            {
                gridProduct.DataSource = result;
                gridProduct.DataBind();
                gridProduct.Visible = true;
            }
            else
            {
                gridProduct.Visible = false;
                this.ShowWarningNotification("No data found");
            }
        }
Esempio n. 28
0
        private void loadGrid_Report(int id)
        {
            SaleInvoice repository = new SaleInvoice();
            var         result     = repository.getProductByCustomer(id);

            if (result.Count > 0)
            {
                gridProduct.DataSource = result;
                gridProduct.DataBind();
                gridProduct.Visible = true;
            }
            else
            {
                gridProduct.Visible = false;
                this.ShowWarningNotification("No data found");
            }
        }
Esempio n. 29
0
        /**
         * ReadSaleInvoiceFeilds
         *
         * Read Sale Invoice Details
         */

        private SaleInvoice ReadSaleInvoiceFeilds( )
        {
            SaleInvoice inv = new SaleInvoice()
            {
                ID                  = -1,
                InvoiceNo           = CBInvoiceNo.Text,
                OnDate              = DTPInvoiceDate.Value,
                TotalBillAmount     = double.Parse(TXTGrandTotal.Text),
                TotalDiscountAmount = double.Parse(TXTDiscount.Text),
                TotalTaxAmount      = double.Parse(TXTTaxAmount.Text),
                TotalItems          = vTotalItems,
                TotalQty            = vTotalQty,
                RoundOffAmount      = vRoundOffAmt,
                CustomerId          = vCustId
            };

            return(inv);
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue == "0")
            {
                this.ShowErrorNotification("Please select proper id");
            }
            else
           {
            Load_Data_Grid();
            lblCustName.Visible = true;
            gridProduct1.Visible = true;
            lblTotal1.Visible = true; 
            txtDiscount1.Visible = true;
            txtTax1.Visible = true;
            lblNetTotal1.Visible = true;
            SaleInvoice repository = new SaleInvoice();
            tblSaleInvoice saleInvoice = repository.Get(Convert.ToInt32(DropDownList1.SelectedValue));
            Customer c = new Customer();
            tblCustomer cust = c.Get(saleInvoice.CustomerId);
            lblCustName.Text = cust.Firstname + " " +cust.Lastname;
            lblTotal1.Text= saleInvoice.TotalSale.ToString();
            txtTax1.Text= saleInvoice.Tax.ToString();
            txtDiscount1.Text=saleInvoice.Discount.ToString();
            lblNetTotal1.Text=saleInvoice.NetSale.ToString();

            SaleInvoiceDetail repo = new SaleInvoiceDetail();
            tblSaleInvoiceDetail sid = new tblSaleInvoiceDetail();
            
IEnumerable<tblSaleInvoiceDetail> enume= repo.GetOnInvoiceId(Convert.ToInt32(saleInvoice.InvoiceId));
            var enumer= enume.GetEnumerator();
            while (enumer.MoveNext())
            {
                int rowindex = enumer.Current.ProductId - 1;
                CheckBox cb = (CheckBox)gridProduct1.Rows[rowindex].FindControl("chkbox1");
                cb.Checked = true;
                
                TextBox txt = (TextBox)gridProduct1.Rows[rowindex].FindControl("txtQuantity");
                txt.Visible = true;
                txt.Text = enumer.Current.Quantity.ToString();

            }
            total = Convert.ToDouble(lblTotal1.Text);
           }
        }
 private void detach_SaleInvoices(SaleInvoice entity)
 {
     this.SendPropertyChanging("SaleInvoices");
     entity.SaleSellitem = null;
 }
 private void detach_SaleInvoices(SaleInvoice entity)
 {
     this.SendPropertyChanging("SaleInvoices");
     entity.ItemInstance = null;
 }