Ejemplo n.º 1
0
        public void ResetAddStudentControl(bool clearLog = true)
        {
            /*
             * This function contains all code that needs to be executed when the control is reloaded
             *
             * You need to edit this code.
             * Example: Emptying textboxes and gridviews
             *
             */
            phoneNumbers.Clear();
            phoneTypes.Clear();
            StudentidTextbox.ResetText();
            FirstnameTextbox.ResetText();
            LastnameTextbox.ResetText();
            GenderTextbox.ResetText();
            StreetadressTextbox.ResetText();
            ZipcodeTextbox.ResetText();
            CityTextbox.ResetText();
            CountryTextbox.ResetText();
            BirthdateDatepicker.Value = BirthdateDatepicker.MaxDate;
            PhoneNumberTextbox.ResetText();
            AddedPhoneNumbers_Readonly.ResetText();

            if (clearLog)
            {
                RegisterStatusTextbox.ResetText();
            }
        }
Ejemplo n.º 2
0
 void ClearFields()
 {
     FirstNameTextbox.Clear();
     LastNameTextbox.Clear();
     AccountNumberTextbox.Clear();
     BalanceTextbox.Clear();
     EmailTextbox.Clear();
     PhoneNumberTextbox.Clear();
     BalanceDateTextbox.Clear();
 }
Ejemplo n.º 3
0
        private void StoreBtn_Click(object sender, EventArgs e)
        {
            //verifies data was entered
            if (string.IsNullOrEmpty(FirstNameTextbox.Text))
            {
                MessageBox.Show("Please enter your First Name.");
                return;
            }
            if (string.IsNullOrEmpty(LastNameTextbox.Text))
            {
                MessageBox.Show("Please enter your Last Name.");
                return;
            }
            if (string.IsNullOrEmpty(AddressTextBox.Text))
            {
                MessageBox.Show("Please enter your Address.");
                return;
            }
            if (string.IsNullOrEmpty(AddressTextBox.Text))
            {
                MessageBox.Show("Please enter your City/State/Zipcode.");
                return;
            }
            if (string.IsNullOrEmpty(PhoneNumberTextbox.Text))
            {
                MessageBox.Show("Please enter your Phone Number");
                return;
            }
            //calls method to add data
            addData(FirstNameTextbox.Text, LastNameTextbox.Text, AddressTextBox.Text, CityStateZipcodeTextboc.Text, PhoneNumberTextbox.Text);



            //clears all items
            FirstNameTextbox.Clear();
            LastNameTextbox.Clear();
            AddressTextBox.Clear();
            CityStateZipcodeTextboc.Clear();
            PhoneNumberTextbox.Clear();
        }
Ejemplo n.º 4
0
        private void NewWorkerAddButton_Click(object sender, EventArgs e)
        {
            bool     IsNameOk     = false;
            bool     IsPhoneOk    = false;
            bool     IsContractOk = false;
            bool     IsSalaryOk   = false;
            int      num;
            string   newLibrarianName           = LibrarianFullNameTextbox.Text;
            string   newLibrarianPhone          = PhoneNumberTextbox.Text;
            string   phoneNumberPattern         = @"[+]{1}\b\d{12}\b";
            DateTime newLibrarianBirthDate      = DateTime.Parse(DayCombobox.Text + " " + MonthCombobox.Text + " " + YearCombobox.Text);
            string   newLibrarianContractNumber = ContractNumberTextbox.Text;
            string   newLibrarianSalary         = SalaryTextbox.Text;

            using (LibraryDBEntities dbContext = new LibraryDBEntities()) {
                Employee employee = new Employee();
                Job      job      = dbContext.Jobs.SingleOrDefault(j => j.Job_Id == 2);
                if (newLibrarianName != null && newLibrarianName.Trim().Length > 0)
                {
                    employee.Name = newLibrarianName;
                    IsNameOk      = true;
                }
                if (newLibrarianPhone != null && newLibrarianPhone.Trim().Length > 0)
                {
                    if (!Regex.IsMatch(newLibrarianPhone, phoneNumberPattern))
                    {
                        MessageBox.Show("Wrong mobile phone number", "Error", MessageBoxButtons.OK);
                        return;
                    }
                    employee.PhoneNumber = newLibrarianPhone;
                    IsPhoneOk            = true;
                }
                if (newLibrarianContractNumber != null && newLibrarianContractNumber.Trim().Length > 0)
                {
                    Employee employExist = dbContext.Employees.SingleOrDefault(emp => emp.Login == newLibrarianContractNumber);
                    if (employExist == null)
                    {
                        employee.Login = newLibrarianContractNumber;
                        IsContractOk   = true;
                    }
                    else
                    {
                        MessageBox.Show("Such contract is already registered", "Error", MessageBoxButtons.OK);
                        return;
                    }
                }
                if (newLibrarianSalary != null && newLibrarianSalary.Trim().Length > 0)
                {
                    if (!int.TryParse(newLibrarianSalary, out num))
                    {
                        MessageBox.Show("Wrong characters in 'Salary' field", "Error", MessageBoxButtons.OK);
                        return;
                    }
                    if (Convert.ToInt32(newLibrarianSalary) < job.Min_Salary)
                    {
                        MessageBox.Show("Sallary is too small", "Error", MessageBoxButtons.OK);
                        return;
                    }
                    else if (Convert.ToInt32(newLibrarianSalary) > job.Max_Salary)
                    {
                        MessageBox.Show("Sallary is too big", "Error", MessageBoxButtons.OK);
                        return;
                    }
                    else
                    {
                        employee.Salary = Convert.ToInt32(newLibrarianSalary);
                        IsSalaryOk      = true;
                    }
                }
                if (!(IsNameOk && IsPhoneOk && IsContractOk && IsSalaryOk))
                {
                    MessageBox.Show("Some fields are empty. Please check your information", "Error", MessageBoxButtons.OK);
                    return;
                }
                employee.BirthDate = newLibrarianBirthDate;
                employee.HireDate  = DateTime.Now;
                employee.Job_Id    = 2;
                employee.Password  = "******";
                dbContext.Employees.Add(employee);
                dbContext.SaveChanges();
                LibrarianFullNameTextbox.Clear();
                PhoneNumberTextbox.Clear();
                ContractNumberTextbox.Clear();
                SalaryTextbox.Clear();
                MessageBox.Show("New Librarian added", "Error", MessageBoxButtons.OK);
            }
        }