예제 #1
0
        protected void doUpdate_Add()
        {
            this.errProvider.Clear();
            Employee newEmp = new Employee();
            newEmp.Empid = -1;
            newEmp.Lastname = this.txtLastname.Text;
            newEmp.Firstname = this.txtFirstname.Text;
            newEmp.Title = this.txtTitle.Text;
            newEmp.Titleofcourtesy = this.cbTitleofCourtesy.Text;
            newEmp.Birthdate = this.dTPBirthday.Value;
            newEmp.Hiredate = this.dTPHireday.Value;
            newEmp.Address = this.txtAddress.Text;
            newEmp.City = this.txtCity.Text;
            newEmp.Region = this.txtRegion.Text;
            newEmp.Postalcode = this.txtPostalCode.Text;
            newEmp.Country = this.cbCountry.Text;
            newEmp.Phone = this.txtPhone.Text;
            try
            {
                EmployeeModel.IdItem cbItem = (EmployeeModel.IdItem)this.cbManagerID.SelectedItem;
                newEmp.Mgrid = cbItem.Id;
            }
            catch { newEmp.Mgrid = -1; }
            newEmp.JobStatus = true;

            try
            {

                int[] check = newEmp.isValid_multi();

                if (check.Length>0)
                {
                    this.showErrors(newEmp, check);

                }
                else
                {
                    if (this.newEmpMode == true)
                        this.dataModel.insertNewRow(newEmp);
                    else
                    {
                        newEmp.Empid = int.Parse(this.txtEmployeeID.Text.Trim());
                        this.dataModel.updateRow(newEmp);
                    }
                    this.clearForm();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }