protected void grdConsEvaluation_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                ObjconsFrmEvalInd = new ConsultantEvaluation();
                clsEntConsultantEvaluation ObjEntConsEvInd = new clsEntConsultantEvaluation();
                // Function used to  for downloading the files from database
                for (int i = 0; i < grdConsEvaluation.Rows.Count; i++)
                {
                    //obtain selected index from GridView for the selected File
                    if (grdConsEvaluation.SelectedIndex == i)
                    {
                        string firmEvalID = grdConsEvaluation.DataKeys[i].Value.ToString();
                        ObjEntConsEvInd = ObjconsFrmEvalInd.readerConsultantEvaluation(firmEvalID);

                        if (ObjEntConsEvInd != null)
                        {
                            Byte[] programFile = ObjEntConsEvInd.ProgramFile;

                            if (ObjEntConsEvInd.ConsEvalID.ToString() != null)
                            {
                                string contentType = ObjEntConsEvInd.Contenttype;
                                string fileName    = ObjEntConsEvInd.FileName;
                                Response.ContentType = contentType;
                                //The AddHeader method adds a new HTML header and value to the response sent to the client
                                Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
                                //The Charset property appends the name of the character set (for example, ISO-8859-13) to the content-type header in the Response object
                                //Here Blank is attached
                                Response.Charset = "";
                                //Provides enumerated values that are used to set the Cache-Control HTTP header.
                                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                            }

                            //Provides enumerated values that are used to set the Cache-Control HTTP header.
                            Response.BinaryWrite(programFile);
                            //The End method causes the Web server to stop
                            //  processing the script and return the current result.
                            Response.End();
                        }
                        else
                        {
                            lblMessage.Text = "File DoesNot Exists";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnRemove);
            ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnSubmit);// register event for btnSubmit

            try
            {
                ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnUpdate);
                consEvalID = Request.QueryString["consEvalID"];

                #region While Editing
                if (consEvalID != null)
                {
                    if (IsPostBack == false)
                    {
                        btnSubmit.Visible = false;

                        objEnt = consFrmEvalObj.readerConsultantEvaluation(consEvalID);


                        LoanLoad();
                        int loanID = objEnt.LoanID;
                        drpLoanNumber.SelectedValue = loanID.ToString();

                        PackageLoad();
                        int packagename = objEnt.PackageID;
                        drpPackageName.SelectedValue = packagename.ToString();


                        FirmNameLoad();
                        string firmname = objEnt.FirmID.ToString();
                        drpFirmName.SelectedValue = firmname;

                        //Binding EA Name to the dropdown control.


                        AgencyLoad();
                        string eaname = objEnt.AgencyID.ToString();
                        drpEAName.SelectedValue = eaname;



                        //Binding Compliance Work Program

                        ConsultantComplianceLoad();

                        string compl = objEnt.CWWP.ToString();
                        if (compl == "1" || compl == "2" || compl == "3")
                        {
                            drpComplanceWorkProgrm.Items.FindByValue(compl).Selected = true;
                        }

                        else
                        {
                            drpComplanceWorkProgrm.Items.FindByText(compl).Selected = true;
                            //drpComplanceWorkProgrm.SelectedIndex = 0;
                        }

                        //Binding Quality Output

                        OutputLoad();

                        string outp = objEnt.QOO.ToString();
                        if (outp == "1" || outp == "2" || outp == "3")
                        {
                            drpQualityOutPut.Items.FindByValue(outp).Selected = true;
                        }

                        else
                        {
                            drpQualityOutPut.Items.FindByText(outp).Selected = true;
                            //drpQualityOutPut.SelectedIndex = 0;
                        }

                        //Binding Personal Stablity
                        PersonalstabilityLoad();

                        string ps = objEnt.PStbl.ToString();
                        if (ps == "1" || ps == "2" || ps == "3")
                        {
                            drpPersonalStability.Items.FindByValue(ps).Selected = true;
                        }

                        else
                        {
                            drpPersonalStability.Items.FindByText(ps).Selected = true;
                            //drpPersonalStability.SelectedIndex = 0;
                        }

                        //Binding Timely Availabilty
                        TimelyAvailabilityLoad();

                        string tav = objEnt.TAvail.ToString();
                        if (tav == "1" || tav == "2" || tav == "3")
                        {
                            drpTimelyAvailability.Items.FindByValue(tav).Selected = true;
                        }
                        else
                        {
                            drpTimelyAvailability.Items.FindByText(tav).Selected = true;
                            //drpTimelyAvailability.SelectedIndex = 0;
                        }

                        //Binding Average Rating

                        ConsultantAverageratingLoad();
                        string ar = objEnt.AR.ToString();
                        if (ar == "1" || ar == "2" || ar == "3")
                        {
                            drpAverageRating.Items.FindByValue(ar).Selected = true;
                        }
                        else
                        {
                            drpAverageRating.Items.FindByText(ar).Selected = true;
                        }


                        //Binding Conusltant Name

                        ConsultantLoad();
                        string cn = objEnt.ConsID.ToString();
                        drpConsultantName.SelectedValue = cn;

                        txtComments.Text = objEnt.Comments;

                        string evalDate = objEnt.EvalDate;
                        if (evalDate != "")
                        {
                            evalDate = Convert.ToDateTime(evalDate).ToString(clsConstant.DATE_FORMAT);
                        }
                        ds = new DataSet();
                        ds.ReadXml(HostingEnvironment.ApplicationPhysicalPath + "XML\\EvaluationDate.xml");
                        drpDate.DataSource     = ds.Tables[0];
                        drpDate.DataTextField  = "value";
                        drpDate.DataValueField = "value";
                        drpDate.DataBind();

                        YearLoad();
                        if (evalDate != "")
                        {
                            if (evalDate.Substring(0, evalDate.Length - 5) == "01 Jan" || evalDate.Substring(0, evalDate.Length - 5) == "1 Jan")
                            {
                                drpDate.SelectedIndex = 0;
                            }
                            else
                            {
                                drpDate.SelectedIndex = 1;
                            }

                            drpYear.SelectedIndex = drpYear.Items.IndexOf(drpYear.Items.FindByText(evalDate.Substring(evalDate.Length - 4, 4)));
                        }
                        //drpDate.SelectedItem.Text = evalDate.Substring(0, evalDate.Length - 5);

                        //drpYear.SelectedIndex = drpYear.Items.IndexOf(drpYear.Items.FindByText(evalDate.Substring(evalDate.Length - 4, 4)));
                        if (objEnt.btFinal == true)
                        {
                            optYes.Checked = true;
                        }
                        else
                        {
                            optNo.Checked = true;
                        }

                        if (objEnt.FileName != "")
                        {
                            lblFileName.Text       = objEnt.FileName;
                            btnRemove.Visible      = true;
                            CertFileUpload.Visible = false;
                        }
                        else
                        {
                            lblFileName.Text       = "";
                            btnRemove.Visible      = false;
                            CertFileUpload.Visible = true;
                        }

                        DisablePrimeData();
                    }

                    isEdit = true;
                }
                #endregion

                #region While Do First Time
                //Add Function call
                else
                {
                    //ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnSubmit);// register event for btnSubmit
                    if (!IsPostBack)
                    {
                        if (Utility.CheckAccess("ConsultantEvaluationAddEdit") == false)
                        {
                            //UrlParameterPasser urlWrapper = new UrlParameterPasser();
                            ////urlWrapper.Url = "../Logout.aspx";
                            //urlWrapper.Url = "../DocumentLogSystem/DashBoard.aspx";
                            //urlWrapper.PassParameters();
                            //urlWrapper["pageaccesserr"] = "1";

                            pnlInvalid.Visible = true;
                            MainDiv.Visible    = false;
                        }

                        if (!Convert.ToBoolean(Session[clsConstant.SESS_VIEWTYPE]))
                        {
                            this.MakeReadOnly(this.Controls);
                        }

                        btnUpdate.Visible = false;

                        //Binding Loan Number to the dropdown control.
                        PackageLoad();

                        //Binding TA No to the dropdown control.

                        FirmNameLoad();

                        //Binding EA Name to the dropdown control.
                        //According to Login.........................
                        if ((((UserDetails)Session[clsConstant.TOKEN]).SuperUser) == true)
                        {
                            drpEAName.DataSource     = objCommon.getDropDownList(clsConstant.SP_GET_AGENCY, param);
                            drpEAName.DataTextField  = "DisplayFieldText";
                            drpEAName.DataValueField = "ValueFieldText";
                            drpEAName.DataBind();
                        }
                        else
                        {
                            param = new SqlParameter[] { new SqlParameter("@iAgencyID", ((UserDetails)Session[clsConstant.TOKEN]).AgencyID) };

                            drpEAName.DataSource     = objCommon.getDropDownList(clsConstant.SP_GET_AGENCY_USER, param);
                            drpEAName.DataTextField  = "DisplayFieldText";
                            drpEAName.DataValueField = "ValueFieldText";
                            drpEAName.DataBind();
                        }
                        drpEAName.Items.FindByValue(((UserDetails)Session[clsConstant.TOKEN]).AgencyID.ToString()).Selected = true;

                        //Accord To Agency Loan

                        int SelectedIndex = int.Parse(drpEAName.SelectedValue);
                        param = new SqlParameter[] { new SqlParameter("@selectedIndex", SelectedIndex) };

                        drpLoanNumber.DataSource     = objCommon.getDropDownList(clsConstant.SP_GET_LOAN_BY_AGENCY, param);
                        drpLoanNumber.DataTextField  = "DisplayFieldText";
                        drpLoanNumber.DataValueField = "ValueFieldText";
                        drpLoanNumber.DataBind();

                        int count = drpLoanNumber.Items.Count;
                        if (count == 1)
                        {
                            lblStatus.Text      = "No Loan in" + " - " + drpEAName.SelectedItem;
                            lblStatus.ForeColor = System.Drawing.Color.Blue;
                        }
                        else
                        {
                            lblStatus.Text = "";
                        }


                        //Binding Compliance Work Program

                        ConsultantComplianceLoad();

                        //Binding Quality Output

                        OutputLoad();

                        //Binding Personal Stablity
                        PersonalstabilityLoad();

                        //Binding Timely Availabilty
                        TimelyAvailabilityLoad();

                        //Binding Average Rating

                        ConsultantAverageratingLoad();

                        //Binding Conusltant Name
                        ConsultantLoad();

                        //txtDateOfEvaluation.Text = DateTime.Now.Date.ToString("dd MMM yyyy");
                        ds = new DataSet();
                        ds.ReadXml(HostingEnvironment.ApplicationPhysicalPath + "XML\\EvaluationDate.xml");
                        drpDate.DataSource     = ds.Tables[0];
                        drpDate.DataTextField  = "value";
                        drpDate.DataValueField = "value";
                        drpDate.DataBind();

                        YearLoad();

                        optNo.Checked = true;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }