private void btnSave_Click(object sender, EventArgs e)
        {
            SaleRecoveryBL objRec = new SaleRecoveryBL()
            {
                CustomerID   = Convert.ToInt32(txtCusID.Text),
                ReturnCash   = Convert.ToDecimal(txtReturnCash.Text),
                RecoveryDate = Convert.ToDateTime(txtRecoveryDate.Text),
            };

            objRec.Save();

            SaleLedgerBL objLedger = new SaleLedgerBL();


            if (string.IsNullOrEmpty(txtDescription.Text))
            {
                objLedger.CustomerID  = Convert.ToInt32(txtCusID.Text);
                objLedger.SRecoveryID = Convert.ToInt32(txtSRecoveryID.Text);

                objLedger.Credit      = 0;
                objLedger.Debit       = Convert.ToDecimal(txtReturnCash.Text);
                objLedger.Date        = Convert.ToDateTime(txtRecoveryDate.Text);
                objLedger.Balance     = Convert.ToDecimal(txtNewBalance.Text);
                objLedger.Description = "Debit";
                objLedger.Save();
            }
            else
            {
                objLedger.CustomerID  = Convert.ToInt32(txtCusID.Text);
                objLedger.SRecoveryID = Convert.ToInt32(txtSRecoveryID.Text);

                objLedger.Credit      = 0;
                objLedger.Debit       = Convert.ToDecimal(txtReturnCash.Text);
                objLedger.Date        = Convert.ToDateTime(txtRecoveryDate.Text);
                objLedger.Balance     = Convert.ToDecimal(txtNewBalance.Text);
                objLedger.Description = txtDescription.Text;
                objLedger.Save();
            }


            //ReturnSaleBL objRet = new ReturnSaleBL()
            //{
            //  CustomerID = Convert.ToInt32(txtCusID.Text),
            //    DuePayment = Convert.ToDecimal(txtReturnCash.Text)
            //};
            //objRet.UpdateDueSub();
            (new SaleLedgerBL()).UpdateBalance(objLedger.Balance, objLedger.CustomerID);

            MessageBox.Show("Recovery Completed " + txtCusID.Text + "and Recovery Amount " + txtReturnCash.Text);
            //SaleRecoveryIDReport objrpt = new SaleRecoveryIDReport();
            //objrpt.SetParameterValue("@RecoveryID", txtSRecoveryID.Text);
            //rptViewer objView = new rptViewer();
            //objView.crptViewer.ReportSource = objrpt;
            ////objView.crptViewer.RefreshReport();
            //objView.WindowState = FormWindowState.Normal;
            //objView.ShowDialog();
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         decimal prebal = Convert.ToDecimal(txtPreBalance.Text);
         if (FormValidate() == true)
         {
             CustomerBL objcus = new CustomerBL()
             {
                 Name       = txtCusName.Text,
                 Email      = txtEmail.Text,
                 Address    = txtAddress.Text,
                 Contact    = txtContact.Text,
                 CusTypeID  = Convert.ToInt32(txtCusType.SelectedValue),
                 ZoneID     = Convert.ToInt32(txtZoneID.SelectedValue),
                 SubZoneId  = Convert.ToInt32(txtSubZone.SelectedValue),
                 Duepayment = Convert.ToDecimal(txtPreBalance.Text)
             };
             if (prebal > 0)
             {
                 SaleLedgerBL objBl = new SaleLedgerBL()
                 {
                     CustomerID  = Convert.ToInt32(txtCusID.Text),
                     Credit      = Convert.ToDecimal(prebal),
                     Debit       = Convert.ToDecimal("0.00"),
                     Date        = Convert.ToDateTime(DateTime.Now.ToShortDateString()),
                     Balance     = Convert.ToDecimal(prebal),
                     Description = "Opening Balance"
                 };
                 objBl.Save();
             }
             objcus.Save();
             MessageBox.Show("Record Saved Successfull");
             LoadData();
             btnAddnew.Enabled = true;
             btnSave.Enabled   = false;
             ClearGroup();
         }
         else
         {
             MessageBox.Show("Some Error Occur No Record Save");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
     }
 }
Example #3
0
        //private void SumDetailProduct()
        //{
        //    decimal sum = 0;
        //    for (int i = 0; i < dgvProduct.Rows.Count; ++i)
        //    {
        //        sum += Convert.ToDecimal(resultTP);
        //    }
        //    resultGrand = Convert.ToDecimal(sum.ToString());

        //}



        private void btnSave_Click(object sender, EventArgs e)
        {
            SaleInvoiceBL objProd = new SaleInvoiceBL();

            for (int i = 0; i < dgvProduct.Rows.Count; ++i)
            {
                objProd.ProductID = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objProd.Quantity  = Convert.ToInt32(dgvProduct.Rows[i].Cells[6].Value.ToString());
                objProd.UpdateProd();
            }

            PurchaseReturnBL objCtn = new PurchaseReturnBL();

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



            SaleInvoiceBL objsale = new SaleInvoiceBL();
            decimal       Ssum    = 0;

            for (int i = 0; i < dgvProduct.Rows.Count; ++i)
            {
                objsale.InvoiceNo   = Convert.ToInt32(txtInvoiceID.Text);
                objsale.ProductID   = Convert.ToInt32(dgvProduct.Rows[i].Cells[1].Value.ToString());
                objsale.Ctn         = Convert.ToDecimal(dgvProduct.Rows[i].Cells[5].Value.ToString());
                objsale.Quantity    = Convert.ToInt32(dgvProduct.Rows[i].Cells[6].Value.ToString());
                objsale.Discount    = Convert.ToDecimal(dgvProduct.Rows[i].Cells[7].Value.ToString());
                objsale.TotalAmount = Convert.ToDecimal(dgvProduct.Rows[i].Cells[8].Value.ToString());

                decimal TP = Convert.ToDecimal(dgvProduct.Rows[i].Cells[3].Value.ToString());
                objsale.RP = Convert.ToDecimal(dgvProduct.Rows[i].Cells[4].Value);
                decimal resultRP = (objsale.RP * objsale.Ctn) - objsale.Discount;
                decimal resultTP = (TP * objsale.Ctn);
                decimal detailP  = Convert.ToDecimal(resultRP - resultTP);
                objsale.DetailProfit = detailP;
                Ssum += resultTP;
                objsale.SaveDetail();
            }

            decimal       grandtotal    = Convert.ToDecimal(txtGrandTotal.Text);
            decimal       InvoiceProfit = grandtotal - Ssum;
            SaleInvoiceBL objmas        = new SaleInvoiceBL()
            {
                SaleDate     = DateTime.Parse(txtInvoiceDate.Text),
                GrandTotal   = Convert.ToDecimal(txtGrandTotal.Text),
                CustomerID   = Convert.ToInt32(txtCusId.Text),
                Payment      = Convert.ToDecimal(txtTotalPay.Text),
                DuePayment   = Convert.ToDecimal(txtDuePay.Text),
                OrderBy      = txtSalesman.Text,
                MasterProfit = InvoiceProfit
            };

            objmas.SaveMaster();

            SaleLedgerBL objLedger = new SaleLedgerBL();

            objLedger.Invoiceno  = Convert.ToInt32(txtInvoiceID.Text);
            objLedger.CustomerID = Convert.ToInt32(txtCusId.Text);
            objLedger.Credit     = Convert.ToDecimal(txtDuePay.Text);
            objLedger.Debit      = 0;



            objLedger.Date        = Convert.ToDateTime(txtInvoiceDate.Text);
            objLedger.Balance     = Convert.ToDecimal(txtnewBalance.Text);
            objLedger.Description = "Credit";
            objLedger.Save();
            (new SaleLedgerBL()).UpdateBalance(objLedger.Balance, objLedger.CustomerID);

            saleInvoiceReport objSale = new saleInvoiceReport();
            rptViewer         objview = new rptViewer();

            //objSale.SetDataSource =;
            objSale.SetParameterValue("@InvoiceNo", txtInvoiceID.Text);
            SaleInvoiceBL obj = new SaleInvoiceBL()
            {
                InvoiceNo = Convert.ToInt32(txtInvoiceID.Text)
            };
            DataTable dt = obj.Search();

            if (dt.Rows.Count > 0)
            {
                objSale.SetDataSource(dt);
            }
            objview.crptViewer.ReportSource = objSale;
            objview.WindowState             = FormWindowState.Normal;

            objview.ShowDialog();
            ClearForm();
            dgvProduct.DataSource = null;
            btnNew.Enabled        = true;
        }
Example #4
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;
        }