public void RDatesSource() { switch (RDSelected_dep_index) { case (int)DIndex.kb: { String_dates.Clear(); RString_dates.Clear(); context = new DiakontEntities(); context.Departments.Load(); foreach (Departments d in context.Departments) { if (d.department_name == "КБ" && d.workers_amount != null) { String_dates.Add(d.jd_from.ToString()); RString_dates.Add(d.date_to.ToString()); } } if (RString_dates.LongCount() > 0) { RSelected_jdate = RString_dates[0]; } break; } case (int)DIndex.to: { String_dates.Clear(); RString_dates.Clear(); context = new DiakontEntities(); context.Departments.Load(); foreach (Departments d in context.Departments) { if (d.department_name == "ТО" && d.workers_amount != null) { String_dates.Add(d.jd_from.ToString()); RString_dates.Add(d.date_to.ToString()); } } RSelected_jdate = RString_dates[0]; break; } } NotifyPropertyChanged(nameof(String_dates)); NotifyPropertyChanged(nameof(RString_dates)); NotifyPropertyChanged(nameof(RSelected_jdate)); }
public void DatesSource() { switch (DSelected_job_index) { case (int)JIndex.ik: { String_dates.Clear(); context = new DiakontEntities(); context.Jobs.Load(); foreach (Jobs j in context.Jobs) { if (j.job_name == "Инженер-конструктор" && j.fee != null) { String_dates.Add(j.jdate_from.ToString()); } } if (String_dates.LongCount() > 0) { Selected_jdate = String_dates[0]; RSelected_jdate = String_dates[0]; } break; } case (int)JIndex.it: { String_dates.Clear(); context = new DiakontEntities(); context.Jobs.Load(); foreach (Jobs j in context.Jobs) { if (j.job_name == "Инженер-технолог" && j.fee != null) { String_dates.Add(j.jdate_from.ToString()); } } Selected_jdate = String_dates[0]; RSelected_jdate = String_dates[0]; break; } } NotifyPropertyChanged(nameof(String_dates)); NotifyPropertyChanged(nameof(Selected_jdate)); NotifyPropertyChanged(nameof(RSelected_jdate)); }
public DiakontViewModel() { context = new DiakontEntities(); Job_names = new List <string>(); DJob_names = new List <string>(); Dep_names = new List <string>(); String_dates = new List <string>(); RString_dates = new List <string>(); context.Jobs.Load(); context.Departments.Load(); var init_jobs = context.Jobs.ToList(); var init_departments = context.Departments.ToList(); foreach (Jobs j in init_jobs) { if (j.fee == null) { Job_names.Add(j.job_name); } } foreach (Departments d in init_departments) { if (d.workers_amount == null) { Dep_names.Add(d.department_name); } } foreach (Departments d in init_departments) { if (d.workers_amount != null) { RString_dates.Add(d.date_to.ToString()); } } foreach (Jobs j in init_jobs) { if (j.job_name == "Инженер-конструктор" && j.fee != null) { String_dates.Add(j.jdate_from.ToString()); } } Selected_job = Job_names[0]; Selected_department = Dep_names[0]; Selected_department_index = 0; RDSelected_dep_index = 0; JDate_from = DateTime.Now; Date_to = DateTime.Now; Rjd_from = DateTime.Now; RDate_to = DateTime.Now; jobsDataGrid.ItemsSource = context.Jobs.SqlQuery("select * from Jobs where fee is not null").ToList(); using (SqlConnection connection = new SqlConnection(@"Data Source=DESKTOP-7442FLF;Initial Catalog=Diakont; Integrated security = true; User ID=DESKTOP-7442FLF\dehnk;Password=1803")) { connection.Open(); string sqlQuery = "select department_name, job_name, jd_from, date_to, workers_amount from Departments join Jobs on Departments.jd_from = Jobs.jdate_from where workers_amount is not null"; SqlCommand command = new SqlCommand(sqlQuery, connection); SqlDataAdapter da = new SqlDataAdapter(command); DataTable dt = new DataTable("Departments"); da.Fill(dt); departmentsDataGrid.ItemsSource = dt.DefaultView; da.Update(dt); connection.Close(); } AddJob = new BaseCommand(AddNewJob, true); AddDepartment = new BaseCommand(AddNewDepartment, true); ShowReport = new BaseCommand(ShowPaymentReport, true); }