public void facebook() { Application.EnableVisualStyles(); g = new GetTheMail(); string mail = g.getMail(); if (dataBaseOperations.facebookUserExist(mail, "instructor")) { //In perception i thing that its importent to pass //user object for the next managing form //plese do it in all other form ulong i = dataBaseOperations.getIdByMail(mail); //here i create new inst obj instructor inst = new instructor(dataBaseOperations.getIdByMail(mail)); //and then i pass it to the next form //i'll catch it in the next form constractor teachingStaffMenu instrfMen = new teachingStaffMenu(inst); this.Hide(); instrfMen.ShowDialog(); } else { MessageBox.Show("the user not exist"); } g.logout(); }
public teachingStaffMenu(user someUser) { InitializeComponent(); labelNoSched.Hide(); //learn more about downcasting here http://stackoverflow.com/questions/1524197/downcast-and-upcast if (someUser is professor) { //make reperance to the object we get this.prof = (professor)someUser; theUserWeGot = userType.Professor; } if (someUser is instructor) { //make reperance to the object we get this.inst = (instructor)someUser; theUserWeGot = userType.Instructor; } //change this form size //see also: https://msdn.microsoft.com/en-us/library/ms229606(v=vs.110).aspx this.Size = new System.Drawing.Size(1000, 550); //set position in the center; //see also: https://msdn.microsoft.com/en-us/library/system.windows.forms.form.startposition(v=vs.110).aspx this.StartPosition = FormStartPosition.CenterScreen; //set the item in the combo boxes setComboBoxes(); set_account_Management(); //hide constraints panel; panel1.Hide(); //build schedule if the schedule is published by the secretary if (new dataBaseOperations().getPublishedSched(someUser.getid())) { build_schedule(someUser); } else { labelNoSched.Show(); } watch_your_constraints(null, null); }
//build schedule to professor or instructor private void build_schedule(user someUser) { if (someUser is professor) { //make reperance to the object we get this.prof = (professor)someUser; courses_List = this.prof.getCoursesList(); } if (someUser is instructor) { //make reperance to the object we get this.inst = (instructor)someUser; courses_List = this.inst.getCoursesList(); } //build DataTable DataTable tempTable = new DataTable(); tempTable.Columns.Add(" ", typeof(string)); tempTable.Columns.Add("Sunday", typeof(string)); tempTable.Columns.Add("Monday", typeof(string)); tempTable.Columns.Add("Tuesday", typeof(string)); tempTable.Columns.Add("Wednesday", typeof(string)); tempTable.Columns.Add("Thursday", typeof(string)); tempTable.Columns.Add("Friday", typeof(string)); tempTable.Rows.Add("07:00", typeof(string)); tempTable.Rows.Add("08:00", typeof(string)); tempTable.Rows.Add("09:00", typeof(string)); tempTable.Rows.Add("10:00", typeof(string)); tempTable.Rows.Add("11:00", typeof(string)); tempTable.Rows.Add("12:00", typeof(string)); tempTable.Rows.Add("13:00", typeof(string)); tempTable.Rows.Add("14:00", typeof(string)); tempTable.Rows.Add("15:00", typeof(string)); tempTable.Rows.Add("16:00", typeof(string)); tempTable.Rows.Add("17:00", typeof(string)); tempTable.Rows.Add("18:00", typeof(string)); tempTable.Rows.Add("19:00", typeof(string)); tempTable.Rows.Add("20:00", typeof(string)); tempTable.Rows.Add("21:00", typeof(string)); string day = ""; string start = ""; string end = ""; string room = ""; //enter lectures to DataTable for (int i = 0; i < courses_List.Count; i++) { //get the attributes of the lecture from DB day = dataOp.getAttrByName(courses_List[i], 5); start = dataOp.getAttrByName(courses_List[i], 6); end = dataOp.getAttrByName(courses_List[i], 7); room = dataOp.getAttrByName(courses_List[i], 4); //convert to location in DataTable int location_x = publicChecksAndOperations.convDayToInt(day); int location_y_s = publicChecksAndOperations.hourConvertFromStringToInt(start); int location_y_e = publicChecksAndOperations.hourConvertFromStringToInt(end); string name = courses_List[i]; if ((tempTable.Rows[location_y_s][location_x] != null && !tempTable.Rows[location_y_s][location_x].Equals("System.String") && !string.IsNullOrEmpty(tempTable.Rows[location_y_s][location_x].ToString()))) { tempTable.Rows[location_y_s][location_x] = "Collision courses!Contact the Secretary"; } else { tempTable.Rows[location_y_s][location_x] = courses_List[i] + " ( " + room + " )"; } for (int j = location_y_s + 1; j <= (location_y_e); j++) { if ((tempTable.Rows[j][location_x] != null && !tempTable.Rows[j][location_x].Equals("System.String") && !string.IsNullOrEmpty(tempTable.Rows[j][location_x].ToString()))) { tempTable.Rows[j][location_x] = "Collision courses!Contact the Secretary"; } else { tempTable.Rows[j][location_x] = name + " ( " + room + " )"; } } } //define empty value in cells which dont have lecture for (int i = 0; i < 15; i++) { for (int j = 1; j < 6; j++) { if (tempTable.Rows[i][j] == null || tempTable.Rows[i][j].Equals("System.String") || string.IsNullOrEmpty(tempTable.Rows[i][j].ToString())) { tempTable.Rows[i][j] = " "; } } } dataGridView2.DataSource = tempTable; dataGridView2.RowHeadersVisible = false; }