예제 #1
0
        //Delete workers from production team
        protected void btnSubProdWorker_Click(object sender, EventArgs e)
        {
            try
            {
                //Create instance of prodcionteam with ID of textbox value
                var pt = new PROD_TEAM { ID = Convert.ToInt32(txtSubProdWorker.Text) };
                //Attach records
                db.PROD_TEAM.Attach(pt);
                //Remove record
                db.PROD_TEAM.Remove(pt);
                db.SaveChanges();
                //Refresh gridview
                gvProdTeamProduction.DataBind();
            }
            catch
            {
                lblErrormsgProductionTeam.Text = "Please select a valid row to delete!";
            }

            //Set textbox back to default
            txtSubProdWorker.Text = "";
        }
예제 #2
0
        //Add workers to project
        protected void btnAddProdWorker_Click(object sender, EventArgs e)
        {
            try
            {
                //Create production team instance
                PROD_TEAM pt = new PROD_TEAM();

                //Gather information needed to form a new production team
                pt.projectID = Convert.ToInt32(this.ddlProjectID.SelectedValue);
                pt.workerID = this.ddlProductionWorkerNameProduction.SelectedIndex + 1;
                pt.teamPhaseIn = this.txtProductionTeamPhaseProduction.Text;

                //Save changes to database
                db.PROD_TEAM.Add(pt);
                db.SaveChanges();

                //Refresh the gridview
                gvProdTeamProduction.DataBind();
            }

            catch
            {
                lblErrormsgProductionTeam.Text = "Something went wrong!";
            }

            //Set the dropdownlist and textbox back to default
            this.ddlProductionWorkerNameProduction.SelectedIndex = 0;
            this.txtProductionTeamPhaseProduction.Text = "";
        }