コード例 #1
0
        /// <summary>
        /// Private Mehod for Save Loan ApplicationRecord
        /// </summary>
        public void SaveLoanDetails()
        {
            ObjLoan = new clsLoan();
            int intYear, intMonth;
            try
            {
                //Loan Detials
                ObjLoan.LoanId = !string.IsNullOrEmpty(hdnLoanId.Value) ? Convert.ToInt32(hdnLoanId.Value) : 0;
                ObjLoan.CustomerId = !string.IsNullOrEmpty(hdnCustomerId.Value) ? Convert.ToInt32(hdnCustomerId.Value) : 0;
                ObjLoan.LoanDate = !string.IsNullOrEmpty(txtLoanDate.Text.Trim()) ? Convert.ToString(txtLoanDate.Text.Trim()) : String.Empty;
                ObjLoan.LoanTypeID = !string.IsNullOrEmpty(ddlLoanType.SelectedValue) ? Convert.ToInt32(ddlLoanType.SelectedValue) : 0;
                ObjLoan.LoanAmount = !string.IsNullOrEmpty(txtLoanAmt.Text.Trim()) ? Convert.ToDouble(txtLoanAmt.Text.Trim()) : 0;
                ObjLoan.InstallmentAmt = !string.IsNullOrEmpty(txtEmiAmt.Text.Trim()) ? Convert.ToDouble(txtEmiAmt.Text.Trim()) : 0;

                //Calculate Loan Period
                intYear = !string.IsNullOrEmpty(ddlLoanYear.SelectedValue) ? Convert.ToInt32(ddlLoanYear.SelectedValue) : 0;
                intMonth = !string.IsNullOrEmpty(ddlLoanMonth.SelectedValue) ? Convert.ToInt32(ddlLoanMonth.SelectedValue) : 0;
                intMonth = ((intYear * 12) + intMonth);
                ObjLoan.LoanPeriod = intMonth;

                ObjLoan.LoanReason = !string.IsNullOrEmpty(txtCustomerLoanPurpose.Text.Trim()) ? Convert.ToString(txtCustomerLoanPurpose.Text.Trim()) : string.Empty;
                ObjLoan.LoanPaidUpTypeID = !string.IsNullOrEmpty(ddlCustomerPastLoanEMI.SelectedValue) ? Convert.ToInt32(ddlCustomerPastLoanEMI.SelectedValue) : 0;
                ObjLoan.TotalInstallment = !string.IsNullOrEmpty(txtTotalLoanInstallmentAmt.Text.Trim()) ? Convert.ToDouble(txtTotalLoanInstallmentAmt.Text.Trim()) : 0;
                ObjLoan.WitnessNo1 = !string.IsNullOrEmpty(hdnWitnessID1.Value) ? Convert.ToInt32(hdnWitnessID1.Value) : 0;
                ObjLoan.WitnessNo2 = !string.IsNullOrEmpty(hdnWitnessID2.Value) ? Convert.ToInt32(hdnWitnessID2.Value) : 0;
                ObjLoan.WitnessNo3 = !string.IsNullOrEmpty(hdnWitnessID3.Value) ? Convert.ToInt32(hdnWitnessID3.Value) : 0;
                ObjLoan.WitnessNo4 = !string.IsNullOrEmpty(hdnWitnessID4.Value) ? Convert.ToInt32(hdnWitnessID4.Value) : 0;
                ObjLoan.CreatedBy = Convert.ToInt32(AppSessions.GetSession(AppSessions.UDFSessionName._user_id.ToString()));
                ObjLoan.CreatedDate = Convert.ToDateTime(txtLoanDate.Text);
                ObjLoan.UpdatedBy = Convert.ToInt32(AppSessions.GetSession(AppSessions.UDFSessionName._user_id.ToString()));
                ObjLoan.UpdatedDate = Convert.ToDateTime(txtLoanDate.Text);
                ObjLoan.IsActive = true;

                if (ObjLoan.Insert())
                {
                    lblMessage.CssClass = "SuccessfulMessage";
                    lblMessage.Text = (String)GetGlobalResourceObject("SharedResource", "RecordSavedSuccessfully");
                }
                else
                {
                    lblMessage.CssClass = "FailureMessage";
                    lblMessage.Text = (String)GetGlobalResourceObject("SharedResource", "RecordSavingFailure");
                }
                ShowHideLoanGrid(true);
                EnableDisabledControls(false);
                BindLoanGrid();
            }
            catch
            {
                lblMessage.CssClass = "FailureMessage";
                lblMessage.Text = (String)GetGlobalResourceObject("SharedResource", "RecordSavingFailure");
            }
            finally
            {
                ObjLoan = null;
            }
        }