Exemplo n.º 1
0
 public void updateEmployee(string name, string nation, long?id, long?phone, string address, int accCode, int oldAcc, string role, int EmID)
 {
     using (EmployeeTableAdapter employeeTableAdapter = new EmployeeTableAdapter())
     {
         try
         {
             employeeTableAdapter.Update(new int?(EmID), name, nation, id, address, phone, new int?(accCode), new int?(oldAcc), role);
         }
         catch (Exception exception)
         {
             throw new Exception(string.Concat("Error updating employee. ", exception.Message));
         }
     }
 }
Exemplo n.º 2
0
        // insert Update into employee table
        protected void updateEmployee()
        {
            int     id        = int.Parse(txtEmployeeNumber.Text);
            string  name      = txtName.Text;
            string  address   = txtAddress.Text;
            string  city      = txtCity.Text;
            string  province  = ddlProvinceE.SelectedValue;
            string  zipcode   = txtZipcode.Text;
            decimal homephone = decimal.Parse(txtHomePhone.Text);
            decimal cellphone = decimal.Parse(txtCellPhone.Text);
            string  email     = txtEmail.Text;
            //Treat DOB
            string   year    = ddlDOBY.SelectedValue;
            string   month   = ddlDOBM.SelectedValue;
            string   day     = ddlDOBD.SelectedValue;
            string   dobTemp = year + "-" + month + "-" + day;
            DateTime dob     = DateTime.Parse(dobTemp);

            int     dept   = int.Parse(ddlDept.SelectedValue);
            int     title  = int.Parse(ddlTitle.SelectedValue);
            decimal salary = decimal.Parse(txtSalary.Text);
            //Treat startDate
            //Treat startDate
            string   syear     = ddlStartdty.SelectedValue;
            string   smonth    = ddlStartdtm.SelectedValue;
            string   sday      = ddlStartdtd.SelectedValue;
            string   startTemp = syear + "-" + smonth + "-" + sday;
            DateTime startdate = DateTime.Parse(startTemp);

            string gender = "";

            if (rdbGender.SelectedIndex == 1)
            {
                gender = "F";
            }
            else if (rdbGender.SelectedIndex == 2)
            {
                gender = "O";
            }
            else
            {
                gender = "M";
            }
            string status = "A";

            if (rdbStatus.SelectedIndex != 0)
            {
                status = "F";
            }

            int result = adpEmployee.Update(name, address, city, province, zipcode, homephone, cellphone, email, dob, gender, dept, title, startdate, salary, status, id);

            if (result == 1)
            {
                lblErrorMessage.Text      = "Employee Update";
                lblErrorMessage.ForeColor = System.Drawing.Color.Green;
            }
            else
            {
                lblErrorMessage.Text      = "Employee NOT Update";
                lblErrorMessage.ForeColor = System.Drawing.Color.Red;
            }
        }