private void deleteButton_Click(object sender, EventArgs e) { DaoEmployee daoEmployee = new DaoEmployee(); DaoPosition daoPosition = new DaoPosition(); DaoRoom daoRoom = new DaoRoom(); DaoRecall daoRecall = new DaoRecall(); DaoHotelUser daoHotelUser = new DaoHotelUser(); DaoAnswer daoAnswer = new DaoAnswer(); if (directorTabControl.SelectedIndex == 0) { daoPosition.DeletePosition(Data.context, Convert.ToInt16(positionDataGridView.Rows[positionDataGridView.CurrentCell.RowIndex].Cells[0].Value.ToString())); } this.positionTableAdapter.Fill(this.hotelDataSet1.Position); if (directorTabControl.SelectedIndex == 1) { daoRoom.DeleteRoom(Data.context, Convert.ToInt16(roomDataGridView.Rows[roomDataGridView.CurrentCell.RowIndex].Cells[0].Value.ToString())); } this.roomTableAdapter.Fill(this.hotelDataSet1.Room); if (directorTabControl.SelectedIndex == 2) { daoEmployee.DeleteEmployee(Data.context, Convert.ToInt16(employeeDataGridView.Rows[employeeDataGridView.CurrentCell.RowIndex].Cells[0].Value.ToString())); } work.PrintEmployee(employeeDataGridView); if (directorTabControl.SelectedIndex == 3) { daoHotelUser.DeleteRoom(Data.context, Convert.ToInt16(hotelUserDataGridView.Rows[hotelUserDataGridView.CurrentCell.RowIndex].Cells[0].Value.ToString())); } this.hotelUserTableAdapter.Fill(this.hotelDataSet1.HotelUser); if (directorTabControl.SelectedIndex == 4) { daoRecall.DeleteRecall(Data.context, Convert.ToInt16(recallDataGridView.Rows[recallDataGridView.CurrentCell.RowIndex].Cells[0].Value.ToString())); } work.PrintRecall(recallDataGridView); if (directorTabControl.SelectedIndex == 5) { daoAnswer.DeleteAnswer(Data.context, Convert.ToInt16(answerDataGridView.Rows[answerDataGridView.CurrentCell.RowIndex].Cells[0].Value.ToString())); } work.PrintAnswer(answerDataGridView); }
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("Заполните обязательное поле Имя"); } }