public Projects(KubixAdmin.Customer cc) { InitializeComponent(); _customerID = cc.CustomerID; _customer = cc; context = new KubixDBEntities(); context.Projects.Load(); BitmapImage imgsrc = new BitmapImage(new Uri("/Images/icon_event_primary.png", UriKind.Relative)); enable = (Style)FindResource("ButtonPrimary"); disable = (Style)FindResource("ButtonPrimaryDisabled"); headerControl.CurrentCustomer = cc.Name + " " + cc.Surname; tblWelcomeUser.Text = "Add new project or work on existing projects for customer " + headerControl.CurrentCustomer; foreach (KubixAdmin.Project proj in context.Projects.Local) { if (proj.CustomerID == _customer.CustomerID) { ProjectControl pj = new ProjectControl(); pj.ProjectID = proj.ProjectID; pj.ProjectName = proj.Name; pj.ProjectExpirationDate = proj.ExpirationDate.Value.ToShortDateString(); pj.ProjectAddress = proj.Address; pj.ProjectCreatedLabel = "EXPIRES ON"; pj.ProjectExpectedPrice = proj.ExpectedPrice.ToString(); pj.ProjectLogoSource = imgsrc; pj.Control_Click += new EventHandler(Control_click); rpsGridProjects.Children.Add(pj); } } }
public Project(KubixAdmin.Customer customer, KubixAdmin.Project project) { InitializeComponent(); enable = (Style)FindResource("ButtonPrimary"); disable = (Style)FindResource("ButtonPrimaryDisabled"); headerControl.CurrentCustomer = customer.Name + " " + customer.Surname; _customer = customer; _project = project; btnDeleteProject.Style = disable; int projectId = -1; if (project != null) { projectId = project.ProjectID; tbxName.Text = project.Name; tbxAddress.Text = project.Address; tbxExpectedPrice.Text = project.ExpectedPrice.ToString(); dtpExpirationDate.SelectedDate = project.ExpirationDate; tbxActualPrice.Text = project.ActualPrice.ToString(); btnDeleteProject.Style = enable; } context = new KubixDBEntities(); context.Projects.Load(); context.ProjectServices.Load(); context.Services.Load(); List <ProjectService> listProjectServices = (from p in context.Projects join ps in context.ProjectServices on p.ProjectID equals ps.ProjectID where p.ProjectID == projectId select ps).ToList(); foreach (var serv in context.Services.Local) { CheckboxInputControl smc = new CheckboxInputControl(); foreach (ProjectService ps in listProjectServices) { if (serv.ServiceID == ps.ServiceID) { smc.cbIsMaterialChecked.IsChecked = true; break; } } smc.ChildID = serv.ServiceID; smc.ParentID = projectId; smc.cbIsMaterialChecked.Content = serv.Name; smc.tblMaterialUnit.Text = "m2"; icServices.Children.Add(smc); } }
public Materials() { InitializeComponent(); context = new KubixDBEntities(); context.Materials.Load(); BitmapImage imgsrc = new BitmapImage(new Uri("/Images/icon_user_primary.png", UriKind.Relative)); enable = (Style)FindResource("ButtonPrimary"); disable = (Style)FindResource("ButtonPrimaryDisabled"); foreach (var matr in context.Materials.Local) { MaterialControl mat = new MaterialControl(); mat.MaterialName = matr.Name; mat.MaterialDescription = matr.Description; mat.MaterialUnitMeasurement = matr.UnitMeasurement; mat.MaterialUnitPrice = matr.UnitPrice.ToString() + " euros."; mat.MaterialType = matr.Type; mat.Control_Click += new EventHandler(Control_click); mat.MaterialID = matr.MaterialID; rpsGridMaterials.Children.Add(mat); } }
public Customers() { InitializeComponent(); context = new KubixDBEntities(); context.Customers.Load(); BitmapImage imgsrc = new BitmapImage(new Uri("/Images/icon_user_primary.png", UriKind.Relative)); enable = (Style)FindResource("ButtonPrimary"); disable = (Style)FindResource("ButtonPrimaryDisabled"); foreach (var cust in context.Customers.Local) { CustomerControl cc = new CustomerControl(); cc.CustomerName = cust.Name + " " + cust.Surname; cc.CustomerLocation = cust.Address; cc.CustomerCreatedDate = cust.CreationDate.ToShortDateString(); cc.CustomerCreatedLabel = "CREATED ON"; cc.CustomerPhoneNumber = cust.PhoneNumber; cc.Control_Click += new EventHandler(Control_click); cc.CustomerLogoSource = imgsrc; cc.CustomerID = cust.CustomerID; rpsGridCustomers.Children.Add(cc); } }
public Services() { InitializeComponent(); context = new KubixDBEntities(); context.Services.Load(); BitmapImage imgsrc = new BitmapImage(new Uri("/Images/icon_user_primary.png", UriKind.Relative)); enable = (Style)FindResource("ButtonPrimary"); disable = (Style)FindResource("ButtonPrimaryDisabled"); foreach (var cust in context.Services.Local) { CustomerControl cc = new CustomerControl(); cc.CustomerName = cust.Name; cc.CustomerLocation = cust.Description; cc.CustomerCreatedDate = cust.WorkPrice.ToString(); cc.CustomerCreatedLabel = cust.WorkTime.ToString(); //cc.CustomerPhoneNumber = cust.PhoneNumber; cc.Control_Click += new EventHandler(Control_click); cc.CustomerLogoSource = imgsrc; cc.CustomerID = cust.ServiceID; rpsGridServices.Children.Add(cc); } }
public Service(KubixAdmin.Service service) { InitializeComponent(); enable = (Style)FindResource("ButtonPrimary"); disable = (Style)FindResource("ButtonPrimaryDisabled"); _service = service; context = new KubixDBEntities(); context.Materials.Load(); context.Services.Load(); context.ServiceMaterials.Load(); context.Units.Load(); ComboboxItem cbi; int serviceId = -1; if (service != null) { tbxServiceName.Text = _service.Name; tbxDescription.Text = _service.Description; tbxWorkPrice.Text = _service.WorkPrice.ToString(); tbxWorkTime.Text = _service.WorkTime.ToString(); btnDeleteService.Style = enable; serviceId = _service.ServiceID; cbIsPriceIndependent.IsChecked = _service.IsIndependetPrice; } else { btnDeleteService.Style = disable; } int selctedIndex = 0; int unitIndex = 0; foreach (Unit unit in context.Units.Local) { cbi = new ComboboxItem(); cbi.Text = unit.UnitName; cbi.Value = unit.UnitUD; if (_service != null && _service.UnitID == unit.UnitUD) { selctedIndex = unitIndex; } cbxMeasurementUnit.Items.Add(cbi); unitIndex++; } cbxMeasurementUnit.SelectedIndex = selctedIndex; List <ServiceMaterial> listServiceMaterials = (from s in context.Services join sm in context.ServiceMaterials on s.ServiceID equals sm.ServiceID where s.ServiceID == serviceId select sm).ToList(); foreach (var matr in context.Materials.Local) { CheckboxInputControl smc = new CheckboxInputControl(); foreach (ServiceMaterial sm in listServiceMaterials) { if (matr.MaterialID == sm.MaterialID) { smc.cbIsMaterialChecked.IsChecked = true; break; } } smc.ChildID = matr.MaterialID; smc.ParentID = serviceId; smc.cbIsMaterialChecked.Content = matr.Name; smc.tblMaterialUnit.Text = matr.UnitMeasurement; icMaterials.Children.Add(smc); } }
public ProjectDashboard(KubixAdmin.Customer customer, KubixAdmin.Project project) { InitializeComponent(); _customer = customer; _project = project; headerControl.CurrentCustomer = customer.Name + " " + customer.Surname; subheaderControl.ProjectName = project.Name; subheaderControl.ProjectLocation = project.Address; tblWelcomeUser.Text = "Please work on project " + project.Name + " for customer " + headerControl.CurrentCustomer; GlobalSettings.CurrentCustomer = customer; GlobalSettings.CurrentProject = project; context = new KubixDBEntities(); context.Materials.Load(); context.Services.Load(); context.Projects.Load(); context.ProjectServices.Load(); context.ServiceMaterials.Load(); var listProjectServices = (from p in context.Projects join ps in context.ProjectServices on p.ProjectID equals ps.ProjectID join s in context.Services on ps.ServiceID equals s.ServiceID join u in context.Units on s.UnitID equals u.UnitUD where p.ProjectID == project.ProjectID select new { p.ProjectID, s.ServiceID, s.Name, s.WorkPrice, s.WorkTime, s.UnitID, s.IsIndependetPrice, u.UnitName, u.UnitDescription, ps.UnitsPerService }).ToList(); DynamicGrid.RowDefinitions.Clear(); DynamicGrid.ColumnDefinitions.Clear(); ColumnDefinition serviceDesc = new ColumnDefinition(); ColumnDefinition serviceUnit = new ColumnDefinition(); ColumnDefinition servicePricePerUnit = new ColumnDefinition(); ColumnDefinition materialAmount = new ColumnDefinition(); ColumnDefinition totalPrice = new ColumnDefinition(); DynamicGrid.ColumnDefinitions.Add(serviceDesc); DynamicGrid.ColumnDefinitions.Add(serviceUnit); DynamicGrid.ColumnDefinitions.Add(servicePricePerUnit); DynamicGrid.ColumnDefinitions.Add(materialAmount); DynamicGrid.ColumnDefinitions.Add(totalPrice); int rowNumber = 0; foreach (var projectService in listProjectServices) { rowNumber++; var listServiceMaterials = (from s in context.Services join sm in context.ServiceMaterials on s.ServiceID equals sm.ServiceID where s.ServiceID == projectService.ServiceID select sm).ToList(); rowNumber = rowNumber + listServiceMaterials.Count(); } int row = 0; while (row < rowNumber) { DynamicGrid.RowDefinitions.Add(new RowDefinition()); row++; } int rowIndex = 0; foreach (var service in listProjectServices) { TextBlock name = new TextBlock(); name.Text = service.Name; name.FontSize = 18; name.FontWeight = FontWeights.Bold; Grid.SetRow(name, rowIndex); Grid.SetColumn(name, 0); TextBlock unit = new TextBlock(); unit.Text = service.UnitName; unit.FontSize = 18; unit.FontWeight = FontWeights.Bold; Grid.SetRow(unit, rowIndex); Grid.SetColumn(unit, 1); TextBlock price = new TextBlock(); price.Text = service.WorkPrice.ToString(); price.FontSize = 18; price.FontWeight = FontWeights.Bold; Grid.SetRow(price, rowIndex); Grid.SetColumn(price, 2); TextBlock amount = new TextBlock(); amount.Text = service.UnitsPerService.ToString(); amount.FontSize = 18; amount.FontWeight = FontWeights.Bold; Grid.SetRow(amount, rowIndex); Grid.SetColumn(amount, 3); TextBlock priceTotal = new TextBlock(); priceTotal.Text = "0"; priceTotal.FontSize = 18; priceTotal.FontWeight = FontWeights.Bold; Grid.SetRow(priceTotal, rowIndex); Grid.SetColumn(priceTotal, 4); DynamicGrid.Children.Add(name); DynamicGrid.Children.Add(unit); DynamicGrid.Children.Add(price); DynamicGrid.Children.Add(amount); DynamicGrid.Children.Add(priceTotal); var listServiceMaterials = (from s in context.Services join sm in context.ServiceMaterials on s.ServiceID equals sm.ServiceID join m in context.Materials on sm.MaterialID equals m.MaterialID where s.ServiceID == service.ServiceID select new { s.ServiceID, m.MaterialID, m.Name, m.UnitMeasurement, m.UnitPrice, m.Description, m.Type, sm.MaterialPerUnit }).ToList(); rowIndex++; foreach (var material in listServiceMaterials) { name = new TextBlock(); name.Text = material.Name; name.FontSize = 14; name.FontWeight = FontWeights.Medium; Grid.SetRow(name, rowIndex); Grid.SetColumn(name, 0); unit = new TextBlock(); unit.Text = material.UnitMeasurement; name.FontSize = 14; name.FontWeight = FontWeights.Medium; Grid.SetRow(unit, rowIndex); Grid.SetColumn(unit, 1); price = new TextBlock(); price.Text = material.UnitPrice.ToString(); name.FontSize = 14; name.FontWeight = FontWeights.Medium; Grid.SetRow(price, rowIndex); Grid.SetColumn(price, 2); amount = new TextBlock(); amount.Text = material.MaterialPerUnit.ToString(); name.FontSize = 14; name.FontWeight = FontWeights.Medium; Grid.SetRow(amount, rowIndex); Grid.SetColumn(amount, 3); priceTotal = new TextBlock(); priceTotal.Text = "0"; name.FontSize = 14; name.FontWeight = FontWeights.Medium; Grid.SetRow(priceTotal, rowIndex); Grid.SetColumn(priceTotal, 4); DynamicGrid.Children.Add(name); DynamicGrid.Children.Add(unit); DynamicGrid.Children.Add(price); DynamicGrid.Children.Add(amount); DynamicGrid.Children.Add(priceTotal); rowIndex++; } } }