protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    sLoanid = Request.QueryString["loanid"];
                    if (Utility.CheckAccess("LoanMasterAddEdit") == false)
                    {
                        UrlParameterPasser urlWrapper = new UrlParameterPasser();
                        urlWrapper["pageaccesserr"] = "1";
                        urlWrapper.Url = "../DocumentLogSystem/DashBoard.aspx";
                        urlWrapper.PassParameters();
                    }
                    if (!Convert.ToBoolean(Session[clsConstant.SESS_VIEWTYPE]))
                    {
                        this.MakeReadOnly(this.Controls);
                    }
                    else
                    {
                        ddlProjectBind();
                        fillDocCat();
                        fillAgency();
                        btnSubmit.Visible = true;
                        btnUpdate.Visible = false;
                        checkForPMU();
                        fillTA();
                        if (sLoanid != "")
                        {
                            chkLoanClosed.Visible = true;
                        }
                        else
                        {
                            chkLoanClosed.Visible = false;
                        }
                    }
                }

                if (sLoanid != null)
                {
                    if (!IsPostBack)
                    {
                        objLoan = new clsLoanDetails();
                        EntLoanMaster objEnt = objLoan.setEntity(int.Parse(sLoanid));
                        fillData(objEnt);
                    }
                }
            }

            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
 protected void txtLoanNumber_TextChanged(object sender, EventArgs e)
 {
     try
     {
         objLoan = new clsLoanDetails();
         EntLoanMaster objEnt = objLoan.setEntity(0, txtLoanNumber.Text);
         fillData(objEnt);
     }
     catch (Exception ex)
     {
         logger.Error(ex);
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string pmuDate = "";

            try
            {
                if (txtPMU.Text == "Yes")
                {
                    pmuDate = txtAppDate.Text;
                }
                else
                {
                    pmuDate = DateTime.Now.ToString();

                    DateTime dtPmu = new DateTime();
                    dtPmu   = DateTime.Parse(pmuDate);
                    pmuDate = dtPmu.ToString("dd MMM yyyy");
                }
                objLoan = new clsLoanDetails();

                if (objLoan.AddLoanMaster(ddlProjectDetail.SelectedValue, txtLoanNumber.Text, txtLoanName.Text,
                                          double.Parse(txtAmount.Text), txtAppDate.Text, txtClosingDate.Text, txtStartDate.Text,
                                          txtEndDate.Text, int.Parse(ddlDocCat.SelectedValue), int.Parse(ddlGroup.SelectedValue),
                                          int.Parse(ddlAgency.SelectedValue), txtSigningDate.Text, txtEffectivenessDate.Text,
                                          txtContractAwardDate.Text, txtRevisedClosingDate.Text, pmuDate, txtGracePeriod.Text,
                                          double.Parse(txtOrgAmount.Text == "" ? "0" : txtOrgAmount.Text),
                                          double.Parse(txtCancelAmount.Text == "" ? "0" : txtCancelAmount.Text),
                                          double.Parse(txtTotalPrjCost.Text == "" ? "0" : txtTotalPrjCost.Text),
                                          double.Parse(txtCommtChrg.Text == "" ? "0" : txtCommtChrg.Text),
                                          double.Parse(txtContDisTrg.Text == ""?"0":txtContDisTrg.Text),
                                          txtSecondRevisedClosingDate.Text, int.Parse(ddlTAno.SelectedValue)))
                {
                    lblMessage.ForeColor = System.Drawing.Color.Blue;
                    lblMessage.Text      = "Information has been saved successfully";
                    Utility util = new Utility();
                    util.ResetFormControl(pageDiv);
                }

                else
                {
                    lblMessage.ForeColor = System.Drawing.Color.Red;
                    lblMessage.Text      = "Sorry Unable to Save.";
                }
            }

            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string pmuDate = "";

            try
            {
                if (txtPMU.Text == "Yes")
                {
                    pmuDate = txtAppDate.Text;
                }
                else
                {
                    //pmuDate = null;
                    pmuDate = DateTime.Now.ToString();
                    DateTime dtPmu = new DateTime();
                    dtPmu   = DateTime.Parse(pmuDate);
                    pmuDate = dtPmu.ToString("dd MMM yyyy");
                }
                objLoan = new clsLoanDetails();
                if (objLoan.EditLoanDetails(int.Parse(lblLoanNo.Text), ddlProjectDetail.SelectedValue, txtLoanNumber.Text,
                                            txtLoanName.Text, double.Parse(txtAmount.Text), txtAppDate.Text, txtClosingDate.Text,
                                            txtStartDate.Text, txtEndDate.Text, int.Parse(ddlDocCat.SelectedValue),
                                            int.Parse(ddlGroup.SelectedValue), int.Parse(ddlAgency.SelectedValue), txtSigningDate.Text,
                                            txtEffectivenessDate.Text, txtContractAwardDate.Text, txtRevisedClosingDate.Text, pmuDate,
                                            txtGracePeriod.Text, (txtOrgAmount.Text == ""?0.00:double.Parse(txtOrgAmount.Text)),
                                            (txtCancelAmount.Text == ""?0.00:double.Parse(txtCancelAmount.Text)),
                                            (txtTotalPrjCost.Text == ""?0.00:double.Parse(txtTotalPrjCost.Text)),
                                            (txtCommtChrg.Text == ""?0.00:double.Parse(txtCommtChrg.Text)),
                                            (txtContDisTrg.Text == ""?0.00:double.Parse(txtContDisTrg.Text)),
                                            txtSecondRevisedClosingDate.Text, int.Parse(ddlTAno.SelectedValue)))
                {
                    using (SqlConnection conn = new SqlConnection())
                    {
                        conn.ConnectionString = ConfigurationManager.ConnectionStrings["TA7511DBConnString"].ConnectionString;
                        using (SqlCommand cmd = new SqlCommand())
                        {
                            cmd.CommandText = "USP_UpdateLoanStatus";
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@LoanId", lblLoanNo.Text);
                            cmd.Parameters.AddWithValue("@Status", chkLoanClosed.Checked == true?1 :0);
                            cmd.Connection = conn;
                            conn.Open();
                            cmd.ExecuteNonQuery();
                        }
                    }
                    lblMessage.ForeColor = System.Drawing.Color.Blue;
                    lblMessage.Text      = "Information  successfully updated";
                    Utility util = new Utility();
                    util.ResetFormControl(pageDiv);
                }
                else
                {
                    lblMessage.ForeColor = System.Drawing.Color.Red;
                    lblMessage.Text      = "Sorry Unable to Save.";
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }