Пример #1
0
        public Employee insertEmployee(EmployeeInsertSdi employeeInsertSdi)
        {
            con = SqlServerConnection.getConnnection();
            con.Open();
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into Employee values(@employeeid,@ssn,@fname,@mname,@lname,@salary,@dob,@address,@phonenumber,@roletype,@username,@password)");
            SqlCommand command = new SqlCommand(sql.ToString(), con);

            command.Parameters.AddWithValue("employeeid", employeeInsertSdi.EmployeeId1);
            command.Parameters.AddWithValue("ssn", employeeInsertSdi.SSN1);
            command.Parameters.AddWithValue("fname", employeeInsertSdi.Fname);
            command.Parameters.AddWithValue("mname", employeeInsertSdi.Mname);
            command.Parameters.AddWithValue("lname", employeeInsertSdi.Lname);
            command.Parameters.AddWithValue("dob", DateTime.Parse(employeeInsertSdi.DOB1));
            command.Parameters.AddWithValue("phonenumber", employeeInsertSdi.PhoneNumber);
            command.Parameters.AddWithValue("address", employeeInsertSdi.Address);
            command.Parameters.AddWithValue("username", employeeInsertSdi.Username);
            command.Parameters.AddWithValue("password", employeeInsertSdi.Password);
            command.Parameters.AddWithValue("salary", employeeInsertSdi.Salary);
            command.Parameters.AddWithValue("roletype", employeeInsertSdi.RoleType);
            command.ExecuteNonQuery();
            con.Close();
            return(this.getEmployeeById(employeeInsertSdi.EmployeeId1));
        }
Пример #2
0
 private void insertCustom_Click(object sender, EventArgs e)
 {
     if (!passwordTextBox.Text.Equals(retypePasswordTextBox.Text))
     {
         MessageBox.Show("retype password does not match", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (employeeService.isExistAccount(usernameTextBox.Text))
     {
         MessageBox.Show("username already exists", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (employeeService.isExistSSN(ssnTextBox.Text))
     {
         MessageBox.Show("ssn already exists", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (patronService.isExistAccount(usernameTextBox.Text))
     {
         MessageBox.Show("username already exists", "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         EmployeeInsertSdi employeeInsertSdi = new EmployeeInsertSdi();
         employeeInsertSdi.EmployeeId1 = employeeIdTextBox.Text;
         employeeInsertSdi.Fname       = fnameTextBox.Text;
         employeeInsertSdi.Lname       = lnameTextBox.Text;
         employeeInsertSdi.Mname       = mnameTextBox.Text;
         employeeInsertSdi.DOB1        = dobTextBox.Value.ToString();
         employeeInsertSdi.PhoneNumber = phoneNumberTextBox.Text;
         employeeInsertSdi.Username    = usernameTextBox.Text;
         employeeInsertSdi.Address     = addressTextBox.Text;
         employeeInsertSdi.Password    = passwordTextBox.Text;
         employeeInsertSdi.RoleType    = roleTypeTextBox.Text;
         employeeInsertSdi.SSN1        = ssnTextBox.Text;
         employeeInsertSdi.Salary      = Convert.ToDouble(salaryTextBox.Text);
         Employee employee = employeeService.insertEmployee(employeeInsertSdi);
         if (employee != null)
         {
             this.Close();
             employeeForm.addDataToTable(employee);
         }
     }
 }
Пример #3
0
 public Employee insertEmployee(EmployeeInsertSdi employeeInsertSdi)
 {
     return(employeeRepoService.insertEmployee(employeeInsertSdi));
 }