private void PostTransaction()
    {
        string custref    = txtcode.Text.Trim();
        string custname   = txtname.Text.Trim();
        string phone      = txtPhone.Text.Trim();
        string amount     = txtAmount.Text.Trim();
        string bal        = txtbal.Text.Trim();
        string custtype   = txtCustType.Text.Trim();
        string accountno  = txtaccountno.Text.Trim();
        string chequeno   = txtchequeNo.Text.Trim();
        string chequeDate = txtDate.Text.Trim();
        string paymode    = GetPayTypeSelected();
        string bank       = GetBank(paymode);
        string payType    = cboPayType.SelectedValue.ToString();
        string teller     = Session["Username"].ToString();
        string mreceipto  = txtReceiptno.Text.Trim();
        bool   cancelled  = chkcancelled.Checked;

        if (custref.Equals(""))
        {
            ShowMessage("Customer Ref is Required", true);
        }
        else if (custname.Equals(""))
        {
            ShowMessage("Customer Name is Required", true);
        }
        else if (payType.Equals("0"))
        {
            ShowMessage("Please Select Payment Type", true);
        }
        else if (mreceipto.Equals(""))
        {
            ShowMessage("Please Enter Manual Receipt Number", true);
            txtReceiptno.Focus();
        }
        //else if (bll.ManualReceiptExists(mreceipto))
        //{
        //    ShowMessage("Duplicate Manual Receipt Number", true);
        //    txtReceiptno.Focus();
        //}
        else if (amount.Equals(""))
        {
            ShowMessage("Please Enter Amount to pay", true);
            txtAmount.Focus();
        }
        else if (amount.Equals("0"))
        {
            ShowMessage("Amount to post cannot be zero", true);
            txtAmount.Focus();
        }
        else if (bal.Equals(""))
        {
            ShowMessage("Customer Balance is Required", true);
        }
        else if (paymode.Equals("NONE"))
        {
            ShowMessage("Please Select Payment Mode, Cash or Cheque", true);
        }
        else if (paymode.Equals("CHEQUE") && chequeno.Equals(""))
        {
            ShowMessage("Please Enter Cheque Number", true);
            txtchequeNo.Focus();
        }
        else if (paymode.Equals("CHEQUE") && accountno.Equals(""))
        {
            ShowMessage("Please Enter Cheque Account Number", true);
            txtaccountno.Focus();
        }
        else if (paymode.Equals("CHEQUE") && bank.Equals(""))
        {
            ShowMessage("Please Select Cheque Bank Name", true);
        }
        else if (paymode.Equals("CHEQUE") && chequeDate.Equals(""))
        {
            ShowMessage("Please Enter Cheque Payment Date", true);
            txtDate.Focus();
        }
        else
        {
            ShowMessage(".", true);
            Responseobj res = new Responseobj();
            Transaction t   = new Transaction();
            t.TranAmount   = amount.Replace(",", "");
            t.CustomerRef  = custref;
            t.CustomerType = custtype;
            t.CustomerName = custname;
            t.TranType     = paymode;
            t.PaymentType  = payType;
            t.CustomerTel  = phone;
            t.Reversal     = "0";
            t.Teller       = teller;
            t.PaymentDate  = DateTime.Now.ToString("dd/MM/yyyy");
            t.Offline      = "1";
            string receipt_status = bll.isValidManualReceipt(mreceipto, t.TranAmount);
            if (receipt_status.Equals("YES"))
            {
                res = bll.PostPayment(t, bal.ToString(), mreceipto, cancelled, true);
                if (res.Errorcode.Equals("0"))
                {
                    //DisplayReceipt(res);
                    string receiptno = res.Receiptno;
                    string vendorref = res.VendorRef;
                    // Save Cheque Details
                    if (paymode.Equals("CHEQUE"))
                    {
                        string res_cheque = Process.SaveChequeDetails(vendorref, chequeno, accountno, bank, chequeDate);
                    }
                    ClearContrls();
                    ShowMessage("Payment Posted Successfully. Receipt Number " + receiptno, false);
                }
                else
                {
                    ShowMessage(res.Message, true);
                }
            }
            else
            {
                ShowMessage(receipt_status, true);
            }
        }
    }