private void sAddButton_Click(object sender, EventArgs e) { if (!Validation.isTextBoxValid(errorProvider1, sUserIdTextBox, sPassowrdtextBox, sFirstNametextBox, sLastNametextBox, sEmailTextBox, sPhoneTextBox)) { return; } //add student adminConnect = new AdminConnect(); StudentObject student = new StudentObject(); student.UserId = sUserIdTextBox.Text; student.Password = sPassowrdtextBox.Text; student.FirstName = sFirstNametextBox.Text; student.LastName = sLastNametextBox.Text; student.Phone = sPhoneTextBox.Text; student.Email = sEmailTextBox.Text; if (adminConnect.AddUser(student) <= 0) { //show error MessageBox.Show("Instructor not added", "Add error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } else { //display success message MessageBox.Show("Instructor added successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } }
private void iAddBtn_Click(object sender, EventArgs e) { //validate input //add instructor details if (!Validation.isTextBoxValid(errorProvider1, IuserIdTxtBox, iPasswordTxtBox, iFirstNameTxtBox, iLastNameTxtBox, iEmailTxtBox, iPhoneTxtBox)) { return; } //add instructor adminConnect = new AdminConnect(); InstructorObject instructor = new InstructorObject(); instructor.UserId = IuserIdTxtBox.Text; instructor.Password = iPasswordTxtBox.Text; instructor.FirstName = iFirstNameTxtBox.Text; instructor.LastName = iLastNameTxtBox.Text; instructor.Phone = iPhoneTxtBox.Text; instructor.Email = iEmailTxtBox.Text; if (adminConnect.AddUser(instructor) <= 0) { //show error MessageBox.Show("Instructor not added", "Add error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } else { //display success message MessageBox.Show("Instructor added successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } }
public WhereParam(AdminConnect connectors, string fieldName, AdminCompare valueOperator, string defaultValue, string dateFormat, FieldType fieldType) { this.Connector = connectors; this.FieldName = fieldName; this.Operator = valueOperator; this.DefaultValue = defaultValue; this.DateFormat = dateFormat; this.FieldType = fieldType; }
private void AdminContainer_Load(object sender, EventArgs e) { //display logged in user userFullNameLabel.Text = string.IsNullOrEmpty(AdminFullName) ? AdminFullName : "Logged in as " + AdminFullName; //populate datagrid view with data AdminConnect adminConnect = new AdminConnect(); insTbl = adminConnect.GetInstructors(); instructorDataGridView.DataSource = insTbl; FormClass.AddDatagridButtons(instructorDataGridView, 3, true); stuTbl = adminConnect.GetStudents(); studentDataGridView.DataSource = stuTbl; FormClass.AddDatagridButtons(studentDataGridView, 3, true); claTbl = adminConnect.GetClasses(); classDataGridView.DataSource = claTbl; FormClass.AddDatagridButtons(classDataGridView, 3, true); rubTbl = adminConnect.GetRubric(); rubricDataGridView.DataSource = rubTbl; FormClass.AddDatagridButtons(rubricDataGridView, 3, true); couTbl = adminConnect.GetCourse(); courseDataGridView.DataSource = couTbl; FormClass.AddDatagridButtons(courseDataGridView, 3, true); //bind views to datatable #region BindInstructor try { instructorBindingSrc = new BindingSource(); instructorBindingSrc.DataSource = adminConnect.GetInstructors(); IuserIdViewComboBox.Items.Clear(); IuserIdViewComboBox.DataSource = instructorBindingSrc; IuserIdViewComboBox.ValueMember = "userId"; IuserIdViewComboBox.DisplayMember = "userId"; IuserIdViewComboBox.DataBindings.Add("Text", instructorBindingSrc, "userId", false); if (!string.IsNullOrEmpty((string)IuserIdViewComboBox.SelectedValue) && !string.IsNullOrEmpty(IuserIdViewComboBox.Text)) { //bind other controls iPasswordViewtextBox.DataBindings.Add("Text", instructorBindingSrc, "password", false); iFirstNameViewtextBox.DataBindings.Add("Text", instructorBindingSrc, "fName", false); iLastNameViewTextBox.DataBindings.Add("Text", instructorBindingSrc, "lName", false); iEmailViewTextBox.DataBindings.Add("Text", instructorBindingSrc, "email", false); iPhoneViewTextBox.DataBindings.Add("Text", instructorBindingSrc, "phone", false); } else { errorProvider1.SetError(IuserIdViewComboBox, "Invalid selection"); return; } } catch (Exception) { throw; } #endregion #region BindStudent try { studentBindingSrc = new BindingSource(); } catch (Exception) { throw; } #endregion #region BindClass try { classBindingSrc = new BindingSource(); } catch (Exception) { throw; } #endregion #region BindCourse try { courseBindingSrc = new BindingSource(); } catch (Exception) { throw; } #endregion #region BindRubric try { rubricBindingSrc = new BindingSource(); } catch (Exception) { throw; } #endregion }