Exemplo n.º 1
0
        public EmployeeAdding()
        {
            InitializeComponent();
            DataContext = this;
            ISqlComunicator sqlComunicator = new AddingEmployeeDataAccess();
            DataTable       result         = DataAcces.Instance.GetData(sqlComunicator);

            ComboBoxItems = new ObservableCollection <string>(result.Rows.OfType <DataRow>().Select(row => row.Field <string>("Name").ToString()));
        }
Exemplo n.º 2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         Employee = new Employee();
         if (LogBox.Text.Length >= 3 && LogBox.Text.Length <= 20)
         {
             Employee.UserLogin = LogBox.Text;
         }
         else
         {
             MessageBox.Show("Incorrect Login (Length should be between 3-20");
             throw new Exception();
         }
         if ((NamBox.Text.Length >= 3 && NamBox.Text.Length <= 20))
         {
             Employee.Name = NamBox.Text;
         }
         else
         {
             MessageBox.Show("Incorrect Name (Length should be between 3-20");
             throw new Exception();
         }
         if ((SurBox.Text.Length >= 3 && SurBox.Text.Length <= 20))
         {
             Employee.Surname = SurBox.Text;
         }
         else
         {
             MessageBox.Show("Incorrect Surname (Length should be between 3-20");
             throw new Exception();
         }
         if ((SurBox.Text.Length >= 3 && SurBox.Text.Length <= 20))
         {
             Employee.PositionName = PosComBox.Text;
         }
         else
         {
             MessageBox.Show("Incorrect Position name (Length should be between 3-20");
             throw new Exception();
         }
         if (
             DisBox.Text.Where(c => char.IsDigit(c)).Count() == DisBox.Text.Length
             &&
             Convert.ToInt64(DisBox.Text) < 100
             &&
             Convert.ToInt64(DisBox.Text) >= 0
             )
         {
             Employee.DiscountLevel = Convert.ToInt16(DisBox.Text);
         }
         else
         {
             MessageBox.Show("Incorrect Discount Level (should be between <0;100))");
             throw new Exception();
         }
         if (PassBox.Password == PassBox1.Password
             &&
             PassBox.Password.Length >= 3 && PassBox.Password.Length <= 20)
         {
             Employee.Password = PassBox.Password;
         }
         else
         {
             MessageBox.Show("Incorrect Password name (Length should be between 3-20 and Passwords fields schould have same values");
             throw new Exception();
         }
         ISqlComunicator sqlComunicator = new AddingEmployeeDataAccess(Employee);
         DataAcces.Instance.AddData(sqlComunicator);
         Employee = null;
     }
     catch (Exception ex)
     {
         Employee = null;
         return;
     }
 }