Exemple #1
0
        public void ReportHeader(CashReceiptVoucher data)
        {
            _fontStyle       = FontFactory.GetFont("Tahoma", 8f, 1);
            _PdfCell         = new PdfPCell(new Phrase("created by " + Session["UserName"].ToString() + ".", _fontStyle));
            _PdfCell.Colspan = 3;
            // _PdfCell.Width = 2;
            _PdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            //_PdfCell.VerticalAlignment = Element.ALIGN_BOTTOM;
            _PdfCell.Border = 0;
            _table2.AddCell(_PdfCell);


            var logo = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Content/img/LOGO.jpg"));
            //logo.SetAbsolutePosition(400,2000);
            //_document.Add(logo);

            string imageURL = Server.MapPath("~/Content/img/LOGO.jpg");

            jpg = iTextSharp.text.Image.GetInstance(imageURL);

            //Resize image depend upon your need

            jpg.ScaleToFit(140f, 120f);

            //Give space before image

            jpg.SpacingBefore = 10f;

            //Give some space after the image

            jpg.SpacingAfter = 1f;

            jpg.Alignment = Element.ALIGN_LEFT;

//            _document.Add(jpg);

            _fontStyle                   = _fontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14f, BaseColor.BLACK);
            _PdfCell                     = new PdfPCell(new Phrase(" ", _fontStyle));
            _PdfCell.Colspan             = _tablecolumn;
            _PdfCell.HorizontalAlignment = Element.ALIGN_CENTER;
            _PdfCell.Border              = 0;
            _PdfCell.BackgroundColor     = BaseColor.WHITE;
            _PdfCell.ExtraParagraphSpace = 0;
            _PdfTable.AddCell(_PdfCell);
            _PdfTable.CompleteRow();


            _fontStyle                   = _fontStyle = FontFactory.GetFont(FontFactory.TIMES_ROMAN, 14f, 1);
            _PdfCell                     = new PdfPCell(new Phrase("Cash Reciept Voucher", _fontStyle));
            _PdfCell.Colspan             = _tablecolumn;
            _PdfCell.HorizontalAlignment = Element.ALIGN_CENTER;
            _PdfCell.Border              = 0;
            _PdfCell.BackgroundColor     = BaseColor.WHITE;
            _PdfCell.ExtraParagraphSpace = 0;
            _PdfTable.AddCell(_PdfCell);
            _PdfTable.CompleteRow();
        }
Exemple #2
0
        // GET: shart
        public JsonResult Index(CashReceiptVoucher data)

        {
            byte[] abytes       = prepareReport(data);
            string base64String = Convert.ToBase64String(abytes, 0, abytes.Length);

            return(Json(base64String, JsonRequestBehavior.AllowGet));

            //return File(base64String, "application/pdf");
            //Response.AppendHeader("content-disposition", "inline; filename=file.pdf");
            //return new FileStreamResult(prepareReport(data), "application/pdf");
            #region

            #endregion
        }
Exemple #3
0
        public ActionResult AddCashReceiptVoucher(CashReceiptVoucher data)
        {
            if (data.ID == 0)
            {
                data.Amount = Convert.ToInt32(data.AmountWithComma.Replace(",", ""));
                db.CashReceiptVouchers.Add(data);
            }
            else
            {
                db.Entry(data).State = System.Data.Entity.EntityState.Modified;
            }
            db.SaveChanges();

            return(RedirectToAction("CashReceiptVoucher", "Reciept"));
        }
Exemple #4
0
        public byte[] prepareReport(CashReceiptVoucher data)
        {
            //public MemoryStream prepareReport(cashPaymentVoucher data) {

            _document = new Document(PageSize.A4, 0f, 0f, 0f, 0f);
            _document.SetPageSize(PageSize.A4);
            _document.SetMargins(20f, 20f, 20f, 20f);

            _PdfTable.WidthPercentage     = 100;
            _table1.WidthPercentage       = 100;
            _table1.HorizontalAlignment   = Element.ALIGN_LEFT;
            _PdfTable.HorizontalAlignment = Element.ALIGN_LEFT;

            _table2.WidthPercentage     = 100;
            _table2.HorizontalAlignment = Element.ALIGN_LEFT;


            _table4.WidthPercentage     = 100;
            _table4.HorizontalAlignment = Element.ALIGN_LEFT;


            _fontStyle = FontFactory.GetFont("Tahoma", 8f, 1);
            PdfWriter.GetInstance(_document, _memoryStream);
            _document.Open();
            _PdfTable.SetWidths(new float[] { 40f, 10f, 10f });

            _table1.SetWidths(new float[] { 10f, 30f });
            _table2.SetWidths(new float[] { 40f, 10f, 20f });
            _table4.SetWidths(new float[] { 40f, 40f, 40f, 40f });


            _PdfTable.SpacingBefore = 10;
            _table2.SpacingBefore   = 50;
            _table2.SpacingBefore   = 50;
            this.ReportHeader(data);
            this.ReportBody(data);
            _PdfTable.HeaderRows = 2;

            _document.Add(_table2);
            _document.Add(jpg);
            _document.Add(_PdfTable);
            _document.Add(_table1);
            _document.Add(_table4);
            _document.Close();
            //return _memoryStream.ToArray();

            return(_memoryStream.ToArray());
        }
        private void button17_Click(object sender, EventArgs e)
        {
            //Hide sub menu filemaintenance
            panelProcessSub.Visible = false;

            //controls
            foreach (Form form in Application.OpenForms)
            {
                if (form.GetType() == typeof(CashReceiptVoucher))
                {
                    form.Activate();
                    return;
                }
            }

            CashReceiptVoucher frm = new CashReceiptVoucher();

            frm.Show();
            frm.MdiParent = this;
        }
Exemple #6
0
        public void ReportBody(CashReceiptVoucher data)
        {
            _fontStyle                   = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell                     = new PdfPCell(new Phrase("\n"));
            _PdfCell.Border              = 0;
            _PdfCell.Colspan             = 3;
            _PdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            _PdfTable.AddCell(_PdfCell);
            _PdfTable.CompleteRow();

            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            _PdfTable.AddCell(_PdfCell);

            _fontStyle = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell   = new PdfPCell(new Phrase("Voucer No: ", _fontStyle));
            //_PdfCell.Colspan = 2;
            //  _PdfCell.Width = 2;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _PdfTable.AddCell(_PdfCell);

            _PdfCell = new PdfPCell(new Phrase(data.VNumber.ToString(), _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _PdfTable.AddCell(_PdfCell);
            _PdfTable.CompleteRow();
            //-------------//

            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            _PdfTable.AddCell(_PdfCell);

            _fontStyle = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell   = new PdfPCell(new Phrase("Date : ", _fontStyle));
            //_PdfCell.Colspan = 2;
            // _PdfCell.Width = 2;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _PdfTable.AddCell(_PdfCell);

            _PdfCell = new PdfPCell(new Phrase(data.Date.ToString(), _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            //_PdfCell.Width = 2;
            _PdfTable.AddCell(_PdfCell);
            _PdfTable.CompleteRow();

            //-------------//

            //-------------//

            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            _PdfTable.AddCell(_PdfCell);

            _fontStyle = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell   = new PdfPCell(new Phrase("Category : ", _fontStyle));
            //_PdfCell.Colspan = 2;
            // _PdfCell.Width = 2;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _PdfTable.AddCell(_PdfCell);

            _PdfCell = new PdfPCell(new Phrase(data.Category, _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            //_PdfCell.Width = 2;
            _PdfTable.AddCell(_PdfCell);
            _PdfTable.CompleteRow();

            //-------------//


            //----------//
            _PdfCell = new PdfPCell(new Phrase("\n"));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border  = 0;
            _PdfCell.Colspan = 2;
            _table1.AddCell(_PdfCell);
            _table1.CompleteRow();



            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("Received From: ", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _table1.AddCell(_PdfCell);
            _PdfCell = new PdfPCell(new Phrase(data.Received_From.ToString(), _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _table1.AddCell(_PdfCell);
            _table1.CompleteRow();


            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("Amount: ", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _table1.AddCell(_PdfCell);
            _PdfCell = new PdfPCell(new Phrase(data.AmountWithComma.ToString(), _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _table1.AddCell(_PdfCell);
            _table1.CompleteRow();


            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("Rupees: ", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _table1.AddCell(_PdfCell);
            _PdfCell = new PdfPCell(new Phrase(data.Rupees.ToString(), _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _table1.AddCell(_PdfCell);
            _table1.CompleteRow();

            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("AC Description: ", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _table1.AddCell(_PdfCell);
            _PdfCell = new PdfPCell(new Phrase(data.A_C_Description.ToString(), _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _table1.AddCell(_PdfCell);
            _table1.CompleteRow();


            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("Narration: ", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _table1.AddCell(_PdfCell);
            _PdfCell = new PdfPCell(new Phrase(data.Narration.ToString(), _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border = 0;
            _table1.AddCell(_PdfCell);
            _table1.CompleteRow();



            //-------------//

            //----------//
            _PdfCell = new PdfPCell(new Phrase("\n"));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border  = 0;
            _PdfCell.Colspan = 2;
            _table1.AddCell(_PdfCell);
            _table4.CompleteRow();

            _PdfCell = new PdfPCell(new Phrase("\n"));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border  = 0;
            _PdfCell.Colspan = 2;
            _table1.AddCell(_PdfCell);
            _table4.CompleteRow();

            _PdfCell = new PdfPCell(new Phrase("\n"));
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _PdfCell.Border  = 0;
            _PdfCell.Colspan = 2;
            _table1.AddCell(_PdfCell);
            _table4.CompleteRow();



            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("Prepared: ________", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _table4.AddCell(_PdfCell);

            _fontStyle      = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell        = new PdfPCell(new Phrase("Approval: ________", _fontStyle));
            _PdfCell.Border = 0;
            _PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            _table4.AddCell(_PdfCell);

            _fontStyle = FontFactory.GetFont("Tahoma", 12f, 1);
            _PdfCell   = new PdfPCell(new Phrase("Posted: ________", _fontStyle));
            //_PdfCell.Colspan = 2;
            // _PdfCell.Width = 2;
            _PdfCell.HorizontalAlignment = Element.ALIGN_CENTER;
            _PdfCell.Border = 0;
            _table4.AddCell(_PdfCell);

            _PdfCell = new PdfPCell(new Phrase("Received: ________", _fontStyle));
            _PdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            _PdfCell.Border = 0;
            //_PdfCell.Width = 2;
            _table4.AddCell(_PdfCell);
            _table4.CompleteRow();


            //_PdfCell = new PdfPCell(new Phrase("\n", _fontStyle));
            //_PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            //_PdfCell.Border = 0;
            //_PdfCell.Colspan = 3;
            ////_PdfCell.Width = 2;
            //_table4.AddCell(_PdfCell);
            //_table4.CompleteRow();


            //_PdfCell = new PdfPCell(new Phrase("\n", _fontStyle));
            //_PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            //_PdfCell.Border = 0;
            //_PdfCell.Colspan = 3;
            ////_PdfCell.Width = 2;
            //_table4.AddCell(_PdfCell);
            //_table4.CompleteRow();


            //-------------//



            //-------------//

            //_fontStyle = FontFactory.GetFont("Tahoma", 12f, 1);
            //_PdfCell = new PdfPCell(new Phrase("", _fontStyle));
            //_PdfCell.Border = 0;
            //_PdfCell.HorizontalAlignment = Element.ALIGN_RIGHT;
            //_table2.AddCell(_PdfCell);

            //_fontStyle = FontFactory.GetFont("Tahoma", 12f, 1);
            //_PdfCell = new PdfPCell(new Phrase("Signature : ", _fontStyle));
            ////_PdfCell.Colspan = 2;
            //// _PdfCell.Width = 2;
            //_PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            //_PdfCell.Border = 0;
            //_table2.AddCell(_PdfCell);

            //_PdfCell = new PdfPCell(new Phrase("________________", _fontStyle));
            //_PdfCell.HorizontalAlignment = Element.ALIGN_LEFT;
            //_PdfCell.Border = 0;
            ////_PdfCell.Width = 2;
            //_table2.AddCell(_PdfCell);
            //_table2.CompleteRow();

            //-------------//
        }
        //===================================================================
        //                  USE RECEIPT VOUCHER
        //===================================================================
        public void useReceipt()
        {
            if (dgvList.SelectedRows.Count > 0)
            {
                CashReceiptVoucher or = new CashReceiptVoucher();

                using (SqlConnection con = new SqlConnection(global.connectString()))
                {
                    con.Open();

                    SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Cash_Receipts_Header WHERE Or_No = '" + dgvList.SelectedRows[0].Cells["voucherRealNo"].Value.ToString() + "'", con);
                    DataSet        ds      = new DataSet();
                    adapter.Fill(ds);

                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        //=========================================================================================
                        //                              Header Information
                        //=========================================================================================

                        Classes.clsCashReceipt.userID = Convert.ToInt32(ds.Tables[0].Rows[0]["userID"].ToString());
                        or.txtORNo.Text  = dgvList.SelectedRows[0].Cells["voucherRealNo"].Value.ToString();
                        or.dtOrDate.Text = ds.Tables[0].Rows[0]["Or_Date"].ToString();

                        if (ds.Tables[0].Rows[0]["Payor_Type"].ToString() == "True")
                        {
                            or.radioClient.Checked = true;
                            //Return Company Name According to ID
                            or.txtPayorName.Text = clsSearchCash.returnClientName(ds.Tables[0].Rows[0]["Payor"].ToString());
                        }
                        else
                        {
                            or.radioMember.Checked = true;
                            //Return Member Name According to ID
                            or.txtPayorName.Text    = clsSearchCash.returnMembersName(ds.Tables[0].Rows[0]["userID"].ToString());
                            or.txtPayorCompany.Text = clsCash.returnCompanyDescription(clsSearchCash.GetCompanyPerMember(ds.Tables[0].Rows[0]["userID"].ToString()));
                        }

                        or.txtPayorID.Text     = ds.Tables[0].Rows[0]["Payor"].ToString();
                        or.txtParticulars.Text = ds.Tables[0].Rows[0]["Particulars"].ToString();

                        //=========================================================================================
                        //                      COLLECTION TYPE
                        //=========================================================================================
                        //0 = cash
                        //1 = pecci check
                        //2 = non-pecci check
                        if (ds.Tables[0].Rows[0]["Collection_Type"].ToString() == "0")
                        {
                            or.radioCash.Checked = true;
                        }
                        else if (ds.Tables[0].Rows[0]["Collection_Type"].ToString() == "1")
                        {
                            or.radioPecciCheck.Checked = true;
                        }
                        else
                        {
                            or.radioNonPecciCheck.Checked = true;
                        }

                        //=========================================================================================
                        //                      Transaction Header
                        //=========================================================================================
                        clsSearchCash.loadTransaction(or.datagridviewTransaction, dgvList.SelectedRows[0].Cells["voucherRealNo"].Value.ToString());

                        //=========================================================================================
                        //                      Bank Details
                        //=========================================================================================
                        if (ds.Tables[0].Rows[0]["Collection_Type"].ToString() == "1" || ds.Tables[0].Rows[0]["Collection_Type"].ToString() == "2")
                        {
                            clsSearchCash.loadBanksCheck(or.dgvChecks, dgvList.SelectedRows[0].Cells["voucherRealNo"].Value.ToString());

                            //Disable Bank Grid and buttons
                            or.dgvChecks.Enabled      = false;
                            or.btnAddCheck.Enabled    = false;
                            or.btnRemoveCheck.Enabled = false;
                        }
                        else
                        {
                            or.dgvChecks.Rows.Clear();
                        }

                        //=========================================================================================
                        //                      Cash Receipt Details
                        //=========================================================================================

                        clsSearchCash.loadCashReceiptsDetails(or.dataGridView3, dgvList.SelectedRows[0].Cells["voucherRealNo"].Value.ToString());

                        //=========================================================================================
                        //                      Cash Receipt Footer
                        //=========================================================================================
                        or.txtPostedBy.Text    = ds.Tables[0].Rows[0]["Posted_By"].ToString();
                        or.txtCancelledBy.Text = ds.Tables[0].Rows[0]["Cancelled_By"].ToString();

                        if (ds.Tables[0].Rows[0]["Posted"].ToString() == "True" || ds.Tables[0].Rows[0]["Posted"].ToString() == "1")
                        {
                            or.status.Visible = true;
                            or.status.Text    = "POSTED";
                        }
                        else if (ds.Tables[0].Rows[0]["Cancelled"].ToString() == "True" || ds.Tables[0].Rows[0]["Cancelled"].ToString() == "1")
                        {
                            or.status.Visible = true;
                            or.status.Text    = "CANCELLED";
                        }
                        else
                        {
                            or.status.Visible = false;
                        }


                        //Location of OR as Per Maam Diane Request
                        if (ds.Tables[0].Rows[0]["Location"].ToString() == "PEREA")
                        {
                            or.radioLocPerea.Checked = true;
                        }
                        else
                        {
                            or.radioLocTeltech.Checked = true;
                        }

                        //Put Prepared By
                        or.txtPreparedBy.Text = ds.Tables[0].Rows[0]["Prepared_By"].ToString();
                        or.txtAuditedBy.Text  = ds.Tables[0].Rows[0]["Audited_By"].ToString();

                        //Enable Commands
                        or.btnEdit.Enabled     = true;
                        or.btnPost.Enabled     = true;
                        or.btnCancel.Enabled   = true;
                        or.btnAuditted.Enabled = true;

                        or.fromTH = true;

                        or.ShowDialog();
                    }
                }
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (clsAccess.checkForViewingRestriction("PDC Management", Classes.clsUser.Username) != true)
            {
                return;
            }

            if (dataGridView1.Rows.Count > 0)
            {
                if (dataGridView1.SelectedRows[0].Cells["ORNumber"].Value.ToString() != "")
                {
                    CashReceiptVoucher or = new CashReceiptVoucher();

                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType() == typeof(CashReceiptVoucher))
                        {
                            form.Activate();
                            or = (CashReceiptVoucher)Application.OpenForms["CashReceiptVoucher"];
                        }
                    }
                    //REMOVE GRID FIRST
                    or.datagridviewTransaction.Rows.Clear();
                    or.dataGridView3.Rows.Clear();
                    or.dgvChecks.Rows.Clear();

                    //REMOVE THE OPEN OR FIRST
                    if (or.txtORNo.Text != "")
                    {
                        clsOpen.deleteTransaction("Receipt Voucher", or.txtORNo.Text);
                    }

                    or.txtORNo.Text = dataGridView1.SelectedRows[0].Cells["ORNumber"].Value.ToString();
                    //========================================================
                    //          PAYOR INFORMATION
                    //========================================================
                    Classes.clsCashReceipt.userID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                    or.txtPayorID.Text            = dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString();
                    or.txtPayorName.Text          = dataGridView1.SelectedRows[0].Cells["EmpName"].Value.ToString();
                    or.txtPayorCompany.Text       = clsCash.returnCompanyDescription(clsSearchCash.GetCompanyPerMember(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));
                    or.radioMember.Checked        = true;

                    //========================================================
                    //          PAYOR TRANSACTION
                    //========================================================
                    or.radioPecciCheck.Checked = true;

                    using (SqlConnection con = new SqlConnection(global.connectString()))
                    {
                        con.Open();

                        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM PDCManagementv2_details WHERE ChequeNo = '" + dataGridView1.SelectedRows[0].Cells["ChequeNo"].Value.ToString() + "'", con);
                        DataSet        ds      = new DataSet();
                        adapter.Fill(ds);

                        //================================================
                        //          COCI FOR DETAILS
                        //================================================
                        or.dataGridView3.Rows.Add(
                            "105", "", "", Convert.ToDecimal(dataGridView1.SelectedRows[0].Cells["TotalAmount"].Value.ToString()).ToString("#,0.00"), "0.00", "0"
                            );

                        for (int x = 0; x < ds.Tables[0].Rows.Count; x++)
                        {
                            switch (ds.Tables[0].Rows[x]["Category"].ToString())
                            {
                            case "Savings":
                                or.datagridviewTransaction.Rows.Add(
                                    "001", "SAVINGS DEPOSIT", Convert.ToDecimal(ds.Tables[0].Rows[x]["Amount"].ToString()).ToString("#,0.00")
                                    );

                                //================================================
                                //          SAVINGS ENTRY
                                //================================================
                                or.dataGridView3.Rows.Add(
                                    "300.1", "", "", "0.00", Convert.ToDecimal(ds.Tables[0].Rows[x]["Amount"].ToString()).ToString("#,0.00"), dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()
                                    );
                                break;

                            case "Share Capital":
                                or.datagridviewTransaction.Rows.Add(
                                    "003", "FIXED DEPOSIT", Convert.ToDecimal(ds.Tables[0].Rows[x]["Amount"].ToString()).ToString("#,0.00")
                                    );

                                //================================================
                                //          SHARE CAPITAL ENTRY
                                //================================================
                                or.dataGridView3.Rows.Add(
                                    "363", "", "", "0.00", Convert.ToDecimal(ds.Tables[0].Rows[x]["Amount"].ToString()).ToString("#,0.00"), dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()
                                    );
                                break;

                            case "Loan":
                                or.datagridviewTransaction.Rows.Add(
                                    "002", clsPDCManagement.returnLoanDescription(ds.Tables[0].Rows[x]["Loan_Type"].ToString()), Convert.ToDecimal(ds.Tables[0].Rows[x]["Amount"].ToString()).ToString("#,0.00")
                                    );
                                //FOR LOAN SETUP
                                clsPDCManagement.getMonthlyDetails(or.dataGridView3, ds.Tables[0].Rows[x]["Loan_No"].ToString(), Convert.ToDouble(ds.Tables[0].Rows[x]["Amount"].ToString()), or.dgvtempBilling);
                                break;
                            }
                        }
                        or.compute();
                        or.computeDetails();
                    }

                    //========================================================
                    //              CHEQUE INFORMATION
                    //========================================================
                    or.dgvChecks.Rows.Add(
                        dataGridView1.SelectedRows[0].Cells["Bank"].Value.ToString(),
                        dataGridView1.SelectedRows[0].Cells["TotalAmount"].Value.ToString(),
                        Convert.ToDateTime(dataGridView1.SelectedRows[0].Cells["ChequeDate"].Value.ToString()).ToShortDateString(),
                        dataGridView1.SelectedRows[0].Cells["ChequeNo"].Value.ToString()
                        );


                    or.dataGridView3.Sort(or.dataGridView3.Columns["Debit"], ListSortDirection.Descending);

                    //Enable and Disable Buttons
                    or.btnEdit.Enabled     = false;
                    or.btnPost.Enabled     = false;
                    or.btnCancel.Enabled   = false;
                    or.btnAuditted.Enabled = false;
                    or.btnSearch.Enabled   = false;
                    or.btnNew.Enabled      = true;

                    or.btnNew.Text   = "SAVE";
                    or.btnEdit.Text  = "EDIT";
                    or.btnClose.Text = "CANCEL";

                    //FROM PDCMANAGEMENT
                    or.frmPDCManagement             = true;
                    or.frmPDCManagementChequeNumber = dataGridView1.SelectedRows[0].Cells["ChequeNo"].Value.ToString();
                    or.Show();
                }
                else
                {
                    Alert.show("Please update or number.", Alert.AlertType.error);
                    return;
                }
            }
        }
Exemple #9
0
        private void btnUse_Click(object sender, EventArgs e)
        {
            if (whosLookUp == "2") //From OR
            {
                //==========================================================================================
                //                      CASH RECEIPT CODE
                //==========================================================================================
                CashReceiptVoucher cashOR = new CashReceiptVoucher();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.GetType() == typeof(CashReceiptVoucher))
                    {
                        //===============================================================================
                        //                      If form is already open
                        //===============================================================================
                        form.Activate();
                        cashOR = (CashReceiptVoucher)Application.OpenForms["CashReceiptVoucher"];
                        cashOR.txtPayorID.Text   = dataGridView1.SelectedRows[0].Cells["Client_Code"].Value.ToString();
                        cashOR.txtPayorName.Text = dataGridView1.SelectedRows[0].Cells["Name"].Value.ToString();
                        this.Close();
                        return;
                    }
                }

                cashOR.txtPayorID.Text   = dataGridView1.SelectedRows[0].Cells["Client_Code"].Value.ToString();
                cashOR.txtPayorName.Text = dataGridView1.SelectedRows[0].Cells["Name"].Value.ToString();
                cashOR.Show();
                this.Close();
            }
            else
            {
                DisbursementVoucher disbursement = new DisbursementVoucher();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.GetType() == typeof(DisbursementVoucher))
                    {
                        //===============================================================================
                        //                      If form is already open
                        //===============================================================================
                        form.Activate();
                        disbursement = (DisbursementVoucher)Application.OpenForms["DisbursementVoucher"];
                        disbursement.txtPayee.Text       = dataGridView1.SelectedRows[0].Cells["Client_Code"].Value.ToString();
                        disbursement.txtPayeeName.Text   = dataGridView1.SelectedRows[0].Cells["Name"].Value.ToString();
                        disbursement.radioClient.Checked = true;
                        Classes.clsDisbursement.userID   = 0;
                        this.Close();
                        return;
                    }
                }

                disbursement.txtPayee.Text       = dataGridView1.SelectedRows[0].Cells["Client_Code"].Value.ToString();
                disbursement.txtPayeeName.Text   = dataGridView1.SelectedRows[0].Cells["Name"].Value.ToString();
                disbursement.radioClient.Checked = true;
                Classes.clsDisbursement.userID   = 0;
                disbursement.Show();

                this.Close();
                disbursement.Show();
            }
        }
Exemple #10
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                CashReceiptVoucher or = new CashReceiptVoucher();

                or = (CashReceiptVoucher)Application.OpenForms["CashReceiptVoucher"];

                //=========================================================================================
                //                              Header Information
                //=========================================================================================

                Classes.clsCashReceipt.userID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                or.txtORNo.Text  = dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString();
                or.dtOrDate.Text = dataGridView1.SelectedRows[0].Cells["Or_Date"].Value.ToString();

                if (dataGridView1.SelectedRows[0].Cells["Payor_Type"].Value.ToString() == "True")
                {
                    or.radioClient.Checked = true;
                    //Return Company Name According to ID
                    or.txtPayorName.Text = clsSearchCash.returnClientName(dataGridView1.SelectedRows[0].Cells["Payor"].Value.ToString());
                }
                else
                {
                    or.radioMember.Checked = true;
                    //Return Member Name According to ID
                    or.txtPayorName.Text    = clsSearchCash.returnMembersName(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                    or.txtPayorCompany.Text = clsCash.returnCompanyDescription(clsSearchCash.GetCompanyPerMember(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));
                }

                or.txtPayorID.Text     = dataGridView1.SelectedRows[0].Cells["Payor"].Value.ToString();
                or.txtParticulars.Text = dataGridView1.SelectedRows[0].Cells["Particulars"].Value.ToString();

                //=========================================================================================
                //                      COLLECTION TYPE
                //=========================================================================================
                //0 = cash
                //1 = pecci check
                //2 = non-pecci check
                if (dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "0")
                {
                    or.radioCash.Checked = true;
                }
                else if (dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "1")
                {
                    or.radioPecciCheck.Checked = true;
                }
                else
                {
                    or.radioNonPecciCheck.Checked = true;
                }

                //=========================================================================================
                //                      Transaction Header
                //=========================================================================================
                clsSearchCash.loadTransaction(or.datagridviewTransaction, dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString());


                //=========================================================================================
                //                      Bank Details
                //=========================================================================================
                if (dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "1" || dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "2")
                {
                    clsSearchCash.loadBanksCheck(or.dgvChecks, dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString());

                    //Disable Bank Grid and buttons
                    or.dgvChecks.Enabled      = false;
                    or.btnAddCheck.Enabled    = false;
                    or.btnRemoveCheck.Enabled = false;
                }
                else
                {
                    or.dgvChecks.Rows.Clear();
                }


                //=========================================================================================
                //                      Cash Receipt Details
                //=========================================================================================

                clsSearchCash.loadCashReceiptsDetails(or.dataGridView3, dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString());


                //=========================================================================================
                //                      Cash Receipt Footer
                //=========================================================================================
                or.txtPostedBy.Text    = dataGridView1.SelectedRows[0].Cells["Posted_By"].Value.ToString();
                or.txtCancelledBy.Text = dataGridView1.SelectedRows[0].Cells["Cancelled_By"].Value.ToString();

                if (dataGridView1.SelectedRows[0].Cells["Posted"].Value.ToString() == "True" || dataGridView1.SelectedRows[0].Cells["Posted"].Value.ToString() == "1")
                {
                    or.status.Visible = true;
                    or.status.Text    = "POSTED";
                }
                else if (dataGridView1.SelectedRows[0].Cells["Cancelled"].Value.ToString() == "True" || dataGridView1.SelectedRows[0].Cells["Cancelled"].Value.ToString() == "1")
                {
                    or.status.Visible = true;
                    or.status.Text    = "CANCELLED";
                }
                else
                {
                    or.status.Visible = false;
                }


                //Location of OR as Per Maam Diane Request
                if (dataGridView1.SelectedRows[0].Cells["Location"].Value.ToString() == "PEREA")
                {
                    or.radioLocPerea.Checked = true;
                }
                else
                {
                    or.radioLocTeltech.Checked = true;
                }

                //Put Prepared By
                or.txtPreparedBy.Text = dataGridView1.SelectedRows[0].Cells["Prepared_By"].Value.ToString();

                //Enable Commands
                or.btnEdit.Enabled   = true;
                or.btnPost.Enabled   = true;
                or.btnCancel.Enabled = true;

                this.Close();
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            switch (Classes.clsLookUp.whosLookUp)
            {
            case "0":     //Savings
                SavingsDataEntry savingsDataentry = new SavingsDataEntry();

                //Check for hold accounts
                if (clsHoldAccount.checkIfHoldAccount(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString())) == true)
                {
                    Alert.show("Member's account is on hold.", Alert.AlertType.error);
                    return;
                }

                if (clsHoldAccount.checkIfTHeresADependent(dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString()) == true)
                {
                    Alert.show("Member's account is on hold.", Alert.AlertType.error);
                    return;
                }
                //for dependent purposes


                //For Resigned Member
                if (clsMembership.isResigned(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString())) == true)
                {
                    //Already Resigned
                    DialogResult result = MessageBox.Show(this, "This member already resigned, are you sure you want to continue?", "PLDT Credit Cooperative", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }

                foreach (Form form in Application.OpenForms)
                {
                    //Start Validation first if selected account is hold

                    if (form.GetType() == typeof(SavingsDataEntry))
                    {
                        //===============================================================================
                        //                      If form is already open
                        //===============================================================================
                        form.Activate();
                        savingsDataentry = (SavingsDataEntry)Application.OpenForms["SavingsDataEntry"];
                        savingsDataentry.txtEmployeeID.Text = dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString();
                        Classes.clsSavingsDataEntry.userID  = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                        savingsDataentry.txtName.Text       = dataGridView1.SelectedRows[0].Cells["LastName"].Value.ToString() + ", " + dataGridView1.SelectedRows[0].Cells["FirstName"].Value.ToString() + " " + dataGridView1.SelectedRows[0].Cells["MiddleName"].Value.ToString() + dataGridView1.SelectedRows[0].Cells["Suffix"].Value.ToString();

                        if (dataGridView1.SelectedRows[0].Cells["Savings_Deposit"].Value == DBNull.Value)
                        {
                            savingsDataentry.txtSDDeduction.Text = "0.00";
                        }
                        else
                        {
                            savingsDataentry.txtSDDeduction.Text = Convert.ToDecimal(dataGridView1.SelectedRows[0].Cells["Savings_Deposit"].Value).ToString("#,##0.00");
                        }

                        savingsDataentry.txtCurrentBalanceBeforeWithdrawal.Text = clsSavingsDataEntry.returnMembersSaving(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());

                        //If theres a deposited check
                        savingsDataentry.txtdepositedCheque.Text = clsSavings.returnDepositedChequeAmount(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));
                        savingsDataentry.txtDepositedDate.Text   = clsSavings.returnDepositedChequeDate(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));

                        //MINUS THE CHECK AMOUNT
                        if (savingsDataentry.txtdepositedCheque.Text != "")
                        {
                            Decimal widAmnt;
                            widAmnt = Convert.ToDecimal(savingsDataentry.txtCurrentBalanceBeforeWithdrawal.Text) - Convert.ToDecimal(savingsDataentry.txtdepositedCheque.Text);
                            savingsDataentry.txtWithdrawalBalance.Text = widAmnt.ToString("#,0.00");
                        }
                        else
                        {
                            savingsDataentry.txtWithdrawalBalance.Text = clsSavingsDataEntry.returnMembersSaving(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                        }


                        savingsDataentry.txtCompany.Text            = clsSavingsDataEntry.returnCompanyDescription(dataGridView1.SelectedRows[0].Cells["Company_Code"].Value.ToString());
                        savingsDataentry.txtLastDateWithdrawal.Text = clsSavings.returnLastWithdrawalDate(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));

                        //For Account number and Bank Code
                        savingsDataentry.txtAccntNo.Text  = dataGridView1.SelectedRows[0].Cells["ATM_Account_No"].Value.ToString();
                        savingsDataentry.txtBankCode.Text = dataGridView1.SelectedRows[0].Cells["Bank_Code"].Value.ToString();

                        savingsDataentry.txtAmountWithdrawn.Focus();
                        this.Close();
                        return;
                    }
                }

                savingsDataentry.txtEmployeeID.Text         = dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString();
                savingsDataentry.txtLastDateWithdrawal.Text = clsSavings.returnLastWithdrawalDate(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));
                Classes.clsSavingsDataEntry.userID          = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());

                savingsDataentry.txtName.Text = dataGridView1.SelectedRows[0].Cells["LastName"].Value.ToString() + ", " + dataGridView1.SelectedRows[0].Cells["FirstName"].Value.ToString() + " " + dataGridView1.SelectedRows[0].Cells["MiddleName"].Value.ToString() + dataGridView1.SelectedRows[0].Cells["Suffix"].Value.ToString();

                if (dataGridView1.SelectedRows[0].Cells["Savings_Deposit"].Value == DBNull.Value)
                {
                    savingsDataentry.txtSDDeduction.Text = "0.00";
                }
                else
                {
                    savingsDataentry.txtSDDeduction.Text = Convert.ToDecimal(dataGridView1.SelectedRows[0].Cells["Savings_Deposit"].Value).ToString("#,##0.00");
                }

                savingsDataentry.txtCurrentBalanceBeforeWithdrawal.Text = clsSavingsDataEntry.returnMembersSaving(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());

                //If theres a deposited check
                savingsDataentry.txtdepositedCheque.Text = clsSavings.returnDepositedChequeAmount(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));
                savingsDataentry.txtDepositedDate.Text   = clsSavings.returnDepositedChequeDate(Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));

                //MINUS THE CHECK AMOUNT
                if (savingsDataentry.txtdepositedCheque.Text != "")
                {
                    Decimal widAmnt;
                    widAmnt = Convert.ToDecimal(savingsDataentry.txtCurrentBalanceBeforeWithdrawal.Text) - Convert.ToDecimal(savingsDataentry.txtdepositedCheque.Text);
                    savingsDataentry.txtWithdrawalBalance.Text = widAmnt.ToString("#,0.00");
                }
                else
                {
                    savingsDataentry.txtWithdrawalBalance.Text = clsSavingsDataEntry.returnMembersSaving(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                }


                savingsDataentry.txtCompany.Text = clsSavingsDataEntry.returnCompanyDescription(dataGridView1.SelectedRows[0].Cells["Company_Code"].Value.ToString());

                //For Account number and Bank Code
                savingsDataentry.txtAccntNo.Text  = dataGridView1.SelectedRows[0].Cells["ATM_Account_No"].Value.ToString();
                savingsDataentry.txtBankCode.Text = dataGridView1.SelectedRows[0].Cells["Bank_Code"].Value.ToString();


                savingsDataentry.Show();

                this.Close();
                savingsDataentry.txtAmountWithdrawn.Focus();
                savingsDataentry.Show();
                break;


            case "1":
                //==========================================================================================
                //                      DISBURSEMENT CODE
                //==========================================================================================
                DisbursementVoucher disbursement = new DisbursementVoucher();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.GetType() == typeof(DisbursementVoucher))
                    {
                        //===============================================================================
                        //                      If form is already open
                        //===============================================================================
                        form.Activate();
                        disbursement = (DisbursementVoucher)Application.OpenForms["DisbursementVoucher"];
                        Classes.clsDisbursement.userID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                        LoanLookUpProcess.clsLoanLookUpMember.userid = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());

                        disbursement.txtLoanNo.Text   = "";
                        disbursement.txtLoanType.Text = "";

                        disbursement.txtPayee.Text     = dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString();
                        disbursement.txtPayeeName.Text = dataGridView1.SelectedRows[0].Cells["LastName"].Value.ToString() + ", " + dataGridView1.SelectedRows[0].Cells["FirstName"].Value.ToString() + " " + dataGridView1.SelectedRows[0].Cells["MiddleName"].Value.ToString() + dataGridView1.SelectedRows[0].Cells["Suffix"].Value.ToString();
                        this.Close();
                        return;
                    }
                }

                Classes.clsDisbursement.userID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                LoanLookUpProcess.clsLoanLookUpMember.userid = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());

                disbursement.txtLoanNo.Text   = "";
                disbursement.txtLoanType.Text = "";

                disbursement.txtPayee.Text     = dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString();
                disbursement.txtPayeeName.Text = dataGridView1.SelectedRows[0].Cells["LastName"].Value.ToString() + ", " + dataGridView1.SelectedRows[0].Cells["FirstName"].Value.ToString() + " " + dataGridView1.SelectedRows[0].Cells["MiddleName"].Value.ToString() + dataGridView1.SelectedRows[0].Cells["Suffix"].Value.ToString();
                disbursement.Show();
                this.Close();
                break;

            case "2":
                //==========================================================================================
                //                      CASH RECEIPT CODE
                //==========================================================================================
                CashReceiptVoucher cashOR = new CashReceiptVoucher();

                foreach (Form form in Application.OpenForms)
                {
                    if (form.GetType() == typeof(CashReceiptVoucher))
                    {
                        //===============================================================================
                        //                      If form is already open
                        //===============================================================================
                        form.Activate();
                        cashOR = (CashReceiptVoucher)Application.OpenForms["CashReceiptVoucher"];
                        Classes.clsCashReceipt.userID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                        cashOR.txtPayorID.Text        = dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString();
                        cashOR.txtPayorName.Text      = dataGridView1.SelectedRows[0].Cells["LastName"].Value.ToString() + ", " + dataGridView1.SelectedRows[0].Cells["FirstName"].Value.ToString() + " " + dataGridView1.SelectedRows[0].Cells["MiddleName"].Value.ToString() + dataGridView1.SelectedRows[0].Cells["Suffix"].Value.ToString();
                        cashOR.txtPayorCompany.Text   = clsCash.returnCompanyDescription(dataGridView1.SelectedRows[0].Cells["Company_Code"].Value.ToString());
                        this.Close();
                        return;
                    }
                }

                Classes.clsCashReceipt.userID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                cashOR.txtPayorID.Text        = dataGridView1.SelectedRows[0].Cells["EmployeeID"].Value.ToString();
                cashOR.txtPayorName.Text      = dataGridView1.SelectedRows[0].Cells["LastName"].Value.ToString() + ", " + dataGridView1.SelectedRows[0].Cells["FirstName"].Value.ToString() + " " + dataGridView1.SelectedRows[0].Cells["MiddleName"].Value.ToString() + dataGridView1.SelectedRows[0].Cells["Suffix"].Value.ToString();
                cashOR.txtPayorCompany.Text   = clsCash.returnCompanyDescription(dataGridView1.SelectedRows[0].Cells["Company_Code"].Value.ToString());
                cashOR.Show();
                this.Close();
                break;
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                CashReceiptVoucher or = new CashReceiptVoucher();

                or = (CashReceiptVoucher)Application.OpenForms["CashReceiptVoucher"];

                if (or.txtORNo.Text != "")
                {
                    clsOpen.deleteTransaction("Receipt Voucher", or.txtORNo.Text);
                }

                if (clsOpen.checkOpenFormsAndTransaction("Receipt Voucher", dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString()) == true)
                {
                    //Messagebox here for open form with user whos using the form and reference
                    Alert.show(clsOpen.returnUserOnlineAndReference("Receipt Voucher", dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString(), "Receipt Voucher"), Alert.AlertType.error);
                    return;
                }
                else
                {
                    //Insert here for register the open form and reference
                    clsOpen.insertTransaction("Receipt Voucher", dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString());
                }

                //=========================================================================================
                //                              Header Information
                //=========================================================================================

                Classes.clsCashReceipt.userID = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                or.txtORNo.Text  = dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString();
                or.dtOrDate.Text = dataGridView1.SelectedRows[0].Cells["Or_Date"].Value.ToString();

                if (dataGridView1.SelectedRows[0].Cells["Payor_Type"].Value.ToString() == "True")
                {
                    or.radioClient.Checked = true;
                    //Return Company Name According to ID
                    or.txtPayorName.Text = clsSearchCash.returnClientName(dataGridView1.SelectedRows[0].Cells["Payor"].Value.ToString());
                }
                else
                {
                    or.radioMember.Checked = true;
                    //Return Member Name According to ID
                    or.txtPayorName.Text    = clsSearchCash.returnMembersName(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString());
                    or.txtPayorCompany.Text = clsCash.returnCompanyDescription(clsSearchCash.GetCompanyPerMember(dataGridView1.SelectedRows[0].Cells["userID"].Value.ToString()));
                }

                or.txtPayorID.Text     = dataGridView1.SelectedRows[0].Cells["Payor"].Value.ToString();
                or.txtParticulars.Text = dataGridView1.SelectedRows[0].Cells["Particulars"].Value.ToString();

                //=========================================================================================
                //                      COLLECTION TYPE
                //=========================================================================================
                //0 = cash
                //1 = pecci check
                //2 = non-pecci check
                if (dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "0")
                {
                    or.radioCash.Checked = true;
                }
                else if (dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "1")
                {
                    or.radioPecciCheck.Checked = true;
                }
                else
                {
                    or.radioNonPecciCheck.Checked = true;
                }

                //=========================================================================================
                //                      Transaction Header
                //=========================================================================================
                clsSearchCash.loadTransaction(or.datagridviewTransaction, dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString());


                //=========================================================================================
                //                      Bank Details
                //=========================================================================================
                if (dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "1" || dataGridView1.SelectedRows[0].Cells["Collection_Type"].Value.ToString() == "2")
                {
                    clsSearchCash.loadBanksCheck(or.dgvChecks, dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString());

                    //Disable Bank Grid and buttons
                    or.dgvChecks.Enabled      = false;
                    or.btnAddCheck.Enabled    = false;
                    or.btnRemoveCheck.Enabled = false;
                }
                else
                {
                    or.dgvChecks.Rows.Clear();
                }


                //=========================================================================================
                //                      Cash Receipt Details
                //=========================================================================================

                clsSearchCash.loadCashReceiptsDetails(or.dataGridView3, dataGridView1.SelectedRows[0].Cells["Or_No"].Value.ToString());


                //=========================================================================================
                //                      Cash Receipt Footer
                //=========================================================================================
                or.txtPostedBy.Text    = dataGridView1.SelectedRows[0].Cells["Posted_By"].Value.ToString();
                or.txtCancelledBy.Text = dataGridView1.SelectedRows[0].Cells["Cancelled_By"].Value.ToString();

                if (dataGridView1.SelectedRows[0].Cells["Posted"].Value.ToString() == "True" || dataGridView1.SelectedRows[0].Cells["Posted"].Value.ToString() == "1")
                {
                    or.status.Visible = true;
                    or.status.Text    = "POSTED";
                }
                else if (dataGridView1.SelectedRows[0].Cells["Cancelled"].Value.ToString() == "True" || dataGridView1.SelectedRows[0].Cells["Cancelled"].Value.ToString() == "1")
                {
                    or.status.Visible = true;
                    or.status.Text    = "CANCELLED";
                }
                else
                {
                    or.status.Visible = false;
                }


                //Location of OR as Per Maam Diane Request
                if (dataGridView1.SelectedRows[0].Cells["Location"].Value.ToString() == "PEREA")
                {
                    or.radioLocPerea.Checked = true;
                }
                else
                {
                    or.radioLocTeltech.Checked = true;
                }

                //Put Prepared By
                or.txtPreparedBy.Text = dataGridView1.SelectedRows[0].Cells["Prepared_By"].Value.ToString();
                or.txtAuditedBy.Text  = dataGridView1.SelectedRows[0].Cells["Audited_By"].Value.ToString();

                //Enable Commands
                or.btnEdit.Enabled     = true;
                or.btnPost.Enabled     = true;
                or.btnCancel.Enabled   = true;
                or.btnAuditted.Enabled = true;
                //Sorting
                or.dataGridView3.Sort(or.dataGridView3.Columns["Debit"], ListSortDirection.Descending);
                this.Close();
            }
        }