protected void grdNominationManagementSystem_SelectedIndexChanged(object sender, EventArgs e)
        {
            objEntWork  = new WorkShop();
            workshopObj = new WorkShopDetails();


            for (int i = 0; i < grdNominationManagementSystem.Rows.Count; i++)
            {
                if (grdNominationManagementSystem.SelectedIndex == i)
                {
                    int nominationID = int.Parse(grdNominationManagementSystem.DataKeys[i].Value.ToString());

                    string topic = grdNominationManagementSystem.Rows[i].Cells[2].Text;

                    objEntWork = workshopObj.readerForWorkShop("", nominationID);


                    Byte[] programFile = objEntWork.ProgramFile;

                    if (objEntWork.FileName != null)
                    {
                        string contentType = objEntWork.Contenttype;
                        string fileName    = objEntWork.FileName;
                        Response.ContentType = contentType;
                        Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
                        Response.Charset = "";
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        Response.BinaryWrite(programFile);
                        Response.End();
                    }
                }
            }
        }
        protected void grdWorkShopDetails_SelectedIndexChanged(object sender, EventArgs e)
        {
            objWork    = new WorkShopDetails();
            objEntWork = new WorkShop();
            // Function used to  for downloading the files from database
            for (int i = 0; i < grdWorkShopDetails.Rows.Count; i++)
            {
                //obtain selected index from GridView for the selected File
                if (grdWorkShopDetails.SelectedIndex == i)
                {
                    //  int nominationID = int.Parse(grdWorkShopDetailsInternationalNationals.Rows[i].Cells[0].Text.Trim());
                    int nominationID = int.Parse(grdWorkShopDetails.DataKeys[i].Value.ToString());

                    //function call for the downloading the file and reading
                    // from database
                    objEntWork = objWork.readerForWorkShop("", nominationID);


                    //---------------------------- Reading of File--------------------------
                    //Information Stored in database is in the form of Binary
                    //Populates an array of objects with the column values of the current row.

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

                        //obtain content type from database, read the no of rows in the table
                        //Check Whether is their any information available in the database or not
                        if (objEntWork.NominationID != null)
                        {
                            //obtain content type of file, i.e., application/pdf, application/ vnd.msword

                            string contentType = objEntWork.Contenttype;
                            //obtaing filename from the table
                            string fileName = objEntWork.FileName;
                            //The ContentType property specifies the HTTP content type for the response.
                            //If no ContentType is specified, the default is text/HTML.
                            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";
                    }
                }
            }
        }
        protected void grdWorkShopDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            objWork = new WorkShopDetails();
            try
            {
                //Storing the Row Index of Deleted Row
                int iNominationIDRowIndex = int.Parse(grdWorkShopDetails.DataKeys[e.RowIndex].Value.ToString());

                if (grdWorkShopDetails.Rows.Count == 0)
                {
                    lblMessage.Text = "No Information Available";
                }
                //Function call for row delete
                if (objWork.deleteWorkShopDetails(iNominationIDRowIndex))
                {
                    UrlParameterPasser urlWrapper = new UrlParameterPasser("WorkshopDetailsList.aspx");
                    // Add some values
                    urlWrapper.PassParameters();
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
        //Search the Grid
        private void searchGrid()
        {
            DataSet dtSet = new DataSet();

            objWork = new WorkShopDetails();
            //Function Call
            this.bindGrid();
        }
        //function call for add workshop
        protected void addWorkshop(bool isEmpty, byte[] programfile, string fileName, string Contenttype)
        {
            workShopDetailsObj = new WorkShopDetails();

            if (isEmpty == false)
            {
                //Add Function call
                if (workShopDetailsObj.AddWorkShopDetails(txtTopic.Text, DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text),
                                                          txtVenue.Text, int.Parse(drpTargetAudience.SelectedValue), int.Parse(drpSector.SelectedValue), int.Parse(txtseats.Text),
                                                          DateTime.Parse(txtLastdateNomination.Text), int.Parse(drpNationalInternational.SelectedValue), int.Parse(drpInvite.SelectedValue), programfile, fileName, Contenttype, isEmpty))
                {
                    txtTopic.Text              = "";
                    txtFromDate.Text           = "";
                    txtToDate.Text             = "";
                    txtVenue.Text              = "";
                    txtLastdateNomination.Text = "";
                    txtseats.Text              = "";

                    drpInvite.SelectedIndex = -1;
                    drpNationalInternational.SelectedIndex = -1;
                    drpSector.SelectedIndex         = -1;
                    drpTargetAudience.SelectedIndex = -1;
                    lblExistingFile.Text            = "";
                    lblMessage.Text = "Information Successfully Saved";
                }
            }
            else
            {
                //Add Function call
                if (workShopDetailsObj.AddWorkShopDetails(txtTopic.Text, DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text),
                                                          txtVenue.Text, int.Parse(drpTargetAudience.SelectedValue), int.Parse(drpSector.SelectedValue), int.Parse(txtseats.Text),
                                                          DateTime.Parse(txtLastdateNomination.Text), int.Parse(drpNationalInternational.SelectedValue), int.Parse(drpInvite.SelectedValue), programfile, fileName, Contenttype, isEmpty))
                {
                    txtTopic.Text              = "";
                    txtFromDate.Text           = "";
                    txtToDate.Text             = "";
                    txtVenue.Text              = "";
                    txtLastdateNomination.Text = "";
                    txtseats.Text              = "";

                    drpInvite.SelectedIndex = -1;
                    drpNationalInternational.SelectedIndex = -1;
                    drpSector.SelectedIndex         = -1;
                    drpTargetAudience.SelectedIndex = -1;
                    lblExistingFile.Text            = "";
                    lblMessage.Text = "Information Successfully Saved";
                }
            }
        }
        private void funcUpd(int workShopID)
        {
            workShopDetailsObj = new WorkShopDetails();
            objEnt             = new WorkShop();
            if (checkDate && checkLstDate)
            {
                lblCheck.Visible  = false;
                btnSubmit.Visible = false;

                objEnt = workShopDetailsObj.readerForWorkShop(txtTopic.Text, 0);


                //Find the Uploaded Filename
                if (FileUpload.PostedFile.FileName == "")
                {
                    lblCheck.Text = "No";

                    if (workShopDetailsObj.editWorkShopDetails(workShopID, txtTopic.Text, DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text),
                                                               txtVenue.Text, int.Parse(drpTargetAudience.SelectedValue), int.Parse(txtseats.Text), int.Parse(drpSector.SelectedValue),
                                                               DateTime.Parse(txtLastdateNomination.Text), int.Parse(drpNationalInternational.SelectedValue), int.Parse(drpInvite.SelectedValue), null, null, null, lblCheck.Text))
                    {
                        txtTopic.Text    = "";
                        txtFromDate.Text = "";
                        txtToDate.Text   = "";

                        txtVenue.Text = "";
                        txtLastdateNomination.Text = "";
                        txtseats.Text = "";

                        drpInvite.SelectedIndex = -1;
                        drpNationalInternational.SelectedIndex = -1;
                        drpSector.SelectedIndex         = -1;
                        drpTargetAudience.SelectedIndex = -1;

                        if (lblExistingFile.Text != string.Empty)
                        {
                            lblMessage.Text = "Information Successfully Saved with existing Document";
                        }
                        else
                        {
                            lblMessage.Text = "Information Successfully Saved";
                        }

                        lblExistingFile.Text = "";
                        btnUpdate.Visible    = false;
                        btnSubmit.Visible    = true;
                    }
                }
                else
                {
                    lblCheck.Text = "Yes";
                    string filepath    = FileUpload.PostedFile.FileName;
                    string fileName    = Path.GetFileName(filepath);
                    string ext         = Path.GetExtension(fileName);
                    string contenttype = string.Empty;
                    if (isUpload == true)
                    {
                        //Check for Specific type of file support
                        switch (ext)
                        {
                        case ".doc":
                            contenttype = "application/vnd.ms-word";
                            break;

                        case ".docx":
                            contenttype = "application/vnd.ms-word";
                            break;

                        case ".pdf":
                            contenttype = "application/pdf";
                            break;
                        }
                        if (contenttype != string.Empty)
                        {
                            //Read File from the user Maschine
                            Stream fileread = FileUpload.PostedFile.InputStream;
                            //Read the file and convert it into Binary format.
                            BinaryReader readfile = new BinaryReader(fileread);
                            //convert streams in byte format
                            Byte[] readByteFile = readfile.ReadBytes((Int32)fileread.Length);


                            //functioncall for Update in database
                            if (lblCheck.Text == "Yes")
                            {
                                if (workShopDetailsObj.editWorkShopDetails(workShopID, txtTopic.Text, DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text),
                                                                           txtVenue.Text, int.Parse(drpTargetAudience.SelectedValue), int.Parse(txtseats.Text), int.Parse(drpSector.SelectedValue),
                                                                           DateTime.Parse(txtLastdateNomination.Text), int.Parse(drpNationalInternational.SelectedValue), int.Parse(drpInvite.SelectedValue), readByteFile, fileName, contenttype, lblCheck.Text))
                                {
                                    txtTopic.Text    = "";
                                    txtFromDate.Text = "";
                                    txtToDate.Text   = "";

                                    txtVenue.Text = "";
                                    txtLastdateNomination.Text = "";
                                    txtseats.Text = "";

                                    drpInvite.SelectedIndex = -1;
                                    drpNationalInternational.SelectedIndex = -1;
                                    drpSector.SelectedIndex         = -1;
                                    drpTargetAudience.SelectedIndex = -1;

                                    if (lblExistingFile.Text != string.Empty)
                                    {
                                        lblMessage.Text = "Information Successfully Saved with New Document";
                                    }
                                    else
                                    {
                                        lblMessage.Text = "Information Successfully Saved";
                                    }

                                    lblExistingFile.Text = "";
                                    btnUpdate.Visible    = false;
                                    btnSubmit.Visible    = true;
                                }
                            }
                        }
                        else
                        {
                            //lblCheck.Text = "Only format with extension .docx, .doc, .pdf Supported";
                            lblMessage.Text = "Only format with extension .docx, .doc, .pdf Supported";
                        }
                    }
                    else
                    {
                        lblMessage.Text = "File Size upto 5 MB Supported";
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //it maintain if you take file upload in side updatepannel(in update pannel your simple upload not work without this line)
            //ScriptManager.GetCurrent(this).RegisterPostBackControl(this.btnUpdate);

            try
            {
                objEnt             = new WorkShop();
                workShopDetailsObj = new WorkShopDetails();


                //Bind All the Drop Down
                if (IsPostBack == false)
                {
                    if (Utility.CheckAccess("WorkshopDetailsAddEdit") == 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);
                    }
                    //Bind all drop down
                    this.funDropBind();
                }


                //Function Called for Update
                workShopId = Request.QueryString["wI"];

                if (IsPostBack == false)
                {
                    if (workShopId != null)
                    {
                        //call function for reader with work ID
                        objEnt = workShopDetailsObj.readerForWorkShop("", int.Parse(workShopId));

                        // Set Entity in variables
                        btnSubmit.Visible = false;

                        ////local variables to store updated values

                        DateTime fromDate = DateTime.Parse(objEnt.FromDate.ToString());
                        DateTime toDate   = DateTime.Parse(objEnt.ToDate.ToString());
                        DateTime lastDate = DateTime.Parse(objEnt.LastDate.ToString());

                        //string FileNameTxt = Request.QueryString["fnm"];


                        txtTopic.Text              = objEnt.Topic;
                        txtFromDate.Text           = fromDate.ToString(clsConstant.DATE_FORMAT);
                        txtToDate.Text             = toDate.ToString(clsConstant.DATE_FORMAT);
                        txtVenue.Text              = objEnt.Venue;
                        txtseats.Text              = objEnt.seats.ToString();
                        txtLastdateNomination.Text = lastDate.ToString(clsConstant.DATE_FORMAT);
                        lblExistingFile.Text       = objEnt.FileName;

                        // Drop down query string for Sector

                        string sector = objEnt.Sector.ToString();

                        drpSector.SelectedValue = sector;

                        // Drop down query string for Invite

                        string invite = objEnt.Invite.ToString();
                        drpInvite.SelectedValue = invite;

                        // Drop down query string for International and National

                        string InternationalNational = objEnt.NationalInternational.ToString();
                        drpNationalInternational.SelectedValue = InternationalNational;

                        // Drop down query string for TargetAudience

                        string targetAudience = objEnt.TargetAudience.ToString();
                        drpTargetAudience.SelectedValue = targetAudience;
                    }
                    else
                    //Condition to check for the First time
                    {
                        lblExistingFile.Visible = false;
                        lblFileUploaded.Visible = false;
                        btnUpdate.Visible       = false;
                        btnSubmit.Visible       = true;
                    }
                }
                //Redundancy Checking

                if (IsPostBack)
                {
                    //var ctrlName = Request.Params[PageBase.postEventSourceID];
                    //var args = Request.Params[PageBase.postEventArgumentID];

                    //  HandleCustomPostbackEvent(ctrlName, args);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
        //function for custom post back
        private void HandleCustomPostbackEvent(string ctrlName, string args)
        {
            workShopDetailsObj      = new WorkShopDetails();
            objEnt                  = new WorkShop();
            lblFileUploaded.Visible = true;
            lblExistingFile.Visible = true;

            string topic = txtTopic.Text;

            if (topic != "")
            {
                if (ctrlName == txtTopic.UniqueID && args == "OnBlur")
                {
                    //check for redundancy
                    try
                    {
                        objEnt = workShopDetailsObj.readerForWorkShop(txtTopic.Text, 0);

                        if (objEnt.Topic != null)
                        {
                            ////local variables to store updated values
                            lblMessage.Text = "Data Available in Database";
                            DateTime fromDate = DateTime.Parse(objEnt.FromDate.ToString());
                            DateTime toDate   = DateTime.Parse(objEnt.ToDate.ToString());
                            DateTime lastDate = DateTime.Parse(objEnt.LastDate.ToString());

                            txtFromDate.Text           = fromDate.ToString(clsConstant.DATE_FORMAT);
                            txtToDate.Text             = toDate.ToString(clsConstant.DATE_FORMAT);
                            txtVenue.Text              = objEnt.Venue;
                            txtseats.Text              = objEnt.seats.ToString();
                            txtLastdateNomination.Text = lastDate.ToString(clsConstant.DATE_FORMAT);
                            lblExistingFile.Text       = objEnt.FileName;

                            // Drop down query string for Sector


                            drpSector.SelectedIndex = 0;
                            string sector = objEnt.Sector.ToString();

                            drpSector.SelectedValue = sector;

                            // Drop down query string for Invite

                            drpInvite.SelectedIndex = 0;
                            string invite = objEnt.Invite.ToString();
                            //drpInvite.Items.FindByText("----------SELECT----------").Selected = false;
                            drpInvite.SelectedValue = invite;

                            // Drop down query string for International and National

                            drpNationalInternational.SelectedIndex = 0;
                            string InternationalNational = objEnt.NationalInternational.ToString();
                            //drpNationalInternational.Items.FindByText("----------SELECT----------").Selected = false;
                            drpNationalInternational.SelectedValue = InternationalNational;

                            // Drop down query string for TargetAudience

                            drpTargetAudience.SelectedIndex = 0;
                            string targetAudience = objEnt.TargetAudience.ToString();
                            //drpTargetAudience.Items.FindByText("----------SELECT----------").Selected = false;
                            drpTargetAudience.SelectedValue = targetAudience;

                            btnSubmit.Visible = false;
                            btnUpdate.Visible = true;
                        }
                        else
                        {
                            btnSubmit.Visible = true;
                            btnUpdate.Visible = false;
                            lblMessage.Text   = "";
                        }
                    }

                    catch (Exception exMessage)
                    {
                        logger.Error(exMessage);
                    }
                }
            }
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //txtRefID.Visible = false;
            //btnSubmit.Visible = false;
            //btnUpdate.Visible = false;
            //lblRef.Visible = false;


            //Chk for other functionality
            if (IsPostBack == false)
            {
                try
                {
                    this.getLoan();
                    txtid.Attributes.Add("readonly", "readonly");

                    if (Session[clsConstant.TOKEN] == null)
                    {
                        UrlParameterPasser urlWrapper = new UrlParameterPasser();
                        urlWrapper.Url = "../Logout.aspx";
                        urlWrapper.PassParameters();
                    }
                    else
                    {
                        if (Request.QueryString["isFinal"] != "")
                        {
                            nomIsFinal = bool.Parse(Request.QueryString["isFinal"]);
                            if (nomIsFinal)
                            {
                                //btnBack.Visible = true;
                            }
                        }



                        if ((((UserDetails)Session[clsConstant.TOKEN]).SuperUser) == true)
                        {
                            // bind the all agency dropdown
                            this.fillAllDrop();
                            LoanProject.Enabled = true;
                            IsNew_CheckedChanged(this, new EventArgs());
                            //IsNew.Checked = true;
                        }
                        else
                        {
                            // bind only agency to the users
                            this.bindAgencyForUser();
                            IsNew_CheckedChanged(this, new EventArgs());
                            //IsNew.Checked = true;
                        }


                        this.readRole();

                        if (IsUpload == false)
                        {
                            UrlParameterPasser urlWrapper = new UrlParameterPasser();
                            urlWrapper.Url = "../Logout.aspx";
                            urlWrapper.PassParameters();
                        }
                        else
                        {
                            objEnt             = new WorkShop();
                            workShopDetailsObj = new WorkShopDetails();
                            nomID              = Request.QueryString["nomI"];
                            objEnt             = workShopDetailsObj.readerForWorkShop("", int.Parse(nomID));
                            lblNomination.Text = "<b/>" + objEnt.Topic.ToString();
                            lblSeats.Text      = "" + objEnt.seats.ToString();
                            this.getCount();
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
            }
        }