void PrintData(List <Recall> listRecalls) { Employee employee; string fio = ""; bookDataGridView.Rows.Clear(); foreach (Recall recall in listRecalls) { if (recall.IndividualNumberFK != null) { employee = daoEmployee.GetEmployeeOnId(Data.context, (int)recall.IndividualNumberFK); fio = employee.Surname + " " + employee.Name + " " + employee.Patronymic; } if (recall.Answers.Count != 0) { foreach (Answer answer in recall.Answers) { bookDataGridView.Rows.Add(recall.TopicRecall, recall.DateTime.Date.ToString("dd'-'MM'-'yyyy"), recall.Comment, recall.SubjectRecall, recall.TypeRecall, answer.AnswerOnRecall, recall.Room, fio); } } else { bookDataGridView.Rows.Add(recall.TopicRecall, recall.DateTime.Date.ToString("dd'-'MM'-'yyyy"), recall.Comment, recall.SubjectRecall, recall.TypeRecall, recall.Room, fio); } } }
private void recallUser_Click(object sender, EventArgs e) { string surname = surnameTextbox.Text; string name = nameTextbox.Text; string patronymic = patronymicTextbox.Text; string topicRecall = topicTextbox.Text; string commentReccal = commentTextbox.Text; string email = ""; string typeRecall = ""; string subjectRecall = ""; Room room = null; Employee employee = null; if (appealRadioButton.Checked == true) { typeRecall = "жалоба"; } else if (sentenceRadioButton.Checked == true) { typeRecall = "предложение"; } else if (thanksRadioButton.Checked == true) { typeRecall = "благодарность"; } if (hostelRadioButton.Checked == true) { subjectRecall = "гостиница"; } else if (staffRadioButton.Checked == true) { staffComboBox.Enabled = true; nameStaffTextBox.Visible = true; subjectRecall = "персонал"; employee = daoEmployee.GetEmployeeOnId(Data.context, (int)staffComboBox.SelectedValue); } else if (roomRadioButton.Checked == true) { roomComboBox.Enabled = true; subjectRecall = "комната"; DaoRoom daoRoom = new DaoRoom(); room = daoRoom.GetRoomOnId(Data.context, (int)roomComboBox.SelectedValue); } if (emailRadioYes.Checked == true) { email = emailTextbox.Text; } string s = DateTime.Now.ToString("u"); DateTime d = Convert.ToDateTime(DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss'.'fff")); if (name != "") { HotelUser hotelUser = Data.context.HotelUsers.Add(new HotelUser { Surname = surname, Name = name, Patronymic = patronymic, Email = email }); Recall recall = Data.context.Recalls.Add(new Recall { Comment = commentReccal, HotelUser = hotelUser, TopicRecall = topicRecall, TypeRecall = typeRecall, SubjectRecall = subjectRecall, Employee = employee, Room = room, DateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy'-'MM'-'dd HH':'mm':'ss'.'fff")) }); Data.context.SaveChanges(); appealRadioButton.Checked = true; hostelRadioButton.Checked = true; surnameTextbox.Text = ""; nameTextbox.Text = ""; patronymicTextbox.Text = ""; topicTextbox.Text = ""; commentTextbox.Text = ""; emailTextbox.Text = ""; emailRadioNo.Checked = true; staffComboBox.Enabled = false; emailTextbox.Enabled = false; } else { MessageBox.Show("Заполните обязательное поле Имя"); } }