Пример #1
0
        private void BtnDeleteService_Click(object sender, RoutedEventArgs e)
        {
            if (_service != null)
            {
                KubixAdmin.Service newService = context.Services.Find(_service.ServiceID);
                if (newService != null)
                {
                    context.Services.Remove(newService);
                    context.SaveChanges();
                }

                Application.Current.MainWindow.Content = new Services();
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            KubixAdmin.Project newProject;
            if (_project != null)
            {
                newProject = context.Projects.Find(_customer.CustomerID, _project.ProjectID);
            }
            else
            {
                newProject            = new KubixAdmin.Project();
                newProject.CustomerID = _customer.CustomerID;
                context.Projects.Add(newProject);
            }

            newProject.Name           = tbxName.Text;
            newProject.Address        = tbxAddress.Text;
            newProject.IsFinished     = false;
            newProject.ExpirationDate = dtpExpirationDate.SelectedDate.Value.Date;
            newProject.ExpectedPrice  = decimal.Parse(tbxExpectedPrice.Text);
            newProject.ActualPrice    = decimal.Parse(tbxActualPrice.Text);

            context.SaveChanges();



            ProjectService projectSerivce;

            foreach (CheckboxInputControl ps in icServices.Children)
            {
                projectSerivce = context.ProjectServices.Find(ps.ParentID, ps.ChildID);
                if (ps.cbIsMaterialChecked.IsChecked.Value)
                {
                    if (projectSerivce == null)
                    {
                        projectSerivce           = new ProjectService();
                        projectSerivce.ServiceID = ps.ChildID;
                        projectSerivce.ProjectID = ps.ParentID;
                        context.ProjectServices.Add(projectSerivce);
                    }
                    projectSerivce.UnitsPerService = int.Parse(ps.tbMaterialPerUnit.Text);
                }
            }
            context.SaveChanges();


            Application.Current.MainWindow.Content = new ProjectDashboard(_customer, newProject);
        }
Пример #3
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            KubixAdmin.Material newMaterial;
            if (_material != null)
            {
                newMaterial = context.Materials.Find(_material.MaterialID);
            }
            else
            {
                newMaterial = new KubixAdmin.Material();
                context.Materials.Add(newMaterial);
            }

            newMaterial.Name            = tbxName.Text;
            newMaterial.Description     = tbxDescription.Text;
            newMaterial.UnitMeasurement = tbxUnitMeasurement.Text;
            newMaterial.UnitPrice       = int.Parse(tbxUnitPrice.Text);
            newMaterial.Type            = tbxType.Text;

            context.SaveChanges();
            Application.Current.MainWindow.Content = new Materials();
        }
Пример #4
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            KubixAdmin.Customer newCustomer;

            if (_customer != null)
            {
                newCustomer = context.Customers.Find(_customer.CustomerID);
            }
            else
            {
                newCustomer = new KubixAdmin.Customer();
                context.Customers.Add(newCustomer);
            }
            newCustomer.Name         = tbxName.Text;
            newCustomer.Surname      = tbxSurname.Text;
            newCustomer.Address      = tbxAddress.Text;
            newCustomer.PhoneNumber  = tbxPhoneNumber.Text;
            newCustomer.Email        = tbxEmail.Text;
            newCustomer.CreationDate = DateTime.Parse(tbxCreationDate.Text);

            context.SaveChanges();
            Application.Current.MainWindow.Content = new Projects(newCustomer);
        }