private void btnCusID_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtRinvoiceNo.Text)) { SaleReturnReport objRet = new SaleReturnReport(); rptViewer objView = new rptViewer(); objRet.SetParameterValue("@RinvoiceNo", txtRinvoiceNo.Text); ReturnSaleBL obj = new ReturnSaleBL() { RInvoice = Convert.ToInt32(txtRinvoiceNo.Text) }; DataTable dt = obj.Select(); if (dt.Rows.Count > 0) { objRet.SetDataSource(dt); objView.crptViewer.ReportSource = objRet; objView.WindowState = FormWindowState.Maximized; objView.ShowDialog(); //crptViewerReturn.ReportSource = objRet; txtRinvoiceNo.Clear(); } else { MessageBox.Show("No Record Found"); } } else if (!string.IsNullOrEmpty(txtCus.Text)) { ReturnByCusReport objCus = new ReturnByCusReport(); rptViewer objView = new rptViewer(); objCus.SetParameterValue("@CusID", txtCus.Text); ReturnSaleBL obj = new ReturnSaleBL() { CustomerID = Convert.ToInt32(txtCus.Text) }; DataTable dt = obj.SelectByCus(); if (dt.Rows.Count > 0) { objCus.SetDataSource(dt); objView.crptViewer.ReportSource = objCus; objView.WindowState = FormWindowState.Normal; objView.ShowDialog(); txtCus.Clear(); } else { MessageBox.Show("No Record Found"); } } //crptViewerReturn.ReportSource = objCus; else { MessageBox.Show("Please Enter Customer ID OR Return Invoice"); } }
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; }