private void Change_Password_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (id_list_Box.SelectedIndex != 0) { if (connect.State == System.Data.ConnectionState.Open) { if (Password_Box.Text == password_Box2.Text) { if (MessageBox.Show("Are you sure you want to Change your password", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { MessageBox.Show("Canselling"); } else { string command = "update Users set Password='******' where ID='" + StudentsID[id_list_Box.SelectedIndex] + "'"; SqlCommand cmd = new SqlCommand(command, connect); cmd.ExecuteReader(); MessageBox.Show("Password Changed"); this.Hide(); } } else { MessageBox.Show("Sorry please fill same password"); } } } else { MessageBox.Show("please choose User"); } }
private void Refresh_Button_Click(object sender, EventArgs e) { ID_List.Clear(); Name_List.Clear(); this.User_List.Items.Clear(); SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string FindCourses = "select * from Users "; // search on CoursePlacement SqlCommand cmdCourses = new SqlCommand(FindCourses, connect); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); while (dataReadcourse.Read()) { int id = Convert.ToInt32(dataReadcourse["ID"]); // gets string name = (dataReadcourse["FirstName"].ToString()); string last_name = (dataReadcourse["LastName"].ToString()); ID_List.Add(id); Last_Name_List.Add(last_name); Name_List.Add(name);// add course to list of courses to student this.User_List.Items.Add(id + "\t" + name + " " + last_name); } } connect.Close(); }
public void update() { if (cours_List_Box.SelectedIndex != -1 || id_list_Box.SelectedIndex != -1) { string Query2 = "update Professor_Box set Grade = '" + Grade_box.Text + "' WHERE StudentID= '" + Convert.ToInt32(id_list_Box.SelectedItem.ToString()) + "' and CourseID= '" + Convert.ToInt32(cours_List_Box.SelectedItem.ToString()) + "'"; SqlConnection conDatabase = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); SqlCommand cmdDatabase = new SqlCommand(Query2, conDatabase); SqlDataReader myReader; try { conDatabase.Open(); myReader = cmdDatabase.ExecuteReader(); while (myReader.Read()) { } } catch (Exception ex) { MessageBox.Show(ex.Message); } MessageBox.Show("update completed"); } else { MessageBox.Show("please choose student and cours"); } }
private void Delete_User_click_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { if (User_List.SelectedIndex == -1) { MessageBox.Show("Please select an Item first!"); } else { if (MessageBox.Show("Are you sure you want to Delete This user", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { MessageBox.Show("Canselling"); } else { string Delete_From_UsersDepartment = "DELETE from UsersDepartment where ID = '" + ID_List[User_List.SelectedIndex] + "'"; SqlCommand cmd3 = new SqlCommand(Delete_From_UsersDepartment, connect); cmd3.ExecuteNonQuery(); string Delete_From_Messege_Box = "DELETE from Messege_Box where ID = '" + ID_List[User_List.SelectedIndex] + "'"; SqlCommand cmd2 = new SqlCommand(Delete_From_Messege_Box, connect); cmd2.ExecuteNonQuery(); string Delete_From_Users = "DELETE from Users where ID = '" + ID_List[User_List.SelectedIndex] + "'"; SqlCommand cmd = new SqlCommand(Delete_From_Users, connect); cmd.ExecuteNonQuery(); } } } connect.Close(); }
private void StudentDisplayDetails_B_Load(object sender, EventArgs e) { string Messenge1 = null, Messenge2 = null; SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); try { connect.Open(); } catch (Exception ex) { // output the error to see what's going on MessageBox.Show(ex.Message); } if (connect.State == System.Data.ConnectionState.Open) { string command = "select * from Messege_Box where ID = '" + SD.getID().ToString() + "'"; SqlCommand cmd = new SqlCommand(command, connect); SqlDataReader dataRead; dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { Messenge1 = (dataRead["S_Messege"].ToString()); Messenge2 = (dataRead["L_Messege"].ToString()); } if (Messenge1 != "" || Messenge2 != "") { if (Messenge1 != "" && Messenge2 != "") { Massange1_.Show(); Massange2_.Show(); Massange1_.Text = Messenge1; Massange2_.Text = Messenge2; } else if (Messenge1 != "") { Massange1_.Show(); Massange1_.Text = Messenge1; } else if (Messenge2 != "") { Massange1_.Show(); Massange1_.Text = Messenge2; } Clear_Massange.Show(); } else { Massange1_.Show(); } } ID_.Text = SD.getID().ToString(); FirstName_.Text = SD.getFirstName().ToString(); LastName_.Text = SD.getLasttName().ToString(); Year_.Text = SD.getYear().ToString(); Department_.Text = SD.getDepartment().ToString(); Semester_.Text = SD.getSemester().ToString(); }
private void ProfessorDisplaysDetails_B_Load(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); //if (connect.State == System.Data.ConnectionState.Open) //{ //string command = "select * from StaffCourses where ID = '" + SD.getID().ToString() + "'"; }
private void Professor_Student_List_B_Load(object sender, EventArgs e) { int profID = Convert.ToInt32(pc.getID()); string FindStaffCourses = "select * from StaffCourses where ID = '" + profID + "'"; SqlConnection connect = new SqlConnection(Connecting_String); SqlCommand cmdStaffCourses = new SqlCommand(FindStaffCourses, connect); SqlDataReader dataReadcourse; connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { dataReadcourse = cmdStaffCourses.ExecuteReader(); while (dataReadcourse.Read()) { CourseID = dataReadcourse.GetInt32(2); } connect.Close(); SqlConnection connect2 = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect2.Open(); if (connect2.State == System.Data.ConnectionState.Open) { string find_students = "select * from StudentsCourses "; SqlCommand cmdfind = new SqlCommand(find_students, connect2); dataReadcourse = cmdfind.ExecuteReader(); while (dataReadcourse.Read()) { if (Convert.ToInt32(dataReadcourse["IDcourse"]) == CourseID) { StudentsID.Add(Convert.ToInt32(dataReadcourse["ID"])); } } if (StudentsID.Count != 0) { for (int i = 0; i < StudentsID.Count; i++) { listBox1.Items.Add(StudentsID[i]); } } else { MessageBox.Show("nobody registered to this cours please select another"); } } connect2.Close(); } }
private void checkData_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string command = "select * from Users where ID = '" + ID_Box.Text + "'"; SqlCommand cmd = new SqlCommand(command, connect); SqlDataReader dataRead; dataRead = cmd.ExecuteReader(); while (dataRead.Read()) { Last_Name_Box.Text = (dataRead["LastName"].ToString()); First_Name_Box.Text = (dataRead["FirstName"].ToString()); Password_Box.Text = (dataRead["Password"].ToString()); Year_Box.Text = (dataRead["Year"].ToString()); } // find courses assined string FindStudentCourses = "select * from StudentsCourses "; // search on CoursePlacement SqlCommand cmdCourses = new SqlCommand(FindStudentCourses, connect); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); //get courses while (dataReadcourse.Read()) { int id = Convert.ToInt32(dataReadcourse["ID"]); // gets id int idfrombox = Convert.ToInt32(ID_Box.Text); if (idfrombox == id) // check if 'this' is in course { int courseassigned = Convert.ToInt32(dataReadcourse["IDcourse"]); CoursesForStudent.Add(courseassigned); // add course to list of courses to student } } } for (int i = 0; i < CoursesForStudent.Count; i++) { this.listBox1.Items.Add(CoursesForStudent[i]); } connect.Close(); }
private void button3_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex == -1) { MessageBox.Show("Please select an Item first!"); } else { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string find_students = "select * from StudentsCourses "; SqlCommand cmdfind = new SqlCommand(find_students, connect); SqlDataReader dataReadcourse; dataReadcourse = cmdfind.ExecuteReader(); while (dataReadcourse.Read()) { //int cours_id = Convert.ToInt32(dataReadcourse["IDcourse"]); if (Convert.ToInt32(dataReadcourse["IDcourse"]) == CourseID) { StudentsID.Add(Convert.ToInt32(dataReadcourse["ID"])); } } if (StudentsID.Count != 0) { for (int i = 0; i < StudentsID.Count; i++) { string command = "update Messege_Box set L_Messege = '" + textBox1.Text + "' where ID = '" + StudentsID[i] + "'"; SqlCommand cmd = new SqlCommand(command, connect); cmd.ExecuteReader(); } MessageBox.Show("your messege was sent to '" + StudentsID.Count + "' students"); } else { MessageBox.Show("nobody registered to this cours please select another"); } } connect.Close(); } }
private void button2_Click(object sender, EventArgs e) { SqlConnection connect2 = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect2.Open(); if (connect2.State == System.Data.ConnectionState.Open) { string FindCourses = "select * from Courses where IDcourse = '" + Convert.ToInt32(CourseID) + "'"; SqlCommand cmdCourses = new SqlCommand(FindCourses, connect2); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); while (dataReadcourse.Read()) { string data = dataReadcourse.GetString(1); listBox1.Items.Add(data); } } connect2.Close(); }
private void Send_Button_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); string command = ""; if (type == "Secretary") { command = "update Messege_Box set S_Messege = '" + Message_Box.Text + "' where ID = '" + ID_BOX.Text + "'"; } else if (type == "lecture") { command = "update Messege_Box set L_Messege = '" + Message_Box.Text + "' where ID = '" + ID_BOX.Text + "'"; } else { MessageBox.Show("sorry you doont got promissin"); } if (connect.State == System.Data.ConnectionState.Open) { string command1 = "select * from Messege_Box where ID = '" + ID_BOX.Text + "'"; SqlCommand cmd1 = new SqlCommand(command1, connect); SqlDataReader dataRead; dataRead = cmd1.ExecuteReader(); int type = 0; while (dataRead.Read()) { type = Convert.ToInt32(dataRead["Type"]); } if (type == 1 && command != "") { SqlCommand cmd = new SqlCommand(command, connect); cmd.ExecuteReader(); MessageBox.Show("your message was successfully sent"); } else { MessageBox.Show("sorry its wrong student ID"); } } }
private void cours_List_Box_SelectedIndexChanged(object sender, EventArgs e) { id_list_Box.Items.Clear(); SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string FindCourses = "select * from StudentLec_B where courseID = '" + Courses[cours_List_Box.SelectedIndex] + "'"; // search on CoursePlacement SqlCommand cmdCourses = new SqlCommand(FindCourses, connect); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); while (dataReadcourse.Read()) { int studid = Convert.ToInt32(dataReadcourse["ID_Student"]); // gets StudentsID.Add(studid); this.id_list_Box.Items.Add(studid); } } }
public bool Show_Courses() { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string FindCourses = "select * from StaffCourses where ID = '" + PC.getID() + "'"; // search on CoursePlacement SqlCommand cmdCourses = new SqlCommand(FindCourses, connect); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); while (dataReadcourse.Read()) { int id = Convert.ToInt32(dataReadcourse["IDcourse"]); // gets Courses.Add(id); this.cours_List_Box.Items.Add(id); } } connect.Close(); return(true); }
private void load_Courses_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string FindCourses = "select * from Courses "; // search on CoursePlacement SqlCommand cmdCourses = new SqlCommand(FindCourses, connect); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); while (dataReadcourse.Read()) { int id = Convert.ToInt32(dataReadcourse["IDcourse"]); // gets string name = (dataReadcourse["Name"].ToString()); Courses.Add(id); CoursesName.Add(name);// add course to list of courses to student this.cours_List_Box.Items.Add(id + "\t\t" + name); } } connect.Close(); }
private void Change_button_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string command = ""; if (changeStatus == 1) { command = "update Users set FirstName='" + Write_Box.Text + "' where ID='" + ID_List[User_List.SelectedIndex] + "'"; if (MessageBox.Show("Are you sure you want to change " + Name_List[User_List.SelectedIndex] + " to " + Write_Box.Text + "", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { MessageBox.Show("Canselling"); } else { SqlCommand cmd = new SqlCommand(command, connect); cmd.ExecuteReader(); } } else if (changeStatus == 2) { command = "update Users set LastName='" + Write_Box.Text + "' where ID='" + ID_List[User_List.SelectedIndex] + "'"; if (MessageBox.Show("Are you sure you want to change " + Last_Name_List[User_List.SelectedIndex] + " to " + Write_Box.Text + "", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { MessageBox.Show("Canselling"); } else { SqlCommand cmd = new SqlCommand(command, connect); cmd.ExecuteReader(); MessageBox.Show("your last name was changeed"); } } } connect.Close(); }
private void get_students_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { string FindStudentCourses = "select * from StudentsCourses "; // search on CoursePlacement SqlCommand cmdCourses = new SqlCommand(FindStudentCourses, connect); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); while (dataReadcourse.Read()) { if (this.getID.Text == (dataReadcourse["IDcourse"].ToString())) // look for course id { this.StudentRegistedToCourse.Add(dataReadcourse["ID"].ToString()); // if its equal add it to array } } } DataTable CommunicationTable = new DataTable(); CommunicationTable.Columns.Add("Student's ID", typeof(int)); for (int i = 0; i < StudentRegistedToCourse.Count; i++) { CommunicationTable.Rows.Add(StudentRegistedToCourse[i]); } // Notice this assignment: dataGridView1.DataSource = CommunicationTable; connect.Close(); }
private void ProfessorMassMassege_Load(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { int profID = Convert.ToInt32(pc.getID()); string FindStaffCourses = "select * from StaffCourses where ID = '" + profID + "' "; // search on Courses SqlCommand cmdStaffCourses = new SqlCommand(FindStaffCourses, connect); SqlDataReader dataReadcourse; dataReadcourse = cmdStaffCourses.ExecuteReader(); while (dataReadcourse.Read()) { CourseID = dataReadcourse.GetInt32(2); } } connect.Close(); SqlConnection connect2 = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect2.Open(); if (connect2.State == System.Data.ConnectionState.Open) { string FindCourses = "select * from Courses where IDcourse = '" + Convert.ToInt32(CourseID) + "'"; // search on CoursePlacement SqlCommand cmdCourses = new SqlCommand(FindCourses, connect2); // check specific course SqlDataReader dataReadcourse; dataReadcourse = cmdCourses.ExecuteReader(); while (dataReadcourse.Read()) { string data = dataReadcourse.GetString(1); listBox1.Items.Add(data); } } connect2.Close(); }
private void Clear_Massange_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); try { connect.Open(); } catch (Exception ex) { // output the error to see what's going on MessageBox.Show(ex.Message); } if (connect.State == System.Data.ConnectionState.Open) { string command = "update Messege_Box set S_Messege = NULL, L_Messege = NULL where ID='" + SD.getID().ToString() + "'"; SqlCommand cmd = new SqlCommand(command, connect); cmd.ExecuteReader(); MessageBox.Show("Messange deleted"); Massange1_.Text = "no massanges"; Massange2_.Hide(); Clear_Massange.Hide(); } }
private void Login_button_Click(object sender, EventArgs e) { if (ID_Box.TextLength != 9) { MessageBox.Show("ooops Wrong ID please try again"); ID_Box.Text = ""; Password_box.Text = ""; } SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); try { connect.Open(); } catch (Exception ex) { // output the error to see what's going on MessageBox.Show(ex.Message); } if (connect.State == System.Data.ConnectionState.Open) { string command = "select * from Users where ID = '" + ID_Box.Text + "' and Password = '******'"; SqlCommand cmd = new SqlCommand(command, connect); SqlDataReader dataRead; dataRead = cmd.ExecuteReader(); int type = 0; string Messenge1 = "", Messenge2 = ""; while (dataRead.Read()) { type = Convert.ToInt32(dataRead["Type"]); int id = Convert.ToInt32(dataRead["ID"]); string ln = (dataRead["LastName"].ToString()); string fn = (dataRead["FirstName"].ToString()); string depa = (dataRead["Departments"].ToString()); if (type == 1) { // 317509073/ //int id = Convert.ToInt32(dataRead["ID"]); //string ln = (dataRead["LastName"].ToString()); //string fn = (dataRead["FirstName"].ToString()); string year = (dataRead["Year"].ToString()); //string depa = (dataRead["Departments"].ToString()); int semester = Convert.ToInt32(dataRead["Semester"]); S1 = new StudentClass(id, fn, ln, type, year, semester, depa); string readMassange = "select * from Messege_Box where ID = '" + S1.getID().ToString() + "'"; SqlCommand ReadMessageCommand = new SqlCommand(readMassange, connect); SqlDataReader messangeRead; messangeRead = ReadMessageCommand.ExecuteReader(); while (messangeRead.Read()) { Messenge1 = (messangeRead["S_Messege"].ToString()); Messenge2 = (messangeRead["L_Messege"].ToString()); } } if (type == 2) // to create the object Lecturer { int pid = Convert.ToInt32(dataRead["ID"]); string pln = (dataRead["LastName"].ToString()); string pfn = (dataRead["FirstName"].ToString()); string pdepa = (dataRead["Departments"].ToString()); P1 = new ProfessorClass(pid, pln, pfn, type, pdepa); string readMassange = "select * from Messege_Box where ID = '" + P1.getID().ToString() + "'"; SqlCommand ReadMessageCommand = new SqlCommand(readMassange, connect); SqlDataReader messangeRead; messangeRead = ReadMessageCommand.ExecuteReader(); while (messangeRead.Read()) { Messenge1 = (messangeRead["S_Messege"].ToString()); Messenge2 = (messangeRead["L_Messege"].ToString()); } lec = new Lecturer(); this.lec.setLastName(ln); this.lec.setFirstName(fn); this.lec.setID(id); this.lec.setdeparName(depa); } if (type == 3) // to create the object TeachingAssitant { ta = new TeachingAssitant(); this.ta.setLastName(ln); this.ta.setFirstName(fn); this.ta.setID(id); this.ta.setdeparName(depa); } if (type == 4) // to create the object HeadDepartmrent { hd = new HeadDepartment(); this.hd.setLastName(ln); this.hd.setFirstName(fn); this.hd.setID(id); this.hd.setdeparName(depa); } if (type == 5) { sec = new Secretary(); this.sec.setLastName(ln); this.sec.setFirstName(fn); this.sec.setID(id); this.sec.setdeparName(depa); } if (type == 7) { sec = new Secretary(); this.sec.setLastName(ln); this.sec.setFirstName(fn); this.sec.setID(id); this.sec.setdeparName(depa); } } if (save_id.Checked) { Properties.Settings.Default.IDREMEMBER = ID_Box.Text.ToString(); Properties.Settings.Default.Save(); } if (!save_id.Checked) { Properties.Settings.Default.IDREMEMBER = ""; Properties.Settings.Default.Save(); } if (type == 1) { MessageBox.Show("wellcome " + S1.getFirstName() + " to student menu your ID " + S1.getID() + ""); this.Hide(); Student_Menu_B student = new Student_Menu_B(); if (Messenge1 != "" || Messenge2 != "") { student.Massange = true; } connect.Close(); student.passValue = S1; dataRead.Close(); student.Show(); } else if (type == 2) { MessageBox.Show("wellcome " + P1.getFirstName() + " to Lecturer Menu your ID " + P1.getID() + ""); this.Hide(); //Proffesor_Menu_B professor = new Proffesor_Menu_B(); A_LecturerMenu lecMenu = new A_LecturerMenu(lec); lecMenu.passValue = P1; connect.Close(); dataRead.Close(); lecMenu.ShowDialog(); /* * this.Hide(); * A_LecturerMenu lecMenu = new A_LecturerMenu(lec); * lecMenu.ShowDialog(); */ //MessageBox.Show("Connceted Professor"); //this.Hide(); //Proffesor_Menu_B professor = new Proffesor_Menu_B(); //professor.Show(); // קבוצה B שימו לב !!!!!!!! // אתם צריכים לשנות את הסוג של פרופסור אצלכם ל-2 ולשנות את זה בכל מקום! גם בקוד וגם בדטהבייס // ואז לשלוח אותו לפורם הבא: A_lecturerMenu אחרי שתאחדו את הדרישות שלכם בפורם הזה } else if (type == 3) { this.Hide(); MessageBox.Show("wellcome " + ta.getFirstName() + " to Teaching Assistant Menu your ID " + ta.getID() + ""); A_TeachingAssistant taMenu = new A_TeachingAssistant(ta); taMenu.passValue = ta; connect.Close(); dataRead.Close(); taMenu.ShowDialog(); //change branch B --- type of proffesor to type 2 //MessageBox.Show("Connceted Professor"); //this.Hide(); //Proffesor_Menu_B professor = new Proffesor_Menu_B(); //professor.Show(); } else if (type == 4) { this.Hide(); //HeadDepartment hd = new HeadDepartment(); A_DepartmentHead hdMenu = new A_DepartmentHead(); hdMenu.passValue = hd; connect.Close(); dataRead.Close(); hdMenu.ShowDialog(); } else if (type == 5) { MessageBox.Show("wellcome " + sec.getFirstName() + " to Secretary Menu your ID " + sec.getID() + ""); this.Hide(); Secretary_Menu_B secretary = new Secretary_Menu_B(); secretary.passsec = sec; secretary.Show(); } else if (type == 6) { MessageBox.Show("Connceted TECH"); this.Hide(); support__manager supp = new support__manager(); supp.Show(); } else if (type == 7) { this.Hide(); MessageBox.Show("wellcome " + sec.getFirstName() + " to Secretary Menu your ID " + sec.getID() + ""); A_menuForSecretary secMenu = new A_menuForSecretary(); // secMenu.passValue = sec; //connect.Close(); //dataRead.Close(); secMenu.Show(); } else { MessageBox.Show("Wrong password"); Password_box.Text = ""; } } }
private void Add_User_click_Click(object sender, EventArgs e) { SqlConnection connect = new SqlConnection(Return_Connection_String_Class.Return_Connection_String()); connect.Open(); if (connect.State == System.Data.ConnectionState.Open) { int type = 0, semester = 0, Idepartment = 7000, max = 0; char year = 'a'; string department = ""; string command, command2, command3; string curItem = Type_list.SelectedItem.ToString(); if (curItem == "Student") { type = 1; DepartmentList.Show(); if (DepartmentList.SelectedItem.ToString() == "Software Engineering") { department = "Software Engineering"; Idepartment = 7000; } else if (DepartmentList.SelectedItem.ToString() == "Electrical Engineering") { department = "Electrical Engineering"; Idepartment = 7001; } else if (DepartmentList.SelectedItem.ToString() == "Structural Engineering") { department = "Structural Engineering"; Idepartment = 7002; } else if (DepartmentList.SelectedItem.ToString() == "Mechanical Engineering") { department = "Mechanical Engineering"; Idepartment = 7003; } else if (DepartmentList.SelectedItem.ToString() == "Physics") { department = "Physics"; Idepartment = 7006; } else if (DepartmentList.SelectedItem.ToString() == "Mathematics") { department = "Mathematics"; Idepartment = 7004; } else if (DepartmentList.SelectedItem.ToString() == "Chemistry") { department = "Chemistry"; Idepartment = 7005; } else { MessageBox.Show("Please Choose Department"); } Year_list.Show(); if (Year_list.SelectedItem.ToString() == "Year 1") { year = 'a'; } else if (Year_list.SelectedItem.ToString() == "Year 2") { year = 'b'; } else if (Year_list.SelectedItem.ToString() == "Year 3") { year = 'c'; } else if (Year_list.SelectedItem.ToString() == "Year 4") { year = 'd'; } else { MessageBox.Show("Please Choose Year"); } SemesterBox.Show(); if (SemesterBox.SelectedItem.ToString() == "Semester a") { semester = 1; } else if (SemesterBox.SelectedItem.ToString() == "Semester b") { semester = 2; } else if (SemesterBox.SelectedItem.ToString() == "Summer") { semester = 3; } else { MessageBox.Show("Please Choose Semester"); } /*insert users (student)*/ command = "insert into Users(ID,FirstName,LastName,Type,Password,Year,Departments,Semester)values('" + ID_Box.Text.ToString() + "','" + First_Name_Box.Text.ToString() + "','" + Last_Name_Box.Text.ToString() + "','" + type + "','" + Password_Box.Text.ToString() + "','" + year + "','" + department + "','" + semester + "')"; } else {//1=student //2=a metargel //3=professor //4=a secretary //5 = secretary //6= Tech if (curItem == "Secretary") { type = 5; } if (curItem == "Tech") { type = 6; } /*insert users (secretary and tech)*/ command = "insert into Users(ID,FirstName,LastName,Type,Password)values('" + ID_Box.Text.ToString() + "','" + First_Name_Box.Text.ToString() + "','" + Last_Name_Box.Text.ToString() + "','" + type + "','" + Password_Box.Text.ToString() + "')"; } if (ID_Box.TextLength != 9) { MessageBox.Show("Wrong ID please Fill Correct Data"); ID_Box.Text = ""; } else { SqlCommand readMaxNum = new SqlCommand("SELECT MAX(Num) as Max_NUM FROM UsersDepartment", connect); readMaxNum.CommandType = CommandType.Text; max = Int32.Parse(readMaxNum.ExecuteScalar().ToString()); /*insert userDepartment*/ command2 = "insert into UsersDepartment(Num,ID,IDdepartment)values('" + (max + 1) + "','" + ID_Box.Text.ToString() + "','" + Idepartment + "')"; SqlCommand readMaxseriannum = new SqlCommand("SELECT MAX(SerialNum) as MAX_NUM FROM Messege_Box", connect); readMaxseriannum.CommandType = CommandType.Text; max = Int32.Parse(readMaxNum.ExecuteScalar().ToString()); /*insert Messege_Box*/ command3 = "insert into Messege_Box(SerialNum,ID,Type)values('" + (max + 1) + "','" + ID_Box.Text.ToString() + "','" + type + "')"; SqlCommand cmd = new SqlCommand(command, connect); cmd.ExecuteNonQuery(); SqlCommand cmd1 = new SqlCommand(command2, connect); cmd1.ExecuteNonQuery(); SqlCommand cmd2 = new SqlCommand(command3, connect); cmd2.ExecuteNonQuery(); MessageBox.Show("Create new user made Successfuly"); } } }