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();
}*/
}