Ejemplo n.º 1
0
        protected void btnEmployeeRemove_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(btnEmployeeRemove.Attributes["data-id"]);

            try
            {
                //delete an existing record
                WORKER w = db.WORKERs.Find(id);
                db.WORKERs.Remove(w);
                db.SaveChanges();
                // Reset the employeelist
                DropDownHelper.PopulateEmployeeList(ddlEmployeeList);
                NotifyJS.DisplayNotification(this.Page, w.wrkFName + " " + w.wrkLName + " was successfully deleted.", "success");
            }
            catch (DataException dx)
            {
                NotifyJS.DisplayNotification(this.Page, dx.InnerException.InnerException.Message, "danger");
            }
        }
Ejemplo n.º 2
0
        protected void btnAddNewEmployee_Click(object sender, EventArgs e)
        {
            // Gather data to create new employee
            WORKER w = new WORKER();

            w.wrkFName  = txtEmployeeFName.Text;
            w.wrkLName  = txtEmployeeLName.Text;
            w.wrkTypeID = Convert.ToInt32(ddlEmployeePosition.SelectedValue);
            db.WORKERs.Add(w);

            try
            {
                db.SaveChanges();
                // Repopulate drop down lists
                DropDownList ddlEmployeeList = (DropDownList)Body.FindControl("ddlEmployeeList");
                DropDownHelper.PopulateEmployeeList(ddlEmployeeList);
                NotifyJS.DisplayNotification(this.Page, w.wrkFName + " " + w.wrkLName + " successfully created.", "success");
            }
            catch (DataException ex)
            {
                NotifyJS.DisplayNotification(this.Page, ex.InnerException.InnerException.Message, "danger");
            }
        }