Exemple #1
0
        private void PART_Editor_GotFocus(object sender, RoutedEventArgs e)
        {
            if (WarehouseCache == null)
            {
                return;
            }

            var selectedItem = dgProjectJournalLinePageGrid.SelectedItem as ProjectJournalLineLocal;

            if (selectedItem?._Warehouse != null)
            {
                var selected = (InvWarehouse)WarehouseCache.Get(selectedItem._Warehouse);
                setLocation(selected, selectedItem);
            }
        }
Exemple #2
0
        private void SelectedItem_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var rec = (ProjectJournalLineLocal)sender;

            switch (e.PropertyName)
            {
            case "Item":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    SetItem(rec);
                    getCostAndSales(rec);
                    rec.InsidePropChange = false;
                }
                break;

            case "Project":
                var pro = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                if (pro != null)
                {
                    if (pro._Dim1 != null)
                    {
                        rec.Dimension1 = pro._Dim1;
                    }
                    if (pro._Dim2 != null)
                    {
                        rec.Dimension2 = pro._Dim2;
                    }
                    if (pro._Dim3 != null)
                    {
                        rec.Dimension3 = pro._Dim3;
                    }
                    if (pro._Dim4 != null)
                    {
                        rec.Dimension4 = pro._Dim4;
                    }
                    if (pro._Dim5 != null)
                    {
                        rec.Dimension5 = pro._Dim5;
                    }
                    rec.Invoiceable = pro._InvoiceAble;
                    getCostAndSales(rec);
                    TimePriceLookup?.GetEmployeePrice(rec);
                    setTask(pro, rec);
                }
                break;

            case "PrCategory":
                getCostAndSales(rec);
                SetInvoiceable(rec);
                break;

            case "Employee":
                if (rec._Employee != null)
                {
                    var emp = (Uniconta.DataModel.Employee)EmployeeCache?.Get(rec._Employee);
                    if (emp?._PayrollCategory != null)
                    {
                        rec.PayrollCategory = emp._PayrollCategory;
                    }
                    if (!rec.InsidePropChange)
                    {
                        rec.InsidePropChange = true;
                        TimePriceLookup?.GetEmployeePrice(rec);
                        PayrollCat(rec, true);     //rec.InsidePropChange = false; done inside method
                    }
                }
                break;

            case "PayrollCategory":
                if (rec._Employee != null && rec._PayrollCategory != null)
                {
                    if (!rec.InsidePropChange)
                    {
                        rec.InsidePropChange = true;
                        TimePriceLookup?.GetEmployeePrice(rec);
                        PayrollCat(rec, true);     //rec.InsidePropChange = false; done inside method
                    }
                }
                break;

            case "Warehouse":
                if (WarehouseCache != null)
                {
                    var selected = (InvWarehouse)WarehouseCache.Get(rec._Warehouse);
                    setLocation(selected, rec);
                }
                break;

            case "Location":
                if (string.IsNullOrEmpty(rec._Warehouse))
                {
                    rec._Location = null;
                }
                break;

            case "TimeFrom":
            case "TimeTo":
                if (rec._TimeTo >= rec._TimeFrom)
                {
                    rec.Qty = (rec._TimeTo - rec._TimeFrom) / 60d;
                }
                else
                {
                    rec.Qty = ((rec._TimeTo + 24 * 60) - rec._TimeFrom) / 60d;
                }
                break;

            case "Qty":
                UpdatePrice(rec);
                double tim;
                if (rec._TimeTo >= rec._TimeFrom)
                {
                    tim = (rec._TimeTo - rec._TimeFrom) / 60d;
                }
                else
                {
                    tim = ((rec._TimeTo + 24 * 60) - rec._TimeFrom) / 60d;
                }

                if (rec._Qty != tim)
                {
                    rec._TimeFrom = 0;
                    rec._TimeTo   = 0;
                }
                break;

            case "EAN":
                FindOnEAN(rec);
                break;

            case "SerieBatch":
                if (ItemsCache != null)
                {
                    if (rec._Item == null || rec._Item == string.Empty)
                    {
                        GetItemFromSerailNumber(rec);
                    }
                }
                break;

            case "Task":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    if (rec._Task != null && rec._Project != null)
                    {
                        var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                        var task = proj.FindTask(rec._Task);
                        if (task != null)
                        {
                            rec.WorkSpace       = task._WorkSpace;
                            rec.PayrollCategory = task._PayrollCategory != null ? task._PayrollCategory : rec.PayrollCategory;
                        }
                    }
                    rec.InsidePropChange = false;
                }
                break;

            case "WorkSpace":
                if (!rec.InsidePropChange)
                {
                    rec.InsidePropChange = true;
                    if (rec._Task != null && rec._Project != null)
                    {
                        var proj = (Uniconta.DataModel.Project)ProjectCache.Get(rec._Project);
                        var task = proj.FindTask(rec._Task);
                        if (task != null && task._WorkSpace != rec._WorkSpace)
                        {
                            rec.Task = null;
                        }
                    }
                    rec.InsidePropChange = false;
                }
                break;
            }
        }