protected void grdFirmEvaluation_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                FirmEvalObj = new FirmEvaluation();
                clsEntFirmEvaluation ObjEntFirmEvInd = new clsEntFirmEvaluation();
                // Function used to  for downloading the files from database
                for (int i = 0; i < grdFirmEvaluation.Rows.Count; i++)
                {
                    //obtain selected index from GridView for the selected File
                    if (grdFirmEvaluation.SelectedIndex == i)
                    {
                        string firmEvalID = grdFirmEvaluation.DataKeys[i].Value.ToString();
                        ObjEntFirmEvInd = FirmEvalObj.readerFirmEvaluation(firmEvalID);

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

                            if (ObjEntFirmEvInd.FirmEvalID.ToString() != null)
                            {
                                string contentType = ObjEntFirmEvInd.Contenttype;
                                string fileName    = ObjEntFirmEvInd.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);
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnRemove);
            try
            {
                ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnUpdate);

                firmEvalID = Request.QueryString["firmEvalID"];

                #region Updation region

                if (firmEvalID != null) //Update Function
                {
                    //ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnUpdate);

                    //Check for System PostBack
                    if (IsPostBack == false)
                    {
                        //Edit Mode

                        btnSubmit.Visible = false;
                        objEnt            = ObjfirmEval.readerFirmEvaluation(firmEvalID);

                        AgencyLoad();
                        int AgencyID = objEnt.AgencyID;
                        drpAgency.SelectedValue = AgencyID.ToString();

                        LoanLoad();
                        drpLoan.SelectedValue = objEnt.LoanID.ToString();

                        PackageLoad();
                        drpPackage.SelectedValue = objEnt.PackageID.ToString();
                        FirmNameLoad();
                        string firmname = objEnt.FirmID.ToString();
                        drpFirmName.Items.FindByValue(firmname).Selected = true;


                        FirmTypeLoad();
                        string firmtype = objEnt.FirmType.ToString();
                        if (firmtype == "1" || firmtype == "2")
                        {
                            drpFirmType.Items.FindByValue(firmtype).Selected = true;
                        }
                        else
                        {
                            drpFirmType.Items.FindByText(firmtype).Selected = true;
                        }

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



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


                        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;
                        }


                        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;
                        }



                        FirmAverageratingLoad();
                        string avrr = objEnt.AR.ToString();

                        if (avrr == "1" || avrr == "2" || avrr == "3")
                        {
                            drpAverageRating.Items.FindByValue(avrr).Selected = true;
                        }

                        else
                        {
                            drpAverageRating.Items.FindByText(avrr).Selected = true;
                        }


                        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;
                            }
                            //if (evalDate.Substring(0, evalDate.Length - 5) == "01 Jul" || evalDate.Substring(0, evalDate.Length - 5) == "1 Jul")
                            //    drpDate.SelectedIndex = 0;
                            //else
                            //    drpDate.SelectedIndex = 1;
                            drpYear.SelectedIndex = drpYear.Items.IndexOf(drpYear.Items.FindByText(evalDate.Substring(evalDate.Length - 4, 4)));
                        }

                        else
                        {
                            evalDate = drpDate.SelectedItem.ToString() + drpYear.SelectedItem.ToString();
                        }

                        if (objEnt.btFinal == true)
                        {
                            optYes.Checked = true;
                        }

                        else
                        {
                            optNo.Checked = true;
                        }

                        txtComments.Text = objEnt.Comments;

                        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 Insert region
                else
                {
                    ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnSubmit);// register event for btnSubmit
                    if (!IsPostBack)
                    {
                        if (Utility.CheckAccess("FirmEvaluationAddEdit") == false)
                        {
                            //UrlParameterPasser urlWrapper = new UrlParameterPasser();
                            //urlWrapper["pageaccesserr"] = "1";
                            ////urlWrapper.Url = "../Logout.aspx";
                            //urlWrapper.Url = "../DocumentLogSystem/DashBoard.aspx";
                            //urlWrapper.PassParameters();
                            pnlInvalid.Visible = true;
                            MainDiv.Visible    = false;
                        }

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

                        btnUpdate.Visible = false;


                        //ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnSubmit);// register event for btnSubmit

                        if (Session[clsConstant.TOKEN] != null)
                        {
                            if ((((UserDetails)Session[clsConstant.TOKEN]).SuperUser) == true)
                            {
                                drpAgency.DataSource     = objCommon.getDropDownList(clsConstant.SP_GET_AGENCY, param);
                                drpAgency.DataTextField  = "DisplayFieldText";
                                drpAgency.DataValueField = "ValueFieldText";
                                drpAgency.DataBind();
                            }
                            else
                            {
                                param = new SqlParameter[] { new SqlParameter("@iAgencyID", ((UserDetails)Session[clsConstant.TOKEN]).AgencyID) };
                                drpAgency.DataSource = objCommon.getDropDownList(clsConstant.SP_GET_AGENCY_USER, param);
                                //drpEAName.DataSource = objCommon.getDropDownList(clsConstant.SP_GET_AGENCY, null);
                                drpAgency.DataTextField  = "DisplayFieldText";
                                drpAgency.DataValueField = "ValueFieldText";
                                drpAgency.DataBind();
                            }
                            drpAgency.Items.FindByValue(((UserDetails)Session[clsConstant.TOKEN]).AgencyID.ToString()).Selected = true;


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

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

                            int count = drpLoan.Items.Count;
                            if (count == 1)
                            {
                                lblStatus.Text = "No Loan in" + " - " + drpAgency.SelectedItem;
                            }
                            else
                            {
                                lblStatus.Text = "";
                            }

                            FirmTypeLoad();
                            FirmComplianceLoad();
                            OutputLoad();
                            PersonalstabilityLoad();
                            TimelyAvailabilityLoad();
                            FirmAverageratingLoad();

                            //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;
                        }

                        else
                        {
                            UrlParameterPasser urlWrapper = new UrlParameterPasser();
                            urlWrapper.Url = "../Logout.aspx";
                            urlWrapper.PassParameters();
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }