Example #1
0
        private void cbxproperty_SelectionChanged(object sender, EventArgs e)
        {
            if (cbxproperty.SelectedItem != null)
            {
                project_task project_task_output = treeProject.SelectedItem_ as project_task;

                if (project_task_output != null)
                {
                    project_task_output.item_description = project_task_output.item_description + " || POS: '" + cbxproperty.Text + "'";
                    project_task_output.RaisePropertyChanged("item_description");
                }
            }
        }
Example #2
0
        private void btnPlaceProject_Click(object sender, RoutedEventArgs e)
        {
            //using (ProjectDB db = new ProjectDB())
            //{
            project project = new project();

            contact contact = EventDB.contacts.Where(x => x.id_contact == sbxContact.ContactID).FirstOrDefault();

            project.id_contact = contact.id_contact;

            project.IsSelected     = true;
            project.id_branch      = CurrentSession.Id_Branch;
            project.name           = txtName.Text;
            project.est_start_date = timestampCalendar.SelectedDate;
            project.est_end_date   = timestampCalendar.SelectedDate;
            project.priority       = 0;

            project_event project_costing = project_costingViewSource.View.CurrentItem as project_event;

            if (project_costing != null)
            {
                foreach (project_event_variable project_event_variable in project_costing.project_event_variable.Where(a => a.is_included == true))
                {
                    item item = project_event_variable.item;
                    if (item != null && item.id_item > 0 && item.is_autorecepie)
                    {
                        project_task project_task = new project_task();
                        project_task.status = Status.Project.Pending;
                        //project_task.project = project;
                        project_task.id_item          = project_event_variable.id_item;
                        project_task.item_description = project_event_variable.item.name;
                        project_task.code             = project_event_variable.item.code;
                        project_task.quantity_est     = ((project_event_variable.adult_consumption) + (project_event_variable.child_consumption));
                        project_task.unit_cost_est    = get_Price(contact, IDcurrencyfx, project_event_variable.item, entity.App.Modules.Sales);


                        if (item.item_recepie.Count() > 0)
                        {
                            foreach (item_recepie_detail item_recepie_detail in item.item_recepie.FirstOrDefault().item_recepie_detail)
                            {
                                project_task Subproject_task = new project_task();

                                Subproject_task.code             = item_recepie_detail.item.code;
                                Subproject_task.item_description = item_recepie_detail.item.name;
                                Subproject_task.id_item          = item_recepie_detail.item.id_item;
                                Subproject_task.items            = item_recepie_detail.item;
                                project_task.status = Status.Project.Pending;
                                Subproject_task.RaisePropertyChanged("item");
                                if (item_recepie_detail.quantity > 0)
                                {
                                    Subproject_task.quantity_est = (decimal)item_recepie_detail.quantity * project_task.quantity_est;
                                }
                                project_task.child.Add(Subproject_task);
                            }
                        }


                        project.project_task.Add(project_task);
                    }
                    else
                    {
                        project_task project_task = new project_task();
                        project_task.status = Status.Project.Pending;
                        //project_task.project = project;
                        project_task.id_item          = project_event_variable.id_item;
                        project_task.item_description = project_event_variable.item.name;
                        project_task.code             = project_event_variable.item.code;
                        project_task.quantity_est     = ((project_event_variable.adult_consumption) + (project_event_variable.child_consumption));
                        project_task.unit_cost_est    = get_Price(contact, IDcurrencyfx, project_event_variable.item, entity.App.Modules.Sales);
                        project.project_task.Add(project_task);
                    }
                }

                foreach (project_event_fixed per_event_service in project_costing.project_event_fixed.Where(a => a.is_included == true))
                {
                    item item = per_event_service.item;
                    if (item != null && item.id_item > 0 && item.is_autorecepie)
                    {
                        project_task project_task = new project_task();
                        project_task.status = Status.Project.Pending;
                        //project_task.project = project;
                        project_task.id_item          = per_event_service.id_item;
                        project_task.item_description = per_event_service.item.name;
                        project_task.code             = per_event_service.item.code;
                        project_task.quantity_est     = per_event_service.consumption;
                        project_task.unit_cost_est    = get_Price(contact, IDcurrencyfx, per_event_service.item, entity.App.Modules.Sales);


                        foreach (item_recepie_detail item_recepie_detail in item.item_recepie.FirstOrDefault().item_recepie_detail)
                        {
                            project_task Subproject_task = new project_task();

                            Subproject_task.code             = item_recepie_detail.item.name;
                            Subproject_task.item_description = item_recepie_detail.item.name;
                            Subproject_task.id_item          = item_recepie_detail.item.id_item;
                            Subproject_task.items            = item_recepie_detail.item;
                            Subproject_task.RaisePropertyChanged("item");
                            if (item_recepie_detail.quantity > 0)
                            {
                                Subproject_task.quantity_est = (decimal)item_recepie_detail.quantity * project_task.quantity_est;
                            }



                            project_task.child.Add(Subproject_task);
                        }
                        project.project_task.Add(project_task);
                    }
                    else
                    {
                        project_task project_task = new project_task();
                        project_task.status = Status.Project.Pending;
                        //project_task.project = project;
                        project_task.id_item          = per_event_service.id_item;
                        project_task.item_description = per_event_service.item.name;
                        project_task.code             = per_event_service.item.code;
                        project_task.quantity_est     = per_event_service.consumption;
                        project_task.unit_cost_est    = get_Price(contact, IDcurrencyfx, per_event_service.item, entity.App.Modules.Sales);
                        project.project_task.Add(project_task);
                    }
                }
                item _item = project_costing.item;
                if (_item != null && _item.id_item > 0 && _item.is_autorecepie)
                {
                    project_task _project_task = new project_task();
                    _project_task.status = Status.Project.Pending;
                    //_project_task.project = project;
                    _project_task.id_item          = project_costing.id_item;
                    _project_task.item_description = project_costing.item.name;
                    _project_task.code             = project_costing.item.code;
                    _project_task.quantity_est     = 1;
                    _project_task.unit_cost_est    = get_Price(contact, IDcurrencyfx, project_costing.item, entity.App.Modules.Sales);



                    foreach (item_recepie_detail item_recepie_detail in _item.item_recepie.FirstOrDefault().item_recepie_detail)
                    {
                        project_task Subproject_task = new project_task();

                        Subproject_task.code             = item_recepie_detail.item.name;
                        Subproject_task.item_description = item_recepie_detail.item.name;
                        Subproject_task.id_item          = item_recepie_detail.item.id_item;
                        Subproject_task.items            = item_recepie_detail.item;
                        Subproject_task.RaisePropertyChanged("item");
                        if (item_recepie_detail.quantity > 0)
                        {
                            Subproject_task.quantity_est = (decimal)item_recepie_detail.quantity * _project_task.quantity_est;
                        }



                        _project_task.child.Add(Subproject_task);
                    }
                    project.project_task.Add(_project_task);
                }
                else
                {
                    project_task _project_task = new project_task();
                    _project_task.status = Status.Project.Pending;
                    //_project_task.project = project;
                    _project_task.id_item          = project_costing.id_item;
                    _project_task.item_description = project_costing.item.name;
                    _project_task.code             = project_costing.item.code;
                    _project_task.quantity_est     = 1;
                    _project_task.unit_cost_est    = get_Price(contact, IDcurrencyfx, project_costing.item, entity.App.Modules.Sales);
                    project.project_task.Add(_project_task);
                }

                project_costing.status = Status.Documents_General.Approved;

                EventDB.projects.Add(project);
                EventDB.SaveChanges();
            }
            //}
        }
Example #3
0
        private void item_Select(object sender, RoutedEventArgs e)
        {
            if (sbxItem.ItemID > 0)
            {
                item item = ProjectTaskDB.items.Where(x => x.id_item == sbxItem.ItemID).FirstOrDefault();


                project_task project_task_output = treeProject.SelectedItem_ as project_task;
                if (project_task_output.parent != null)
                {
                    if (project_task_output.parent.items.is_autorecepie)
                    {
                        MessageBox.Show("can't add becuse item is auto receipe");
                    }
                }

                if (item != null && item.id_item > 0 && item.is_autorecepie)
                {
                    project_task_output.id_item = item.id_item;
                    project_task_output.items   = item;
                    project_task_output.RaisePropertyChanged("item");
                    project_task_output.quantity_est = 1;
                    foreach (item_recepie_detail item_recepie_detail in item.item_recepie.FirstOrDefault().item_recepie_detail)
                    {
                        project_task project_task = new project_task();

                        project_task.code             = item_recepie_detail.item.name;
                        project_task.item_description = item_recepie_detail.item.name;
                        project_task.id_item          = item_recepie_detail.item.id_item;
                        project_task.items            = item_recepie_detail.item;
                        project_task.id_project       = project_task_output.id_project;
                        project_task.status           = Status.Project.Pending;
                        project_task.RaisePropertyChanged("item");
                        if (item_recepie_detail.quantity > 0)
                        {
                            project_task.quantity_est = (decimal)item_recepie_detail.quantity;
                        }
                        project_task_output.child.Add(project_task);
                    }
                    filter_task();
                }
                else
                {
                    if (project_task_output.code == "")
                    {
                        project_task_output.code = item.code;
                    }
                    project_task_output.id_item          = item.id_item;
                    project_task_output.items            = item;
                    project_task_output.item_description = item.name;
                    project_task_output.RaisePropertyChanged("item_description");
                    project_task_output.RaisePropertyChanged("item");
                    project_task_output.quantity_est = 1;
                }

                if (item.item_dimension != null)
                {
                    project_task_output.items = item;
                    project_task_output.project_task_dimension.Clear();
                    foreach (item_dimension _item_dimension in item.item_dimension)
                    {
                        project_task_dimension project_task_dimension = new project_task_dimension();
                        project_task_dimension.id_dimension    = _item_dimension.id_app_dimension;
                        project_task_dimension.app_dimension   = _item_dimension.app_dimension;
                        project_task_dimension.value           = _item_dimension.value;
                        project_task_dimension.id_measurement  = _item_dimension.id_measurement;
                        project_task_dimension.app_measurement = _item_dimension.app_measurement;
                        project_task_dimension.id_project_task = project_task_output.id_project_task;
                        project_task_dimension.project_task    = project_task_output;
                        ProjectTaskDB.project_task_dimension.Add(project_task_dimension);
                        project_task_dimensionViewSource.View.MoveCurrentToLast();
                    }
                }
                try
                {
                    if (project_task_dimensionViewSource != null)
                    {
                        if (project_task_dimensionViewSource.View != null)
                        {
                            project_task_dimensionViewSource.View.Filter = i =>
                            {
                                project_task_dimension _project_task_dimension = (project_task_dimension)i;
                                if (_project_task_dimension.project_task == project_task_output)
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            };
                        }
                    }
                }
                catch (Exception ex)
                {
                    toolBar.msgError(ex);
                }
            }
        }