private void ComboDocNo_TextChanged(object sender, EventArgs e)
        {
            // Formatting the form:
            if (ComboDocNo.Text == "")
            {
                BtnDelete.Enabled = false;
            }
            else
            {
                BtnDelete.Enabled = true;
            }

            if (ComboStatus.Text == "لم يتم تسويتها")
            {
                if (ComboDocNo.Text == "" || ComboLocation.Text == "" || ComboEmployee.Text == "" || TxtTotalAmount.Text == "" || TxtPeriod.Text == "" || TxtReason.Text == "")
                {
                    BtnUpdate.Enabled = false;
                }
                else
                {
                    BtnUpdate.Enabled = true;
                }
            }
            else
            {
                if (ComboDocNo.Text == "" || ComboLocation.Text == "" || ComboEmployee.Text == "" || TxtTotalAmount.Text == "" || TxtPeriod.Text == "" || TxtReason.Text == "" || TxtChequeNo.Text == "" || TxtSettlementAmount.Text == "0")
                {
                    BtnUpdate.Enabled = false;
                }
                else
                {
                    BtnUpdate.Enabled = true;
                }
            }

            // Loading data into the form:
            try
            {
                using (DBAuditDataContext dc = new DBAuditDataContext())
                {
                    if (ComboDocNo.Text != "")
                    {
                        DateTime?VarPayDate              = null;
                        int?     IntLocationID           = null;
                        string   StrLocation             = null;
                        int?     IntEmployeeID           = null;
                        string   StrEmployee             = null;
                        decimal? decimalTotalAmount      = null;
                        int?     IntPeriod               = null;
                        string   StrResason              = null;
                        string   StrStatues              = null;
                        DateTime?varSettlementDate       = null;
                        string   StrChequeNo             = null;
                        DateTime?VarChequeDate           = null;
                        DateTime?VarExpenseDate          = null;
                        DateTime?VarEndDate              = null;
                        decimal? decimalSettlementAmount = null;
                        int?     IntSettlementPEriod     = null;
                        decimal? decimalTax              = null;
                        decimal? decimalPenalty          = null;
                        decimal? decimalFees             = null;
                        decimal? decimalRevenues         = null;
                        decimal? decimalNetAmount        = null;
                        decimal? decimalTotalDiscount    = null;
                        decimal? decimalAmountToPay      = null;
                        decimal? decimalPaidAmount       = null;
                        string   StrBillNo               = null;
                        string   StrSettlementNo         = null;
                        string   StrNotes = null;
                        var      c        = dc.ProSelectTempLoan(ComboDocNo.Text, ref VarPayDate, ref IntLocationID, ref IntEmployeeID, ref decimalTotalAmount, ref IntPeriod, ref StrResason, ref StrStatues, ref varSettlementDate, ref StrChequeNo, ref VarChequeDate, ref VarExpenseDate, ref VarEndDate, ref decimalSettlementAmount, ref IntSettlementPEriod, ref decimalTax, ref decimalPenalty, ref decimalFees, ref decimalRevenues, ref decimalNetAmount, ref decimalTotalDiscount, ref decimalAmountToPay, ref decimalPaidAmount, ref StrBillNo, ref StrSettlementNo, ref StrNotes);
                        DatePayDate.Value = VarPayDate.Value;
                        var d = dc.ProGetLocationByID(IntLocationID, ref StrLocation);
                        ComboLocation.Text = StrLocation;
                        var x = dc.ProGetEmployeeByID(IntEmployeeID, ref StrEmployee);
                        ComboEmployee.Text  = StrEmployee;
                        TxtTotalAmount.Text = decimalTotalAmount.ToString();
                        TxtPeriod.Text      = IntPeriod.ToString();
                        TxtReason.Text      = StrResason;
                        ComboStatus.Text    = StrStatues;
                        if (varSettlementDate != null)
                        {
                            DateSettlement.Value = varSettlementDate.Value;
                        }
                        TxtChequeNo.Text = StrChequeNo;
                        if (VarChequeDate != null)
                        {
                            DateChequeDate.Value = VarChequeDate.Value;
                        }
                        if (VarExpenseDate != null)
                        {
                            DateChequeExpense.Value = VarExpenseDate.Value;
                        }
                        if (VarExpenseDate != null)
                        {
                            DateChequeExpense.Value = VarExpenseDate.Value;
                        }
                        if (VarEndDate != null)
                        {
                            DateEndDate.Value = VarEndDate.Value;
                        }
                        TxtSettlementAmount.Text = decimalSettlementAmount.ToString();
                        TxtSettlementPeriod.Text = IntSettlementPEriod.ToString();
                        TxtTax.Text           = decimalTax.ToString();
                        TxtPenalty.Text       = decimalPenalty.ToString();
                        TxtFees.Text          = decimalFees.ToString();
                        TxtRevenues.Text      = decimalRevenues.ToString();
                        TxtNetAmount.Text     = decimalNetAmount.ToString();
                        TxtTotalDiscount.Text = decimalTotalDiscount.ToString();
                        TxtAmountToPay.Text   = decimalAmountToPay.ToString();
                        TxtPaidAmount.Text    = decimalPaidAmount.ToString();
                        TxtBill.Text          = StrBillNo;
                        TxtSettlementNo.Text  = StrSettlementNo;
                        TxtNotes.Text         = StrNotes;
                    }
                    else
                    {
                        DatePayDate.Value        = DateTime.Now;
                        ComboLocation.Text       = "";
                        ComboEmployee.Text       = "";
                        TxtTotalAmount.Text      = "";
                        TxtPeriod.Text           = "";
                        TxtReason.Text           = "";
                        ComboStatus.Text         = "";
                        DateSettlement.Value     = DateTime.Now;
                        TxtChequeNo.Text         = "";
                        DateChequeDate.Value     = DateTime.Now;
                        DateChequeExpense.Value  = DateTime.Now;
                        DateEndDate.Value        = DateTime.Now;
                        TxtSettlementAmount.Text = "";
                        TxtSettlementPeriod.Text = "";
                        TxtTax.Text           = "";
                        TxtPenalty.Text       = "";
                        TxtFees.Text          = "";
                        TxtRevenues.Text      = "";
                        TxtNetAmount.Text     = "";
                        TxtTotalDiscount.Text = "";
                        TxtAmountToPay.Text   = "";
                        TxtPaidAmount.Text    = "";
                        TxtBill.Text          = "";
                        TxtSettlementNo.Text  = "";
                        TxtNotes.Text         = "";
                    }
                }
            }
            catch (NullReferenceException)
            {
            }
            catch (InvalidOperationException)
            {
                DatePayDate.Value        = DateTime.Now;
                ComboLocation.Text       = "";
                ComboEmployee.Text       = "";
                TxtTotalAmount.Text      = "";
                TxtPeriod.Text           = "";
                TxtReason.Text           = "";
                ComboStatus.Text         = "";
                DateSettlement.Value     = DateTime.Now;
                TxtChequeNo.Text         = "";
                DateChequeDate.Value     = DateTime.Now;
                DateChequeExpense.Value  = DateTime.Now;
                DateEndDate.Value        = DateTime.Now;
                TxtSettlementAmount.Text = "";
                TxtSettlementPeriod.Text = "";
                TxtTax.Text           = "";
                TxtPenalty.Text       = "";
                TxtFees.Text          = "";
                TxtRevenues.Text      = "";
                TxtNetAmount.Text     = "";
                TxtTotalDiscount.Text = "";
                TxtAmountToPay.Text   = "";
                TxtPaidAmount.Text    = "";
                TxtBill.Text          = "";
                TxtSettlementNo.Text  = "";
                TxtNotes.Text         = "";
                BtnDelete.Enabled     = false;
            }
            catch (Exception EX)
            {
                MessageBox.Show(EX.Message.ToString());
            }
        }