private bool isFormValid() { if (StudentNameTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Name is required"); StudentNameTextBox.Focus(); return(false); } if (PhoneNumberTextBox.Text.Trim() == string.Empty) { SMSMessageBox.ShowErrorMessage("Phone number is required"); PhoneNumberTextBox.Focus(); return(false); } if (DepartmentComboBox.SelectedIndex == -1) { SMSMessageBox.ShowErrorMessage("Department is required"); DepartmentComboBox.Focus(); return(false); } return(true); }
private bool IsFormValid() { if (StudentNameTextBox.Text.Trim() == string.Empty) { MessageBox.Show("Student name is Required.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); StudentNameTextBox.Focus(); return(false); } if (StudentNameTextBox.Text.Length >= 200) { MessageBox.Show("Student Name length should be less than or equal to 200 characters.", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); StudentNameTextBox.Focus(); return(false); } return(true); }
private void ResetFormControl() { StudentNameTextBox.Clear(); AgeTextBox.Clear(); GenderTextBox.Clear(); DescriptionTextBox.Clear(); IdPictureBox.Dispose(); StudentNameTextBox.Focus(); if (this.IsUpdate) { this.StudentId = 0; this.IsUpdate = false; SaveButton.Text = "Save User Information"; DeleteButton.Enabled = false; ViewStudentForm vsf = new ViewStudentForm(); //vsf.LoadDataIntoDataGridView(); vsf.StudentDataGridView.Refresh(); } }
public void Enroll(object sender, RoutedEventArgs e) { StudentIDTextBox.Text = (StudentIDTextBox != null) ? StudentIDTextBox.Text.Trim() : ""; StudentNameTextBox.Text = (StudentNameTextBox != null) ? StudentNameTextBox.Text.Trim() : ""; StudentGradeTextBox.Text = (StudentGradeTextBox != null) ? StudentGradeTextBox.Text.Trim() : ""; StudentSectionComboBox.Text = (StudentSectionComboBox != null) ? StudentSectionComboBox.Text.Trim() : ""; if (StudentIDTextBox.Text != "" && StudentNameTextBox.Text != "" && StudentGradeTextBox.Text != "" && StudentSectionComboBox.Text != "") { int ID = int.Parse(StudentIDTextBox.Text); string name = StudentNameTextBox.Text; int grade = int.Parse(StudentGradeTextBox.Text); int section = int.Parse(StudentSectionComboBox.Text); if (ID > 0 && ID < 256 && grade <= 100 && grade >= 0) { try { AssemblyStudentDB.enrollStudent((char)ID, name, (char)name.Length, (char)grade, (char)section); } catch { Console.WriteLine("Error in enrollStudent"); } RefreshList(); } else { MessageBox.Show("Enter Valid Number between 1 and 255 "); } } else { MessageBox.Show("No empty Values"); } StudentIDTextBox.Clear(); StudentNameTextBox.Clear(); StudentGradeTextBox.Clear(); StudentSectionComboBox.SelectedIndex = -1; }
private void button1_Click(object sender, EventArgs e) { int check; if (StudentNameTextBox.Text == string.Empty && DepartmentComboBox.SelectedIndex < 0 && RollNoTextBox.Text == string.Empty && CategoryComboBox.SelectedIndex < 0 && BookNameTextBox.Text == string.Empty) { MessageBox.Show("Fill all Fields!"); } else if (StudentNameTextBox.Text == string.Empty) { MessageBox.Show("Please enter student name"); } else if (DepartmentComboBox.SelectedIndex < 0) { MessageBox.Show("Please Select Department"); } else if (RollNoTextBox.Text == string.Empty) { MessageBox.Show("Please Enter Roll Number"); } else if (!int.TryParse(RollNoTextBox.Text, out check)) { MessageBox.Show("Roll No can only be Integar"); RollNoTextBox.Clear(); } else if (CategoryComboBox.SelectedIndex < 0) { MessageBox.Show("Please Select Category"); } else if (BookNameTextBox.Text == string.Empty) { MessageBox.Show("please enter book name"); } else { string Student_Name = StudentNameTextBox.Text; string Department = DepartmentComboBox.SelectedItem.ToString(); string Roll_No = RollNoTextBox.Text; string Category = CategoryComboBox.SelectedItem.ToString(); string Book_Name = BookNameTextBox.Text; DateTime Issuance_Date = IssuanceDateDateTimePicker.Value; DateTime Due_Date = DueDateDateTimePicker.Value; int recieved = dataAccess.InsertIntoBookIssuanceTable(Student_Name, Department, Roll_No, Category, Book_Name, Issuance_Date, Due_Date); if (recieved == 1) { date_time = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(); writer = file.AppendText(); writer.WriteLine("New Book is Issued at " + date_time); writer.Close(); MessageBox.Show("Data is stored successfully"); } else { MessageBox.Show("Data is not Stored Successfully"); } StudentNameTextBox.Clear(); DepartmentComboBox.SelectedIndex = -1; RollNoTextBox.Clear(); CategoryComboBox.SelectedIndex = -1; BookNameTextBox.Clear(); IssuanceDateDateTimePicker.ResetText(); DueDateDateTimePicker.ResetText(); } }