public void SaveMarkupRowOldRow(TblMarkupTranProdViewModel oldRow)
        {
            if (oldRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(oldRow,
                                                          new ValidationContext(oldRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save = oldRow.Iserial == 0;
                    if (AllowUpdate != true && !save)
                    {
                        MessageBox.Show(strings.AllowUpdateMsg);
                        return;
                    }
                    var saveRow = new PurchasePlanService.TblDyeingOrderInvoiceMarkupTransProd();
                    saveRow.InjectFrom(oldRow);
                    saveRow.TblDyeingOrderInvoiceHeader = SelectedMainRow.Iserial;


                    if (!Loading)
                    {
                        Loading = true;

                        PurchasePlanClient.UpdateOrInsertDyeingOrderInvoiceMarkupTransProdsAsync(saveRow, save,
                                                                                                 SelectedMainRow.MarkUpTransList.IndexOf(oldRow), LoggedUserInfo.DatabasEname);
                    }
                }
            }
        }
        public void AddNewMarkUpRow(bool checkLastRow, bool header)
        {
            var currentRowIndex = (SelectedMainRow.MarkUpTransList.IndexOf(SelectedMarkupRow));

            if (checkLastRow)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMarkupRow,
                                                          new ValidationContext(SelectedMarkupRow, null, null), valiationCollection, true);

                if (!isvalid)
                {
                    return;
                }
            }
            if (AllowAdd != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }
            var newrow = new TblMarkupTranProdViewModel
            {
                Type = 0,
                TblDyeingOrderInvoiceHeader = SelectedMainRow.Iserial,
                MiscValueType = 1
            };

            SelectedMainRow.MarkUpTransList.Insert(currentRowIndex + 1, newrow);
            SelectedMarkupRow = newrow;
        }
Exemple #3
0
        public void AddNewMarkUpRow(bool checkLastRow, bool header)
        {
            var currentRowIndex = (TransactionHeader.MarkUpTransList.IndexOf(SelectedMarkupRow));

            if (checkLastRow)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(SelectedMarkupRow,
                                                          new ValidationContext(SelectedMarkupRow, null, null), valiationCollection, true);

                if (!isvalid)
                {
                    return;
                }
            }
            if (AllowAdd != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }
            var newrow = new TblMarkupTranProdViewModel
            {
                Type = 0,
                TblSalesOrderRequestInvoiceHeader = TransactionHeader.Iserial,
                MiscValueType            = 1,
                JournalAccountTypePerRow = TransactionHeader.JournalAccountTypePerRow,
                EntityPerRow             = TransactionHeader.EntityPerRow,
                TblJournalAccountType    = TransactionHeader.TblJournalAccountType,
                EntityAccount            = TransactionHeader.EntityAccount,
            };

            TransactionHeader.MarkUpTransList.Insert(currentRowIndex + 1, newrow);
            SelectedMarkupRow = newrow;
        }
Exemple #4
0
        public void SaveMarkupRowOldRow(TblMarkupTranProdViewModel oldRow)
        {
            if (oldRow != null)
            {
                var valiationCollection = new List <ValidationResult>();

                var isvalid = Validator.TryValidateObject(oldRow,
                                                          new ValidationContext(oldRow, null, null), valiationCollection, true);

                if (isvalid)
                {
                    var save = oldRow.Iserial == 0;
                    if (AllowUpdate != true && !save)
                    {
                        MessageBox.Show(strings.AllowUpdateMsg);
                        return;
                    }
                    var saveRow = new TblSalesOrderRequestInvoiceHeaderMarkupTransProd();
                    saveRow.InjectFrom(oldRow);
                    saveRow.TblSalesOrderRequestInvoiceHeader = TransactionHeader.Iserial;

                    if (!Loading)
                    {
                        Loading = true;

                        WarehouseClient.UpdateOrInsertTblSalesOrderRequestInvoiceMarkupTransProdsAsync(saveRow, save,
                                                                                                       TransactionHeader.MarkUpTransList.IndexOf(oldRow), LoggedUserInfo.DatabasEname);
                    }
                }
            }
        }
Exemple #5
0
        public void GetMarkUpdata(bool header)
        {
            var client =
                new WarehouseService.WarehouseServiceClient();

            TransactionHeader.MarkUpTransList.Clear();
            client.GetTblSalesOrderRequestInvoiceMarkupTransProdAsync(0, TransactionHeader.Iserial, LoggedUserInfo.DatabasEname);
            client.GetTblSalesOrderRequestInvoiceMarkupTransProdCompleted += (s, sv) =>
            {
                foreach (var row in sv.Result)
                {
                    var newrow = new TblMarkupTranProdViewModel();
                    newrow.InjectFrom(row);
                    newrow.CurrencyPerRow = new CRUDManagerService.GenericTable();
                    newrow.CurrencyPerRow.InjectFrom(CurrencyList.FirstOrDefault(w => w.Iserial == newrow.TblCurrency));
                    newrow.TblMarkupProd1 = new CRUDManagerService.TblMarkupProd();
                    newrow.TblMarkupProd1.InjectFrom(MarkupList.FirstOrDefault(w => w.Iserial == row.TblMarkupProd));
                    newrow.JournalAccountTypePerRow = JournalAccountTypeList.FirstOrDefault(w => w.Iserial == newrow.TblJournalAccountType);
                    newrow.EntityPerRow             = new GlService.Entity().InjectFrom(sv.entityList.FirstOrDefault(w => w.Iserial == row.EntityAccount && w.TblJournalAccountType == row.TblJournalAccountType)) as GlService.Entity;
                    newrow.TblJournalAccountType    = row.TblJournalAccountType;
                    newrow.EntityAccount            = row.EntityAccount;

                    TransactionHeader.MarkUpTransList.Add(newrow);
                }

                Loading = false;

                if (TransactionHeader.MarkUpTransList.Count == 0)
                {
                    AddNewMarkUpRow(false, true);
                }
            };

            Loading = true;
        }
        public DyeingOrderInvoiceViewModel() : base(PermissionItemName.DyeingOrderInvoice)
        {
            GetItemPermissions(PermissionItemName.DyeingOrderInvoice.ToString());
            //PermissionItemName.dyeing
            DyeingServiceClient.PostDyeingOrderInvoiceCompleted += (s, sv) =>
            {
                if (sv.Result != null)
                {
                    SelectedMainRow.InjectFrom(sv.Result);
                }
                SelectedMainRow.VisPosted = false;
                MessageBox.Show("Posted Completed");
            };
            DyeingServiceClient.DeleteDyeingOrderInvoiceHeaderCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
            };

            MiscValueTypeList = new ObservableCollection <GenericTable>
            {
                new GenericTable {
                    Iserial = 0, Code = "%", Ename = "%", Aname = "%"
                },
                new GenericTable {
                    Iserial = 1, Code = "Value", Ename = "Value", Aname = "Value"
                }
            };

            var currencyClient = new GlService.GlServiceClient();

            currencyClient.GetGenericCompleted += (s, sv) =>
            {
                CurrencyList = new ObservableCollection <CRUDManagerService.GenericTable>();
                foreach (var item in sv.Result)
                {
                    CurrencyList.Add(new CRUDManagerService.GenericTable().InjectFrom(item) as CRUDManagerService.GenericTable);
                }
            };
            currencyClient.GetGenericAsync("TblCurrency", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

            var journalAccountTypeClient = new GlService.GlServiceClient();

            journalAccountTypeClient.GetGenericCompleted += (s, sv) =>
            {
                JournalAccountTypeList = sv.Result;
            };
            journalAccountTypeClient.GetGenericAsync("TblJournalAccountType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);


            PurchasePlanClient.GetTblMarkupProdAsync(0, int.MaxValue, "it.Iserial", null, null, LoggedUserInfo.DatabasEname);

            PurchasePlanClient.GetTblMarkupProdCompleted += (s, sv) =>
            {
                MarkupList = new ObservableCollection <TblMarkupProd>();
                foreach (var item in sv.Result)
                {
                    MarkupList.Add(new TblMarkupProd().InjectFrom(item) as TblMarkupProd);
                }

                // MarkupList = sv.Result;
            };



            SelectedMainRow = new TblDyeingOrderInvoiceHeaderViewModel {
                DocDate = DateTime.Now
            };

            DyeingServiceClient.UpdateOrInsertDyeingOrderInvoiceHeaderCompleted += (s, sv) =>
            {
                if (sv.Error != null)
                {
                    MessageBox.Show(sv.Error.Message);
                }
                try
                {
                    SelectedMainRow.InjectFrom(sv.Result);

                    if (SelectedMainRow.Status == 0)
                    {
                        SelectedMainRow.VisPosted = true;
                    }
                    else
                    {
                        SelectedMainRow.VisPosted = false;
                    }
                }

                catch (Exception)
                {
                }
                Loading = false;
                if (OpenMisc)
                {
                    new MarkupTransProdChildWindow(this).Show();
                    OpenMisc = false;
                }
            };

            PurchasePlanClient.UpdateOrInsertDyeingOrderInvoiceMarkupTransProdsCompleted += (s, x) =>
            {
                var markup = new TblMarkupProd();
                try
                {
                    var row = SelectedMainRow.MarkUpTransList.ElementAt(x.outindex);
                    if (row != null)
                    {
                        markup = row.TblMarkupProd1;
                    }
                    if (x.Result.Iserial == -1)
                    {
                        MessageBox.Show("This Markup Is Not Linked To Account");
                        row.TblMarkupProd1 = null;
                    }
                    else
                    {
                        SelectedMainRow.MarkUpTransList.ElementAt(x.outindex).InjectFrom(x.Result);
                        if (row != null)
                        {
                            row.TblMarkupProd1 = markup;
                        }
                    }
                }
                catch (Exception)
                {
                }

                Loading = false;
            };
            DyeingServiceClient.GetDyeingOrderInvoiceHeaderCompleted += (s, sv) =>
            {
                Loading = false;
                MainRowList.Clear();
                foreach (var variable in sv.Result.ToList())
                {
                    var newvendor = new Vendor();
                    newvendor.InjectFrom(sv.Vendors.FirstOrDefault(w => w.vendor_code == variable.Vendor));

                    var newrow = new TblDyeingOrderInvoiceHeaderViewModel();
                    newrow.InjectFrom(variable);
                    newrow.VendorPerRow = newvendor;
                    if (newrow.Status == 0)
                    {
                        newrow.VisPosted = true;
                    }
                    newrow.CurrencyPerRow = new GenericTable();
                    newrow.CurrencyPerRow.InjectFrom(CurrencyList.FirstOrDefault(w => w.Iserial == variable.TblCurrency));
                    newrow.TblCurrency = variable.TblCurrency;
                    MainRowList.Add(newrow);
                }
            };

            DyeingServiceClient.GetDyeingOrderInvoiceDetailCompleted += (s, sv) =>
            {
                foreach (var variable in sv.Result.ToList())
                {
                    var newrow = new TblDyeingOrderInvoiceDetailViewModel();
                    newrow.InjectFrom(variable);
                    newrow.ServicePerRow       = new TblService();
                    newrow.ColorPerRow         = new TblColor();
                    newrow.ColorPerRow.Code    = variable.TblColor1.Code;
                    newrow.ServicePerRow.Code  = variable.TblService1.Code;
                    newrow.ServicePerRow.Ename = variable.TblService1.Ename;
                    TransactionDetails.Add(newrow);
                }
            };
            DyeingServiceClient.SearchDyeingOrderInvoiceCompleted += (s, sv) =>
            {
                TransactionDetails.Clear();
                foreach (var variable in sv.Result.ToList())
                {
                    var newrow = new TblDyeingOrderInvoiceDetailViewModel();
                    newrow.InjectFrom(variable);
                    newrow.ServicePerRow       = new TblService();
                    newrow.ColorPerRow         = new TblColor();
                    newrow.ColorPerRow.Code    = variable.ColorCode;
                    newrow.ServicePerRow.Code  = variable.ServiceCode;
                    newrow.ServicePerRow.Ename = variable.ServiceName;
                    newrow.SupplierInv         = variable.SupplierInv;
                    TransactionDetails.Add(newrow);
                }
            };

            PurchasePlanClient.DyeingOrderInvoiceMarkupTransProdCompleted += (s, sv) =>
            {
                foreach (var row in sv.Result)
                {
                    var newrow = new TblMarkupTranProdViewModel();
                    newrow.InjectFrom(row);
                    newrow.CurrencyPerRow = new GenericTable();
                    newrow.CurrencyPerRow.InjectFrom(CurrencyList.FirstOrDefault(w => w.Iserial == row.TblCurrency));
                    newrow.TblCurrency    = row.TblCurrency;
                    newrow.TblMarkupProd1 = new TblMarkupProd();
                    newrow.TblMarkupProd1.InjectFrom(MarkupList.FirstOrDefault(w => w.Iserial == row.TblMarkupProd));
                    newrow.TblMarkupProd            = row.TblMarkupProd;
                    newrow.JournalAccountTypePerRow = JournalAccountTypeList.FirstOrDefault(w => w.Iserial == newrow.TblJournalAccountType);
                    newrow.EntityPerRow             = new GlService.Entity().InjectFrom(sv.entityList.FirstOrDefault(w => w.Iserial == row.EntityAccount && w.TblJournalAccountType == row.TblJournalAccountType)) as GlService.Entity;
                    newrow.TblJournalAccountType    = row.TblJournalAccountType;
                    newrow.EntityAccount            = row.EntityAccount;
                    SelectedMainRow.MarkUpTransList.Add(newrow);
                }

                Loading = false;

                if (SelectedMainRow.MarkUpTransList.Count == 0)
                {
                    AddNewMarkUpRow(false, true);
                }
            };
        }