private void ButtonTimetable_Clic object sender EventArgs int Int32 Pa

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
private void ButtonTimetable_Click(object sender, EventArgs e)
{
int x = Int32.Parse(iD_EmployeeTextBox1.Text);
string sqlSelect = "";
SqlConnection connection = new SqlConnection(Properties.Settings.Default.beauty_saloon_MarigoldConnectionString);
SqlCommand command = connection.CreateCommand();
if (String.IsNullOrEmpty(iD_EmployeeTextBox1.Text))
{
MessageBox.Show("Обязательно укажите ID необходимого сотрудника.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
else
{
if (radioButton1.Checked)
{
DateTime newdate = new DateTime();
newdate = DateTime.Now.AddDays(-30);
sqlSelect = @"Select A.ID_Timetable AS 'ID раписания', A.[Date] AS Дата, A.[Time] AS Время , A.ID_Employee AS 'ID сотрудника', C.Name_service AS Услуга, C.Duration_service AS 'Продолжительность услуги'
FROM Timetable A , Employees B, [Services] C
Where A.ID_Employee = B.ID_Employee AND
A.ID_Service = C.ID_Service AND
A.Service_done = 'да' AND
A.ID_Employee = @ID AND
A.[Date] >= @TME";
command.CommandText = sqlSelect;
command.Parameters.AddWithValue("@ID", x);
command.Parameters.AddWithValue("@TME", newdate);
}
else if (radioButton3.Checked)
{
DateTime newdate = new DateTime();
newdate = dateTimePicker1.Value;
sqlSelect = @"Select A.ID_Timetable AS 'ID раписания', A.[Date] AS Дата, A.ID_Employee AS 'ID сотрудника', A.[Time] AS Время , C.Name_service AS Услуга, C.Duration_service AS 'Продолжительность услуги'
FROM Timetable A , Employees B, [Services] C
Where A.ID_Employee = B.ID_Employee AND
A.ID_Service = C.ID_Service AND
A.Service_done = 'да' AND
A.ID_Employee = @ID AND
A.[Date] >= @TME";
command.CommandText = sqlSelect;
command.Parameters.AddWithValue("@ID", x);
command.Parameters.AddWithValue("@TME", newdate);
}
else
{
sqlSelect = @"Select A.ID_Timetable AS 'ID раписания', A.[Date] AS Дата, A.ID_Employee AS 'ID сотрудника', A.[Time] AS Время , C.Name_service AS Услуга, C.Duration_service AS 'Продолжительность услуги'
FROM Timetable A , Employees B, [Services] C
Where A.ID_Employee = B.ID_Employee AND
A.ID_Service = C.ID_Service AND
A.Service_done = 'да' AND
A.ID_Employee = @ID";
command.CommandText = sqlSelect;
command.Parameters.AddWithValue("@ID", x);
}
}
// command.CommandText = sqlSelect;
// command.Parameters.AddWithValue("@ID", x);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = command;
DataTable table = new DataTable();
adapter.Fill(table);
dataGridViewTimetable.DataSource = table;
if (table.Rows.Count == 0)
{
MessageBox.Show("Нет значений!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
//empty = true;
}
else empty = false;
}
private void ButtonEmployee_Click(object sender, EventArgs e)
{
int id = -1;
if (((DataRowView)salaryBindingSource.Current)["ID_Employee"].ToString() != "")
{
id = (int)(((DataRowView)salaryBindingSource.Current)["ID_Employee"]);
}
// id = FormEmployee.fd.ShowSelectForm(id);
try
{
id = FormEmployee.fd.ShowSelectForm(id);
if (id >= 0)
{
// MessageBox.Show(id.ToString());
((DataRowView)salaryBindingSource.Current)["ID_Employee"] = id;
salaryBindingSource.EndEdit();
standard_salaryTextBox1.Focus();
}
if (!(String.IsNullOrEmpty(iD_EmployeeTextBox1.Text)))
FIO();
}
catch (Exception err)
{
MessageBox.Show("Информация о данном сотруднике уже имеется в базе. Выберете другого", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
/* if (id >= 0)
{
MessageBox.Show(id.ToString());
((DataRowView)salaryBindingSource.Current)["ID_Employee"] = id;
salaryBindingSource.EndEdit();
standard_salaryTextBox1.Focus();
}*/
}