protected void btnUpdate_Click(Object sender, EventArgs e)
        {
            Button clickedButton = (Button)sender;

            // When the button is clicked,
            clickedButton.Enabled = false;
            // Save to database
            Opportunity opp = new Opportunity();

            opp.OpportunityId        = Convert.ToInt32(Session["AdminOppId"].ToString());
            opp.Name                 = tbName.Text;
            opp.Location             = tbThisLocation.Text;
            opp.JobDescription       = tbJobDescription.Text;
            opp.Requirement          = tbRequirement.Text;
            opp.DateApproved         = DateTime.Now;
            opp.OpportunityTypeId    = Convert.ToInt32(ddlType.SelectedItem.Value);
            opp.CPId                 = 1;
            opp.CPPId                = Convert.ToInt32(ddlSupervisor.SelectedItem.Value);
            opp.QuarterId            = Convert.ToInt32(ddlQuarter.SelectedItem.Value);
            opp.JobHours             = tbJobHours.Text;
            opp.MinimumAge           = tbRequirementAge.Text;
            opp.ResumeRequired       = rblResume.SelectedValue;
            opp.CrcRequiredByPartner = rblCRC.SelectedValue;
            opp.DistanceFromSU       = tbDistance.Text;
            opp.LinkToOnlineApp      = tbLink.Text;
            opp.OrientationDate      = Convert.ToDateTime(tbDate.Text);
            opp.TotalNumberSlots     = Convert.ToInt32(tbSlot.Text);
            opp.TimeCommittment      = ddlTimeCommitment.SelectedItem.Value;

            opp.Update();
            lblEmpty.Text = "The opportunity was updated successfully.";

            clickedButton.Enabled = true;
        }
Esempio n. 2
0
        protected void gvOpportunity_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            //Get the new Values.
            GridViewRow row        = gvOpportunity.Rows[e.RowIndex];
            TextBox     tbName     = (TextBox)row.FindControl("tbName");
            TextBox     tbLocation = (TextBox)row.FindControl("tbLocation");
            TextBox     tbJobDes   = (TextBox)row.FindControl("tbJobDes");
            Label       lblOppId   = (Label)row.FindControl("lblOppId");

            // Code to update the DataSource.
            Opportunity opp = new Opportunity();

            opp.Name           = tbName.Text;
            opp.Location       = tbLocation.Text;
            opp.JobDescription = tbJobDes.Text;
            opp.OpportunityId  = Convert.ToInt32(lblOppId.Text);

            opp.Update();

            //Reset the edit index.
            gvOpportunity.EditIndex = -1;
            //Bind data to the GridView control.
            DataBind();
        }
        protected void btnAdd_Click(Object sender, EventArgs e)
        {
            Button clickedButton = (Button)sender;

            if (clickedButton.Text == "Close")
            {
                string close = @"<script type='text/javascript'>
                                window.returnValue = true;
                                window.close();
                                </script>";
                base.Response.Write(close);
            }
            // When the button is clicked,
            // change the button text, and disable it.


            clickedButton.Text    = "...Processing...";
            clickedButton.Enabled = false;

            // Save to database
            Opportunity opp = new Opportunity();

            opp.Name                 = tbName.Text;
            opp.Location             = tbThisLocation.Text;
            opp.JobDescription       = tbJobDescription.Text;
            opp.Requirement          = tbRequirement.Text;
            opp.DateApproved         = DateTime.Now;
            opp.OpportunityTypeId    = Convert.ToInt32(ddlType.SelectedItem.Value);
            opp.CPId                 = 1;
            opp.CPPId                = Convert.ToInt32(ddlSupervisor.SelectedItem.Value);
            opp.QuarterId            = Convert.ToInt32(ddlQuarter.SelectedItem.Value);
            opp.JobHours             = tbJobHours.Text;
            opp.MinimumAge           = tbRequirementAge.Text;
            opp.ResumeRequired       = rblResume.SelectedValue;
            opp.CrcRequiredByPartner = rblCRC.SelectedValue;
            opp.DistanceFromSU       = tbDistance.Text;
            opp.LinkToOnlineApp      = tbLink.Text;
            try
            {
                opp.OrientationDate  = Convert.ToDateTime(tbDate.Text);
                opp.TotalNumberSlots = Convert.ToInt32(tbSlot.Text);
                opp.TimeCommittment  = ddlTimeCommitment.SelectedItem.Value;
            }
            catch
            {
            }

            if (Session["OppId"] != null && Session["IsClone"] == null)
            {
                opp.OpportunityId = Convert.ToInt32(Session["OppId"].ToString());
                opp.Update();
                lblEmpty.Text = "The opportunity was updated successfully. Please refresh the Opportunity page to review. Please close the window.";
            }
            else
            {
                opp.Add();
                lblEmpty.Text = "New opportunity was added successfully. Please refresh the Opportunity page to review. Please close the window.";
            }
            clickedButton.Enabled = true;
            clickedButton.Text    = "Close";
            Session["OppId"]      = null;
            Session["IsClone"]    = null;
        }