private void Button_Click(object sender, RoutedEventArgs e) { string s = ""; if (studentGender.SelectedIndex == 0) { s = "f"; } if (studentGender.SelectedIndex == 1) { s = "m"; } /*try * {*/ Common_Functions.fake_AddStudent(globalConnection, studentID.Text.ToString()); Common_Functions.fake_addOtherLiving(globalConnection, studentID.Text.ToString()); room_Selection rs = new room_Selection(globalConnection, s, studentID.Text.ToString()); rs.parentLabel = this.studentRoom; rs.ShowDialog(); rSelect.Visibility = Visibility.Hidden; studentRoom.Visibility = Visibility.Visible; RoomClear.Visibility = System.Windows.Visibility.Visible; /*} * catch * { * MessageBox.Show("Проживающий с таким номером уже есть"); * } */ }
private void studentType_Checked(object sender, RoutedEventArgs e) // при нажатии на checkBox { if ((bool)studentType.IsChecked) { studentID.IsEnabled = false; studentFaculty.IsEnabled = false; studentCourse.IsEnabled = false; Form.IsEnabled = false; studentID.Text = Common_Functions.getNewID(globalConnection, otherLiving); otherLivingID = studentID.Text; otherLiving = 1; infoLabel.Visibility = Visibility.Visible; Info.Visibility = Visibility.Visible; } else { studentID.IsEnabled = true; studentFaculty.IsEnabled = true; studentCourse.IsEnabled = true; Form.IsEnabled = true; //otherLivingID = "0"; studentID.Text = ""; infoLabel.Visibility = Visibility.Hidden; Info.Visibility = Visibility.Hidden; } }
private void goBack_Click(object sender, RoutedEventArgs e) { MySqlCommand clear_Fake = new MySqlCommand(); clear_Fake.Connection = globalConnection; clear_Fake.CommandText = "DELETE FROM Students WHERE Name = 'FAKE';"; clear_Fake.ExecuteNonQuery(); MySqlCommand clear_FakeOT = new MySqlCommand(); clear_FakeOT.Connection = globalConnection; clear_FakeOT.CommandText = "DELETE FROM OtherLiving WHERE Name = 'FAKE';"; clear_FakeOT.ExecuteNonQuery(); if (studentRoom.Content.ToString() != "") { Common_Functions.delete_FromRoom(globalConnection, studentRoom.Content.ToString()); } if (otherLiving == 1) { MySqlCommand deleteotherID = new MySqlCommand(); deleteotherID.Connection = globalConnection; deleteotherID.CommandText = "DELETE FROM OtherLivingID WHERE Id = '" + otherLivingID + "';"; deleteotherID.ExecuteNonQuery(); } d(); }
private void actionButton_Click(object sender, RoutedEventArgs e) { switch (type) { case "S": Common_Functions.evictionST(globalConnection, id, decree.Text, (DateTime)date.SelectedDate); break; case "SE": Common_Functions.evictionSTE(globalConnection, id, decree.Text, (DateTime)date.SelectedDate); break; case "O": Common_Functions.evictionOL(globalConnection, id, decree.Text, (DateTime)date.SelectedDate); break; case "OE": Common_Functions.evictionOLE(globalConnection, id, decree.Text, (DateTime)date.SelectedDate); break; } /*if (type == "S") * { * Common_Functions.evictionST(globalConnection, id, decree.Text, (DateTime)date.SelectedDate); * } * else * { * Common_Functions.evictionOL(globalConnection, id, decree.Text, (DateTime)date.SelectedDate); * }*/ page.searchButton_Click(sender, e); window.Close(); this.Close(); }
private void change_Click(object sender, RoutedEventArgs e) { try { if (date.SelectedDate > stayLimit.SelectedDate) { MessageBox.Show("Срок проживания заканчивается раньше конца оплаченного периода проживания"); date.BorderBrush = new SolidColorBrush(Colors.Red); } else { if (id.IsEnabled == true) { Common_Functions.update_StudentData(globalConnection, studentID, name.Text, surname.Text, patronymic.Text, id.Text, faculty.SelectedValue.ToString(), course.Text, phone.Text, decree.Text, form.SelectedValue.ToString(), citizenship.SelectedValue.ToString(), (DateTime)date.SelectedDate, (DateTime)decreeDate.SelectedDate, (DateTime)stayLimit.SelectedDate); } else { Common_Functions.update_OtherLivingData(globalConnection, id.Text, name.Text, surname.Text, patronymic.Text, (DateTime)date.SelectedDate, decree.Text, (DateTime)decreeDate.SelectedDate, (DateTime)stayLimit.SelectedDate, citizenship.SelectedValue.ToString(), info.Text, phone.Text); } page.searchButton_Click(sender, e); this.Close(); } } catch { MessageBox.Show("Невозможно изменить информацию о проживающем"); } }
private void room_Info_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var selRoom = room_Info.SelectedItem; string gender = Sex; string _selRoom = ((RoomItem)selRoom).room_Numb; string _fplaces = ((RoomItem)selRoom).Fplaces_Con; if (SetFamily.IsChecked == true) { gender = "c"; } if (Convert.ToInt32(_fplaces) != 0) { Common_Functions.update_RoomInfo(globalConnection, _selRoom, gender); Common_Functions.update_StudentRoomInfo(globalConnection, _selRoom, studentID); Common_Functions.update_OtherLivingRoomInfo(globalConnection, _selRoom, studentID); //room_Info.ItemsSource = RoomItem.getItems(globalConnection, Sex); parentLabel.Content = _selRoom; this.Close(); } else { MessageBox.Show("В выбранной комнате нет свободных мест, выберете другую комнату"); } }
private void RoomClear_Click(object sender, RoutedEventArgs e) { rSelect.Visibility = Visibility.Visible; studentRoom.Visibility = System.Windows.Visibility.Hidden; RoomClear.Visibility = System.Windows.Visibility.Hidden; Common_Functions.delete_FromRoom(globalConnection, studentRoom.Content.ToString()); }
private void Page_Unloaded(object sender, RoutedEventArgs e) { if (studentRoom.Content != "") { Common_Functions.delete_FromRoom(globalConnection, studentRoom.Content.ToString()); deleteFakeOL(); deleteFakeST(); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { allST = Common_Functions.getAllST(globalConnection); allOL = Common_Functions.getAllOL(globalConnection); int stCountF = 0; int olCount = 0; int nonPayST = 0; int men = 0; int women = 0; int forein = 0; foreach (livingST st in allST) { if (st.evictedTillDate < DateTime.Now) { stCountF += 1; } if (st.date < DateTime.Today) { nonPayST += 1; } if (st.gender == "Мужской") { men += 1; } else if (st.gender == "Женский") { women += 1; } if (st.citizenship != "Российская Федерация") { forein += 1; } } foreach (livingOL ol in allOL) { if (ol.evictedTillDate < DateTime.Now) { olCount += 1; } } nonSTcount.Content = olCount.ToString(); stCount.Content = stCountF.ToString(); commonCount.Content = (olCount + stCountF).ToString(); stCount1.Content = stCountF.ToString(); nonPayedST.Content = nonPayST.ToString(); menCountST.Content = men.ToString(); womenCountST.Content = women.ToString(); forenSTCount.Content = forein.ToString(); }
private void SetFamily_Click(object sender, RoutedEventArgs e) { if (SetFamily.IsChecked == true) { room_Info.ItemsSource = Common_Functions.select_RoomForFamily(globalConnection); } else { room_Info.ItemsSource = RoomItem.getItems(globalConnection, Sex); } }
private void roomChange_Click(object sender, RoutedEventArgs e) { selectRoom.Visibility = Visibility.Visible; roomChange.Visibility = Visibility.Hidden; roomNumber.Visibility = Visibility.Hidden; change.IsEnabled = false; Close.IsEnabled = false; evictionBT.IsEnabled = false; evictTill.IsEnabled = false; Common_Functions.delete_FromRoom(globalConnection, roomNumber.Content.ToString()); }
private void addStudent_Click(object sender, RoutedEventArgs e) { DateTime setDate; if (!(bool)studentType.IsChecked) { if (!contentCheckfull()) { if (studentDate.SelectedDate == null) { setDate = DateTime.Now.AddDays(-1); } else { setDate = (DateTime)studentDate.SelectedDate; } Common_Functions.refresh_StudentData(globalConnection, studentName.Text, studentSurname.Text, studentPatronymic.Text, studentID.Text, studentGender.SelectedValue.ToString(), studentFaculty.SelectedValue.ToString(), studentCourse.Text, studentPhone.Text, Decree.Text, Form.SelectedValue.ToString(), studentCitizenship.SelectedValue.ToString(), setDate, (DateTime)Decree_Date.SelectedDate, (DateTime)studentStayLimit.SelectedDate); deleteFakeOL(); clearAllContent(); rSelect.Visibility = Visibility.Hidden; infoLabel.Visibility = Visibility.Hidden; Info.Visibility = Visibility.Hidden; } else { ; } } else { if (!contentCheck()) { if (studentDate.SelectedDate == null) { setDate = DateTime.Now.AddDays(-1); } else { setDate = (DateTime)studentDate.SelectedDate; } Common_Functions.refresh_OtherLivingData(globalConnection, studentID.Text, studentName.Text, studentSurname.Text, studentPatronymic.Text, studentGender.SelectedValue.ToString(), setDate, Decree.Text, (DateTime)Decree_Date.SelectedDate, (DateTime)studentStayLimit.SelectedDate, studentCitizenship.SelectedValue.ToString(), Info.Text, studentPhone.Text); deleteFakeST(); clearAllContent(); rSelect.Visibility = Visibility.Hidden; infoLabel.Visibility = Visibility.Hidden; Info.Visibility = Visibility.Hidden; } } otherLiving = 0; }
private void Accept_Click(object sender, RoutedEventArgs e) { var selRoom = room_Info.SelectedItem; string gender = Sex; string _selRoom = ((RoomItem)selRoom).room_Numb; if (SetFamily.IsChecked == true) { gender = "c"; } Common_Functions.update_RoomInfo(globalConnection, _selRoom, gender); Common_Functions.update_StudentRoomInfo(globalConnection, _selRoom, studentID); //room_Info.ItemsSource = RoomItem.getItems(globalConnection, Sex); parentLabel.Content = _selRoom; this.Close(); }
private void evict_Click(object sender, RoutedEventArgs e) { MySqlCommand evict = new MySqlCommand(); evict.Connection = globalConnection; if (type == "S") { evict.CommandText = "UPDATE Students SET evicted = 1, EvictedTill = '" + ((DateTime)evictDate.SelectedDate).ToString("yyyy-MM-dd H:mm:ss") + "', Room = null WHERE Student_ID = '" + globalWindow.id.Text + "';"; } else { evict.CommandText = "UPDATE OtherLiving SET evicted = 1, EvictedTill = '" + ((DateTime)evictDate.SelectedDate).ToString("yyyy-MM-dd H:mm:ss") + "', Room = null WHERE ID = '" + globalWindow.id.Text + "';"; } evict.ExecuteNonQuery(); Common_Functions.delete_FromRoom(globalConnection, globalWindow.roomNumber.Content.ToString()); globalWindow.Close(); this.Close(); }
private void initionalTest() { Action action = () => { bool f = true; bool f2 = true; MySqlCommand settings = new MySqlCommand(); settings.Connection = globalConnection; settings.CommandText = "SELECT * FROM Settings"; settings.ExecuteNonQuery(); string outTimeMessage = ""; string sDateCheck = ""; string aDateCheck = ""; MySqlDataAdapter sDA = new MySqlDataAdapter(settings); DataTable sDT = new DataTable(); sDA.Fill(sDT); var mySData = sDT.Select(); outTimeMessage = mySData[0].ItemArray[3].ToString(); sDateCheck = mySData[0].ItemArray[4].ToString(); aDateCheck = mySData[0].ItemArray[5].ToString(); if (mySData[0].ItemArray[6].ToString() == "Не проверять") { f = false; } else { f = true; if (mySData[0].ItemArray[6].ToString() != "При каждом запуске") { DateTime checkDate = DateTime.Now; switch (mySData[0].ItemArray[6].ToString()) { case "Раз в неделю": checkDate = DateTime.Now.AddDays(-7); break; case "Раз в месяц": checkDate = DateTime.Now.AddMonths(-1); break; default: break; } if (checkDate != DateTime.Now) { DateTime lastCheck = (DateTime)mySData[0].ItemArray[7]; if (lastCheck <= checkDate) { f2 = true; } else { f2 = false; } } } else { f2 = true; } } if (f == true && f2 == true) { string message1 = "Есть проживающие, не оплатившие проживание"; string message2 = "Есть проживающие, у которых закончился период проживания"; string message3 = ""; string message4 = ""; bool fl1 = false; bool fl2 = false; string today = DateTime.Now.ToString("yyyy-MM-dd H:mm:ss"); archiveDelete(outTimeMessage); message3 = dateCheck(aDateCheck, sDateCheck); MySqlCommand search = new MySqlCommand(); search.Connection = globalConnection; search.CommandText = "SELECT * FROM Students;"; search.ExecuteNonQuery(); MySqlDataAdapter da = new MySqlDataAdapter(search); DataTable dt = new DataTable(); da.Fill(dt); var myData = dt.Select(); for (int i = 0; i < myData.Length; i++) { if (myData[i].ItemArray[1].ToString() == "FAKE") { Common_Functions.delete_FromRoom(globalConnection, myData[i].ItemArray[7].ToString()); MySqlCommand deleteFake = new MySqlCommand(); deleteFake.Connection = globalConnection; deleteFake.CommandText = "DELETE FROM Students WHERE Name = 'FAKE';"; deleteFake.ExecuteNonQuery(); deleteFake.CommandText = "DELETE FROM OtherLiving WHERE Name = 'FAKE';"; deleteFake.ExecuteNonQuery(); continue; } if (Convert.ToDateTime(myData[i].ItemArray[8]) < Convert.ToDateTime(today)) { fl1 = true; } if (Convert.ToDateTime(myData[i].ItemArray[13]) < Convert.ToDateTime(today)) { fl2 = true; } if (Convert.ToBoolean(myData[i].ItemArray[15]) == true) { if (Convert.ToDateTime(myData[i].ItemArray[16]) <= Convert.ToDateTime(today)) { message4 = "Есть временно выселенные проживающие ожидающие заселения"; } } } if (fl1 == false || fl2 == false || message4 == "") { search.CommandText = "SELECT * FROM OtherLiving;"; search.ExecuteNonQuery(); MySqlDataAdapter da1 = new MySqlDataAdapter(search); DataTable dt1 = new DataTable(); da1.Fill(dt1); var myData1 = dt1.Select(); for (int i = 0; i < myData1.Length; i++) { if (Convert.ToDateTime(myData1[i].ItemArray[6]) < Convert.ToDateTime(today)) { fl1 = true; } if (Convert.ToDateTime(myData1[i].ItemArray[9]) < Convert.ToDateTime(today)) { fl2 = true; } if (Convert.ToBoolean(myData1[i].ItemArray[13]) == true) { if (Convert.ToDateTime(myData1[i].ItemArray[14]) <= Convert.ToDateTime(today)) { message4 = "Есть временно выселенные проживающие ожидающие заселения"; } } if (fl1 == true && fl2 == true && message4 != "") { break; } } } //message3 = evictedCheck(); if (fl1 == true && fl2 == false && message3 == "" && message4 == "") { testLabel1.Content = message1; } if (fl1 == true && fl2 == false && message3 == "" && message4 != "") { testLabel1.Content = message1; testLabel2.Content = message4; } if (fl1 == false && fl2 == false && message3 != "" && message4 == "") { testLabel1.Content = message3; } if (fl1 == false && fl2 == false && message3 != "" && message4 != "") { testLabel1.Content = message3; testLabel2.Content = message4; } if (fl1 == false && fl2 == true && message3 != "" && message4 == "") { testLabel1.Content = message2; testLabel2.Content = message3; } if (fl1 == false && fl2 == true && message3 != "" && message4 != "") { testLabel1.Content = message2; testLabel2.Content = message3; testLabel3.Content = message4; } if (fl1 == true && fl2 == false && message3 != "" && message4 == "") { testLabel1.Content = message1; testLabel2.Content = message3; } if (fl1 == true && fl2 == false && message3 != "" && message4 != "") { testLabel1.Content = message1; testLabel2.Content = message3; testLabel3.Content = message4; } if (fl1 == true && fl2 == true && message3 == "" && message4 == "") { testLabel1.Content = message1; testLabel2.Content = message2; } if (fl1 == true && fl2 == true && message3 == "" && message4 != "") { testLabel1.Content = message1; testLabel2.Content = message2; testLabel3.Content = message4; } if (fl1 == true && fl2 == true && message3 != "" && message4 == "") { testLabel1.Content = message1; testLabel2.Content = message2; testLabel3.Content = message3; } if (fl1 == true && fl2 == true && message3 != "" && message4 != "") { testLabel1.Content = message1; testLabel2.Content = message2; testLabel3.Content = message3; testLabel4.Content = message4; } if (fl1 == false && fl2 == true && message3 == "" && message4 == "") { testLabel1.Content = message2; } if (fl1 == false && fl2 == true && message3 == "" && message4 != "") { testLabel1.Content = message2; testLabel2.Content = message4; } if (fl1 == false && fl2 == false && message3 == "" && message4 != "") { testLabel1.Content = message4; } if (fl1 == false && fl2 == false && message3 == "" && message4 == "") { testLabel1.Content = "Сообщений нет"; } DateTime todayCheckDate = DateTime.Now; string cDate = todayCheckDate.ToString("yyyy-MM-dd H:mm:ss"); MySqlCommand insertDate = new MySqlCommand(); insertDate.Connection = globalConnection; insertDate.CommandText = "UPDATE Settings SET LastCheckDate = '" + cDate + "' WHERE ID = 1;"; insertDate.ExecuteNonQuery(); } }; this.Dispatcher.Invoke(action); }