Пример #1
0
        // insert register into employee table
        private void insertEmployee()
        {
            tblEmployee          = adpEmployee.GetData();
            Cache["tblEmployee"] = tblEmployee;

            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
            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";
            }

            int result = adpEmployee.Insert(name, address, city, province, zipcode, homephone, cellphone, email, dob, gender, dept, title, startdate, salary, "A");

            if (result == 1)
            {
                clearFields();
                resetFields();
                lblErrorMessage.Text      = "Employee Inserted ";
                lblErrorMessage.ForeColor = System.Drawing.Color.Yellow;
                insertPassword();
            }
            else
            {
                lblErrorMessage.Text      = "Employee NOT Inserted";
                lblErrorMessage.ForeColor = System.Drawing.Color.Red;
            }
        }
Пример #2
0
    public EmployeeDataTable getEmployee()
    {
        EmployeeDataTable data;

        using (EmployeeTableAdapter employeeTableAdapter = new EmployeeTableAdapter())
        {
            try
            {
                data = employeeTableAdapter.GetData();
            }
            catch (Exception exception)
            {
                throw new Exception(string.Concat("unable to get employees. ", exception.Message));
            }
        }
        return(data);
    }
Пример #3
0
 /// <summary>
 /// Получить таблицу сотрудников
 /// </summary>
 /// <returns></returns>
 public static DataTable GetRowsEmployee()
 {
     return(_empoyeeTableAdapter.GetData());
 }