private void NewStudentAdd_Click(object sender, EventArgs e) { try { Item collegeItem = (Item)newStudentCollege.SelectedItem; Item majorItem = (Item)newStudentMajor.SelectedItem; String collegeID = collegeItem.Value.ToString(); String majorID = majorItem.Value.ToString(); String name = newStudentName.Text; if (name.Length == 0) { throw new System.ArgumentException("Parameter cannot be empty", "original"); } newStudentCollege.SelectedIndex = -1; newStudentName.Text = ""; Walton_DB.ExecSqlString( "INSERT INTO tbl_Students (StudentName, StudentCollege, StudentMajor) VALUES ('" + name.Trim() + "'," + collegeID + "," + majorID + ")"); loadData(); } catch { System.Windows.Forms.MessageBox.Show("You must enter a Name, College, and Major before adding a student.\n\nStudent not added.", "Error Adding Student", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
private void NewGradeAdd_Click(object sender, EventArgs e) { try { Item studentItem = (Item)newGradeStudent.SelectedItem; Item courseItem = (Item)newGradeCourse.SelectedItem; Item termItem = (Item)newGradeTerm.SelectedItem; String studentID = studentItem.Value.ToString(); String courseID = courseItem.Value.ToString(); String termID = termItem.Value.ToString(); String grade = (string)newGradeGrade.SelectedItem; Walton_DB.ExecSqlString("INSERT INTO tbl_Grades (Student, Course, Term, Grade) VALUES (" + studentID + "," + courseID + "," + termID + ",'" + grade + "')"); newGradeGrade.SelectedIndex = -1; loadData(); } catch { System.Windows.Forms.MessageBox.Show("You must select a Student, Course, Grade, and Term before adding a Grade.\n\nGrade not added.", "Error Adding Grade", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
private void bttnAddCust_Click(object sender, EventArgs e) { //INSERTINTO Customer(name, phone) VALUES('John', '4795551212')" if (Walton_DB.ExecSqlString("INSERT INTO Customer (name, phone) VALUES ('" + txtCustomerName.Text + "','" + txtRewardsTelephone.Text + "')")) { MessageBox.Show("Customer Added!"); } }
private void bttnAddExpense_Click(object sender, EventArgs e) { if (Walton_DB.ExecSqlString("INSERT INTO Expense (eDesc, expseCost) VALUES ('" + txtBoxExpseDesc.Text + "','" + txtBoxExpseAmt.Text + "')")) { MessageBox.Show("Expense Added!"); } txtBoxExpseAmt.Text = ""; txtBoxExpseDesc.Text = ""; }
private void bttnOrderInventory_Click(object sender, EventArgs e) { if (Walton_DB.ExecSqlString("INSERT INTO InventoryOrderingLog (Inventory_Name, Qty_Ordered, Date_Ordered) VALUES ('" + drpDownInventory.SelectedItem.ToString() + "','" + txtBoxInvQty.Text + "','" + txtBoxInvDate.Text + "')")) { MessageBox.Show("Inventory Order Logged!"); } drpDownInventory.SelectedIndex = -1; txtBoxInvQty.Text = ""; txtBoxInvSalesTax.Text = ""; txtBoxInvPreTax.Text = ""; txtBoxInvTotal.Text = ""; richTxtBoxInventory.Text = ""; txtBoxInvDate.Text = ""; }
private void btnAddStudent_Click(object sender, EventArgs e) { //Adds a student to the table if (txtName.Text == "") { MessageBox.Show("Please enter a name."); return; } if (cboCollege.SelectedIndex == -1) { MessageBox.Show("Please select a college."); return; } if (cboMajor.SelectedIndex == -1) { MessageBox.Show("Please select a major."); return; } string CollegeID = dtColleges.Select("College = '" + cboCollege.Text + "'")[0]["CollegeID"].ToString(); string MajorID = dtMajors.Select("Major = '" + cboMajor.Text + "'")[0]["MajorID"].ToString(); if (Walton_DB.ExecSqlString("INSERT INTO tbl_Students (StudentName, StudentCollege, StudentMajor) VALUES ('" + txtName.Text.Trim() + "'," + CollegeID.ToString() + "," + MajorID.ToString() + ")")) { MessageBox.Show("Student " + txtName.Text + " was added to the database." + System.Environment.NewLine + "College: " + cboCollege.Text + "(" + CollegeID + ")" + System.Environment.NewLine + "Major: " + cboMajor.Text + "(" + MajorID + ")"); txtName.Text = ""; cboCollege.SelectedIndex = -1; cboMajor.SelectedIndex = -1; RefreshStudentDGV(); } else { MessageBox.Show("Database Error - please try again!"); } }
private void btnAddGrade_Click(object sender, EventArgs e) { //Adds the grade to the class for that particular student if (cboStudent.SelectedIndex == -1) { MessageBox.Show("You must select a student."); return; } if (cboCourse.SelectedIndex == -1) { MessageBox.Show("You must select a course."); return; } if (cboGrade.SelectedIndex == -1) { MessageBox.Show("You must select a gradet."); return; } if (cboTerm.SelectedIndex == -1) { MessageBox.Show("You must select a term."); return; } string StudentID = dtStudents.Select("StudentName = '" + cboStudent.Text + "'")[0]["StudentID"].ToString(); string CourseID = dtCourse.Select("Course = '" + cboCourse.Text + "'")[0]["CourseID"].ToString(); string TermID = dtTerms.Select("Term = '" + cboTerm.Text + "'")[0]["TermID"].ToString();; if (Walton_DB.ExecSqlString("INSERT INTO tbl_Grades (Student, Course, Term, Grade) VALUES (" + StudentID.ToString() + "," + CourseID.ToString() + "," + TermID.ToString() + ",'" + cboGrade.Text + "')")) { MessageBox.Show("Student added!"); PopulateStudentDropDown(); RefreshGradeDGV(); } else { MessageBox.Show("Database Error - please try again!"); } }
private void bttnCompleteOrder_Click(object sender, EventArgs e) { if (Walton_DB.ExecSqlString("INSERT INTO Payment (Customer, aDue, aPaid) VALUES ('" + txtCustomerName.Text.ToString() + "','" + txtBoxTotal.Text.ToString() + "','" + txtBoxTotal.Text.ToString() + "')")) { MessageBox.Show("Order Completed!"); } txtBoxBowlQty.Text = ""; txtBoxPreTaxTot.Text = ""; txtBoxRewardsFromOrder.Text = ""; txtBoxSalesTaxTotal.Text = ""; txtBoxShootersQty.Text = ""; txtBoxSmoothieQty.Text = ""; txtBoxTotal.Text = ""; txtCustomerName.Text = ""; txtRewardsTelephone.Text = ""; drpDownBowls.SelectedIndex = -1; drpDownShooters.SelectedIndex = -1; drpDownSmoothies.SelectedIndex = -1; drpDownPhoneNum.SelectedIndex = -1; richTextBoxOrderSummary.Text = ""; }
private void bttnAddCustJP_Click(object sender, EventArgs e) { string Gender = ""; Gender = drpDownJPGender.ToString(); string CustomerName = ""; CustomerName = txtJPCustomerName.Text; string Phone = ""; Phone = txtJPPhoneNumb.Text; string Street = ""; Street = txtJPStreetAddress.Text; string City = ""; City = txtJPCityAddress.Text; string PostalCode = ""; PostalCode = txtJPPostalCode.Text; //if (txtJPDOB.Text == "") //{ // MessageBox.Show("Please Enter Date of Birth MM/DD/YYYY"); // return; //} //if (CustomerName.Trim() == "") //{ // MessageBox.Show("You Must Enter A Name!"); // return; //} //else if (Phone.Trim() == "") //{ // MessageBox.Show("You Must Enter A Number!"); // return; //} //else if (drpDownJPGender.SelectedIndex != -1) //{ // Gender = drpDownJPGender.Text; //} //else if (drpDownJPGender.SelectedIndex == -1) //{ // MessageBox.Show("You Must Select A Gender"); // return; //} //else if (Street.Trim() == "") //{ // MessageBox.Show("You Must Enter Your Street Address"); // return; //} //else if (City.Trim() == "") //{ // MessageBox.Show("You Must Enter A City!"); // return; //} //else if (PostalCode.Trim() == "") //{ // MessageBox.Show("You Must Enter A Postal Code!"); // return; //} if (Walton_DB.ExecSqlString("INSERT INTO jpMembers (name, phone, birthday, gender, street, city, zip ) VALUES ('" + txtJPCustomerName.Text + "','" + txtJPPhoneNumb.Text + "' , '" + txtJPDOB.Text + "', '" + drpDownJPGender.SelectedItem.ToString() + "' , '" + txtJPStreetAddress.Text + "', '" + txtJPCityAddress.Text + "', '" + txtJPPostalCode.Text + "')")) { MessageBox.Show("Juicy Perks Member Added"); return; } }