private void btnSave_Click(object sender, EventArgs e)
        {
            PurchaseInvoiceBL objpur = new PurchaseInvoiceBL();

            for (int i = 0; i < dgvProduct.Rows.Count; i++)
            {
                objpur.ProductID = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objpur.Quantity  = Convert.ToInt32(dgvProduct.Rows[i].Cells[4].Value.ToString());
                objpur.ProdUpdate();
            }
            PurchaseInvoiceBL objCtn = new PurchaseInvoiceBL();

            for (int i = 0; i < dgvProduct.Rows.Count; i++)
            {
                objCtn.ProductID = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objCtn.Ctn       = Convert.ToInt32(dgvProduct.Rows[i].Cells[7].Value.ToString());
                objCtn.CtnUpdate();
            }



            PurchaseInvoiceBL objmas = new PurchaseInvoiceBL()
            {
                PInvoice     = Convert.ToInt32(txtInvoiceID.Text),
                companyID    = Convert.ToInt32(txtComID.Text),
                Discount     = Convert.ToDecimal(txtBillDiscount.Text),
                PurchaseDate = DateTime.Parse(txtPurInvoiceDate.Text),
                TotalAmount  = Convert.ToDecimal(txttotalAmount.Text),
                Payment      = Convert.ToDecimal(txtTotalPay.Text),
                DuePayment   = Convert.ToDecimal(txtPayDue.Text),
                furDiscount  = Convert.ToDecimal(txtfurDiscount.Text),
                GrandTotal   = Convert.ToDecimal(txtGrandTotal.Text)
            };

            PurchaseInvoiceBL objDet = new PurchaseInvoiceBL();

            for (int i = 0; i < dgvProduct.Rows.Count; i++)
            {
                objDet.PInvoice  = Convert.ToInt32(txtInvoiceID.Text);
                objDet.ProductID = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objDet.TP        = Convert.ToDecimal(dgvProduct.Rows[i].Cells[3].Value.ToString());
                objDet.Quantity  = Convert.ToInt32(dgvProduct.Rows[i].Cells[4].Value.ToString());
                objDet.frieght   = Convert.ToDecimal(dgvProduct.Rows[i].Cells[6].Value.ToString());
                objDet.Ctn       = Convert.ToDecimal(dgvProduct.Rows[i].Cells[7].Value.ToString());
                objDet.Amount    = Convert.ToDecimal(dgvProduct.Rows[i].Cells[8].Value.ToString());
                objDet.SaveDetail();
            }
            objmas.SaveMaster();
            PurchaseLedgerBL objLedger = new PurchaseLedgerBL();

            objLedger.PInvoice    = Convert.ToInt32(txtInvoiceID.Text);
            objLedger.CompanyID   = Convert.ToInt32(txtComID.Text);
            objLedger.Credit      = Convert.ToDecimal(txtPayDue.Text);
            objLedger.Debit       = 0;
            objLedger.Date        = Convert.ToDateTime(txtPurInvoiceDate.Text);
            objLedger.Balance     = Convert.ToDecimal(txtnewBalance.Text);
            objLedger.Description = "Debit";
            objLedger.save();
            (new PurchaseLedgerBL()).UpdateBalance(objLedger.Balance, objLedger.CompanyID);

            PurchaseInvoiceReport objretp = new PurchaseInvoiceReport();
            rptViewer             objView = new rptViewer();

            objretp.SetParameterValue("@PInvoice", txtInvoiceID.Text);
            PurchaseInvoiceBL objBl = new PurchaseInvoiceBL()
            {
                PInvoice = Convert.ToInt32(txtInvoiceID.Text)
            };
            var dt = objBl.Search();

            if (dt != null)
            {
                objretp.SetDataSource(dt);
                objView.crptViewer.ReportSource = objretp;
                objView.WindowState             = FormWindowState.Maximized;
                objView.ShowDialog();
            }
            ClearForm();
            ChkFrieghtOrder.Checked = false;
            btnNew.Enabled          = true;
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ReturnSaleBL objMas = new ReturnSaleBL()
            {
                Invoiceno    = Convert.ToInt32(txtInvoiceID.Text),
                ReturnAmount = Convert.ToDecimal(txtBalance.Text),
                ReturnDate   = DateTime.Parse(txtReturnDate.Text),
                TotalBill    = Convert.ToDecimal(txtTotalBill.Text),
                ReturnCash   = Convert.ToDecimal(txtReturnCash.Text),
                CustomerID   = Convert.ToInt32(txtCusID.Text)
            };
            ReturnSaleBL objDetail = new ReturnSaleBL();

            for (int i = 0; i < dgvReturnItem.Rows.Count; i++)
            {
                objDetail.RInvoice  = Convert.ToInt32(txtReturnID.Text);
                objDetail.ProductID = Convert.ToInt32(dgvReturnItem.Rows[i].Cells[2].Value.ToString());
                objDetail.RP        = Convert.ToDecimal(dgvReturnItem.Rows[i].Cells[4].Value.ToString());
                objDetail.Ctn       = Convert.ToDecimal(dgvReturnItem.Rows[i].Cells[5].Value.ToString());
                objDetail.Quantity  = Convert.ToInt32(dgvReturnItem.Rows[i].Cells[6].Value.ToString());
                objDetail.Discount  = Convert.ToDecimal(dgvReturnItem.Rows[i].Cells[7].Value.ToString());
                objDetail.Amount    = Convert.ToDecimal(dgvReturnItem.Rows[i].Cells[8].Value.ToString());
                objDetail.SaveDetail();
            }
            PurchaseInvoiceBL objPur = new PurchaseInvoiceBL();

            for (int i = 0; i < dgvReturnItem.Rows.Count; i++)
            {
                objPur.ProductID = Convert.ToInt32(dgvReturnItem.Rows[0].Cells[2].Value.ToString());
                objPur.Quantity  = Convert.ToInt32(dgvReturnItem.Rows[0].Cells[6].Value.ToString());
                objPur.ProdUpdate();
            }

            PurchaseInvoiceBL objCtn = new PurchaseInvoiceBL();

            for (int i = 0; i < dgvReturnItem.Rows.Count; i++)
            {
                objCtn.ProductID = Convert.ToInt32(dgvReturnItem.Rows[0].Cells[2].Value.ToString());
                objCtn.Ctn       = Convert.ToInt32(dgvReturnItem.Rows[0].Cells[5].Value.ToString());
                objCtn.CtnUpdate();
            }

            SaleLedgerBL objLedger = new SaleLedgerBL();

            objLedger.RInvoice    = Convert.ToInt32(txtReturnID.Text);
            objLedger.CustomerID  = Convert.ToInt32(txtCusID.Text);
            objLedger.Debit       = Convert.ToDecimal(txtBalance.Text);
            objLedger.Credit      = 0;
            objLedger.Date        = Convert.ToDateTime(txtReturnDate.Text);
            objLedger.Balance     = Convert.ToDecimal(txtnewBalance.Text);
            objLedger.Description = "Debit";
            objLedger.Save();
            (new SaleLedgerBL()).UpdateBalance(objLedger.Balance, objLedger.CustomerID);


            //ReturnSaleBL objDue = new ReturnSaleBL()
            //{
            //    CustomerID = Convert.ToInt32(txtCusID.Text),
            //    DuePayment = Convert.ToDecimal(txtBalance.Text)
            //};
            //objDue.UpdateDueSub();

            if (txtBalance.Text != "0.00")
            {
                SaleRecoveryBL objRec = new SaleRecoveryBL()
                {
                    CustomerID   = Convert.ToInt32(txtCusID.Text),
                    RecoveryDate = Convert.ToDateTime(txtReturnDate.Text),
                    RInvoice     = Convert.ToInt32(txtReturnID.Text),
                    ReturnCash   = Convert.ToDecimal(txtBalance.Text)
                };
                objRec.Save();
            }

            objMas.SaveMaster();

            SaleReturnReport objRep  = new SaleReturnReport();
            rptViewer        objView = new rptViewer();

            objRep.SetParameterValue("@RinvoiceNo", txtReturnID.Text);
            ReturnSaleBL obj = new ReturnSaleBL()
            {
                RInvoice = Convert.ToInt32(txtReturnID.Text)
            };
            DataTable dt = obj.Select();

            if (dt.Rows.Count > 0)
            {
                objRep.SetDataSource(dt);
            }
            objView.crptViewer.ReportSource = objRep;
            objView.WindowState             = FormWindowState.Normal;
            objView.ShowDialog();
            ClearForm();
            btnNew.Enabled = true;
        }