Exemple #1
0
        private void saveBtn(object sender, RoutedEventArgs e)
        {
            try
            {
                var suppModel = new supplier
                {
                    SupplierID  = int.Parse(SuppIdBox.Text),
                    FirstName   = FirstNameBox.Text,
                    LastName    = LastNameBox.Text,
                    Address     = AddressBox.Text,
                    City        = CityBox.Text,
                    PinCode     = int.Parse(PinCodeBox.Text),
                    PhoneNumber = int.Parse(PhoneNrBox.Text),
                    Email       = EmailBox.Text,
                    DateJoin    = DateJoinPicker.SelectedDate,
                    SupplierOf  = SuppBox.Text,
                };

                SuppIdBox.Clear();
                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                PinCodeBox.Clear();
                PhoneNrBox.Clear();
                EmailBox.Clear();
                SuppBox.Clear();

                dc.suppliers.InsertOnSubmit(suppModel);
                dc.SubmitChanges();

                MessageBox.Show("Supplier has been added");
                LoadData();
                LoadWindow();
            }
            catch
            {
                MessageBox.Show("u need to fill out all fields correct");
            }
        }
Exemple #2
0
        private void saveBtn(object sender, RoutedEventArgs e)
        {
            try
            {
                var empModel = new employee
                {
                    EmployeeID  = int.Parse(EmpIdBox.Text),
                    FirstName   = FirstNameBox.Text,
                    LastName    = LastNameBox.Text,
                    Address     = AddressBox.Text,
                    City        = CityBox.Text,
                    PinCode     = int.Parse(PinCodeBox.Text),
                    PhoneNumber = int.Parse(PhoneNrBox.Text),
                    Email       = EmailBox.Text,
                    JoinDate    = DateJoinPicker.SelectedDate
                };

                EmpIdBox.Clear();
                FirstNameBox.Clear();
                LastNameBox.Clear();
                AddressBox.Clear();
                CityBox.Clear();
                PinCodeBox.Clear();
                PhoneNrBox.Clear();
                EmailBox.Clear();

                dc.employees.InsertOnSubmit(empModel);
                dc.SubmitChanges();

                MessageBox.Show("Employee has been added");
                LoadData();
                LoadWindow();
            }
            catch
            {
                MessageBox.Show("Thats not a valid action");
            }
        }