Exemplo n.º 1
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "CSV export| *.csv";
            dlg.Title = "Export current History view to Excel (csv)";
                            // 0        1       2           3       4       5           6           7                   8       9               10              11              12
            string[] colh = { "Time", "Event", "System", "Body", "Ship" , "Summary", "Description", "Detailed Info", "Note" , "Travel Dist", "Travel Time" , "Travel Jumps" , "Travelled MisJumps" };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Export.ExportGrid grd = new ExportGrid();
                grd.onGetCell += delegate (int r, int c)
                {
                    if (c == -1)    // next line?
                        return r < dataGridViewTravel.Rows.Count;
                    else if (c < colh.Length && dataGridViewTravel.Rows[r].Visible)
                    {
                        HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Cells[TravelHistoryColumns.HistoryTag].Tag;
                        if (c == 0)
                            return dataGridViewTravel.Rows[r].Cells[0].Value;
                        else if (c == 1)
                            return he.journalEntry.EventTypeStr;
                        else if (c == 2)
                            return (he.System != null) ? he.System.name : "Unknown";    // paranoia
                        else if (c == 3)
                            return he.WhereAmI;
                        else if (c == 4)
                            return he.ShipInformation != null ? he.ShipInformation.Name : "Unknown";
                        else if (c == 5)
                            return he.EventSummary;
                        else if (c == 6)
                            return he.EventDescription;
                        else if (c == 7)
                            return he.EventDetailedInfo;
                        else if (c == 8)
                            return dataGridViewTravel.Rows[r].Cells[4].Value;
                        else if (c == 9)
                            return he.isTravelling ? he.TravelledDistance.ToString("0.0") : "";
                        else if (c == 10)
                            return he.isTravelling ? he.TravelledSeconds.ToString() : "";
                        else if (c == 11)
                            return he.isTravelling ? he.Travelledjumps.ToStringInvariant() : "";
                        else 
                            return he.isTravelling ? he.TravelledMissingjump.ToStringInvariant() : "";
                    }
                    else
                        return null;
                };

                grd.onGetHeader += delegate (int c)
                {
                    return (c < colh.Length) ? colh[c] : null;
                };

                grd.Csvformat = discoveryform.ExportControl.radioButtonCustomEU.Checked ? CSVFormat.EU : CSVFormat.USA_UK;
                if (grd.ToCSV(dlg.FileName))
                    System.Diagnostics.Process.Start(dlg.FileName);
            }
        }
Exemplo n.º 2
0
        public void AddNewSubDetailRow(bool checkLastRow)
        {
            var currentRowIndex = (SelectedMainRow.SubDetailList.IndexOf(SelectedSubDetailRow));

            if (checkLastRow)
            {
                var lastrow             = SelectedMainRow.SubDetailList.ElementAtOrDefault(currentRowIndex);
                var valiationCollection = new List <ValidationResult>();

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

                if (!isvalid)
                {
                    return;
                }
            }
            if (AllowUpdate != true)
            {
                MessageBox.Show(strings.AllowAddMsg);
                return;
            }

            var newrow = new TblJournalSettingCostCenterViewModel
            {
                TblJournalSetting = SelectedMainRow.Iserial,
            };

            SelectedMainRow.SubDetailList.Insert(currentRowIndex + 1, newrow);
            SelectedSubDetailRow = newrow;
            if (ExportGrid != null)
            {
                ExportGrid.BeginEdit();
            }
        }
Exemplo n.º 3
0
        public void AddNewDetailRow(bool checkLastRow)
        {
            var currentRowIndex = (SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow));

            if (SelectedDetailRow == null)
            {
                currentRowIndex = 0;
            }
            if (checkLastRow)
            {
                var lastrow             = SelectedMainRow.DetailsList.ElementAtOrDefault(currentRowIndex);
                var valiationCollection = new List <ValidationResult>();

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

                if (!isvalid)
                {
                    return;
                }
            }
            if (AllowUpdate != true)
            {
                return;
            }


            var newrow = new TblJournalSettingEntityViewModel
            {
                TblJournalSetting = SelectedMainRow.Iserial,
            };

            if (SelectedMainRow.DetailsList.Any(x => x.Iserial > -1))
            {
                SelectedMainRow.DetailsList.Insert(currentRowIndex + 1, newrow);
            }
            else
            {
                if (currentRowIndex == -1)
                {
                    currentRowIndex = 0;
                }
                SelectedMainRow.DetailsList.Insert(currentRowIndex, newrow);
            }

            SelectedDetailRow = newrow;
            if (ExportGrid != null)
            {
                ExportGrid.BeginEdit();
            }
        }
Exemplo n.º 4
0
    public void OnDrawGizmos()
    {
        Gizmos.color = Color.gray;
        Gizmos.DrawWireCube(maxBounds.center, maxBounds.size);
        Gizmos.color = Color.red;
        Gizmos.DrawWireCube(fixedMaxBounds.center, fixedMaxBounds.size);

        if (gridList == null)
        {
            return;
        }

        Gizmos.color = Color.green;
        for (int i = 0; i < gridList.Count; i++)
        {
            ExportGrid grid = gridList[i];
            if (!grid.showBounds || grid.perfabMap == null || grid.perfabMap.Count == 0)
            {
                continue;
            }
            Bounds bounds = grid.bounds;
            Gizmos.DrawWireCube(bounds.center, bounds.size);
        }
    }
Exemplo n.º 5
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            SaveFileDialog dlg = new SaveFileDialog();

            dlg.Filter = "CSV export| *.csv";
            dlg.Title  = "Export current History view to Excel (csv)";
            // 0        1       2           3            4               5           6           7             8              9              10              11              12
            string[] colh = { "Time", "System", "Visits", "Other Info", "Visit List", "Body", "Ship", "Description", "Detailed Info", "Travel Dist", "Travel Time", "Travel Jumps", "Travelled MisJumps" };

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Export.ExportGrid grd = new ExportGrid();
                grd.onGetCell += delegate(int r, int c)
                {
                    if (c == -1)    // next line?
                    {
                        return(r < dataGridViewStarList.Rows.Count);
                    }
                    else if (c < colh.Length && dataGridViewStarList.Rows[r].Visible)
                    {
                        List <HistoryEntry> syslist = dataGridViewStarList.Rows[r].Tag as List <HistoryEntry>;
                        HistoryEntry        he      = syslist[0];

                        if (c == 0)
                        {
                            return(dataGridViewStarList.Rows[r].Cells[0].Value);
                        }
                        else if (c == 1)
                        {
                            return(dataGridViewStarList.Rows[r].Cells[1].Value);
                        }
                        else if (c == 2)
                        {
                            return(dataGridViewStarList.Rows[r].Cells[2].Value);
                        }
                        else if (c == 3)
                        {
                            return(dataGridViewStarList.Rows[r].Cells[3].Value);
                        }
                        else if (c == 4)
                        {
                            string tlist = "";
                            if (syslist.Count > 1)
                            {
                                for (int i = 1; i < syslist.Count; i++)
                                {
                                    tlist = tlist.AppendPrePad(syslist[i].EventTimeLocal.ToShortDateString() + " " + syslist[i].EventTimeLocal.ToShortTimeString(), ", ");
                                }
                            }
                            return(tlist);
                        }
                        else if (c == 5)
                        {
                            return(he.WhereAmI);
                        }
                        else if (c == 6)
                        {
                            return(he.ShipInformation != null ? he.ShipInformation.Name : "Unknown");
                        }
                        else if (c == 7)
                        {
                            return(he.EventDescription);
                        }
                        else if (c == 8)
                        {
                            return(he.EventDetailedInfo);
                        }
                        else if (c == 9)
                        {
                            return(he.isTravelling ? he.TravelledDistance.ToString("0.0") : "");
                        }
                        else if (c == 10)
                        {
                            return(he.isTravelling ? he.TravelledSeconds.ToString() : "");
                        }
                        else if (c == 11)
                        {
                            return(he.isTravelling ? he.Travelledjumps.ToStringInvariant() : "");
                        }
                        else    // 12
                        {
                            return(he.isTravelling ? he.TravelledMissingjump.ToStringInvariant() : "");
                        }
                    }
                    else
                    {
                        return(null);
                    }
                };

                grd.onGetHeader += delegate(int c)
                {
                    return((c < colh.Length) ? colh[c] : null);
                };

                grd.Csvformat = discoveryform.ExportControl.radioButtonCustomEU.Checked ? BaseUtils.CVSWrite.CSVFormat.EU : BaseUtils.CVSWrite.CSVFormat.USA_UK;
                if (grd.ToCSV(dlg.FileName))
                {
                    System.Diagnostics.Process.Start(dlg.FileName);
                }
            }
        }
Exemplo n.º 6
0
        public SequenceViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.Sequence.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblSequenceViewModel>();
                SelectedMainRow = new TblSequenceViewModel();

                Glclient.GetTblSequenceCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblSequenceViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("Sequence");
                    }
                };

                Glclient.UpdateOrInsertTblSequencesCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblSequenceCompleted += (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);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                GetMaindata();
            }
        }
Exemplo n.º 7
0
        public PostingProfileHeaderViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.PostingProfile.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblPostingProfileHeaderViewModel>();
                SelectedMainRow = new TblPostingProfileHeaderViewModel();

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

                Glclient.GetTblPostingProfileHeaderCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPostingProfileHeaderViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                };

                Glclient.UpdateOrInsertTblPostingProfileHeadersCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblPostingProfileHeaderCompleted += (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);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                Glclient.GetTblPostingProfileDetailCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblPostingProfileDetailViewModel
                        {
                            AccountPerRow            = row.TblAccount1,
                            JournalAccountTypePerRow = new GenericTable()
                        };
                        newrow.JournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType);

                        newrow.InjectFrom(row);
                        newrow.EntityAccountPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == newrow.Type && x.scope == newrow.Scope &&
                                                         x.Iserial == newrow.Entity);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }
                    Loading         = false;
                    DetailFullCount = sv.fullCount;

                    if (SelectedMainRow.DetailsList.Any() &&
                        (SelectedDetailRow == null))
                    {
                        SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault();
                    }

                    if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                    {
                        AddNewDetailRow(false);
                    }

                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("Users");
                    }
                };

                Glclient.UpdateOrInsertTblPostingProfileDetailsCompleted += (s, x) =>
                {
                    var savedRow = (TblPostingProfileDetailViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                    Loading = false;
                };

                Glclient.DeleteTblPostingProfileDetailCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    Loading = false;
                    var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);
                    if (oldrow != null)
                    {
                        SelectedMainRow.DetailsList.Remove(oldrow);
                    }
                    if (!SelectedMainRow.DetailsList.Any())
                    {
                        AddNewDetailRow(false);
                    }
                };

                GetMaindata();
            }
        }
Exemplo n.º 8
0
        public TradeAgreementViewModel() : base(PermissionItemName.TradeAgreementFabricView)
        {
            // ده هيحتاج تعديل
            productionServiceClient.GetTblTradeAgreementDetailListFabricViewCompleted += (s, sv) =>
            {
                foreach (var row in sv.Result)
                {
                    var newrow = new TradeAgreementDetailModel();
                    newrow.TradeAgreementTransactionIserial = SelectedMainRow.Iserial;
                    newrow.HeaderIserial = row.TblTradeAgreementHeader;
                    newrow.ColorPerRow   = new CRUDManagerService.TblColor();
                    if (row.TblColor1 != null)
                    {
                        newrow.ColorPerRow.InjectFrom(row.TblColor1);
                    }
                    newrow.ItemPerRow = new CRUDManagerService.ItemsDto();
                    newrow.ItemPerRow.InjectFrom(sv.itemsList.SingleOrDefault(x => x.Iserial == row.ItemCode && x.ItemGroup == row.ItemType));
                    newrow.ItemType     = row.ItemType;
                    newrow.VendorPerRow = new CRUDManagerService.Vendor {
                        vendor_code = row.TblTradeAgreementHeader1.Vendor
                    };
                    newrow.VendorPurchaseGroupPerRow = new CRUDManagerService.GenericTable();
                    newrow.VendorPerRow.InjectFrom(sv.VendorList.FirstOrDefault(x => x.vendor_code == row.TblTradeAgreementHeader1.Vendor));
                    if (row.TblVendorPurchaseGroup1 != null)
                    {
                        newrow.VendorPurchaseGroupPerRow.InjectFrom(row.TblVendorPurchaseGroup1);
                    }
                    newrow.TradeAgreementTransactionIserial = row.TblTradeAgreementHeader1.TblTradeAgreementTransaction.Value;
                    newrow.HeaderIserial = row.TblTradeAgreementHeader;
                    newrow.InjectFrom(row);
                    SelectedMainRow.DetailsList.Insert(0, newrow);
                }

                Loading = false;

                if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                {
                    AddNewDetailRow(false);
                }
                if (Export)
                {
                    Export = false;
                    ExportGrid.ExportExcel("TradeAgreement");
                }
            }
            ;
            calculationClient.GetGenericCompleted += (s, sv) =>
            {
                VendorPurchaseGroupList = sv.Result;
            };

            Client.GetAxCurrencyAsync("CCM");
            Client.GetAxCurrencyCompleted += (s, sv) =>
            {
                AxCurrencyList = sv.Result;
            };
            Client.SearchForColorCompleted += (s, sv) =>
            {
                if (sv.Error != null)
                {
                    return;
                }

                SelectedDetailRow.Colors = sv.Result;
            };

            var currentUi = Thread.CurrentThread.CurrentUICulture;

            productionServiceClient.GetTblTradeAgreementDetailListCompleted += (d, sv) =>
            {
                foreach (var row in sv.Result)
                {
                    var newrow = new TradeAgreementDetailModel();
                    newrow.InjectFrom(row);
                    newrow.HeaderIserial = row.TblTradeAgreementHeader;
                    newrow.TradeAgreementTransactionIserial = SelectedMainRow.Iserial;
                    newrow.ColorPerRow = new CRUDManagerService.TblColor();
                    if (row.TblColor1 != null)
                    {
                        newrow.ColorPerRow.InjectFrom(row.TblColor1);
                    }
                    newrow.TblColor   = row.TblColor;
                    newrow.ItemPerRow = new CRUDManagerService.ItemsDto();
                    var itemsDto = sv.itemsList.SingleOrDefault(x => x.Iserial == row.ItemCode && x.ItemGroup == row.ItemType);
                    if (itemsDto != null)
                    {
                        newrow.ItemPerRow.InjectFrom(itemsDto);
                    }
                    newrow.ItemCode = row.ItemCode;
                    newrow.ItemType = row.ItemType;
                    newrow.FromDate = row.TblTradeAgreementHeader1.FromDate;
                    newrow.ToDate   = row.TblTradeAgreementHeader1.ToDate;
                    newrow.VendorPurchaseGroupPerRow = VendorPurchaseGroupList.FirstOrDefault(vpg => vpg.Iserial == newrow.TblVendorPurchaseGroup);
                    newrow.VendorPerRow = new CRUDManagerService.Vendor();
                    newrow.VendorPerRow.InjectFrom(sv.vendorsList.FirstOrDefault(v => v.vendor_code == row.TblTradeAgreementHeader1.Vendor));
                    newrow.Vendor = row.TblTradeAgreementHeader1.Vendor;
                    SelectedMainRow.DetailsList.Add(newrow);
                }

                Loading         = false;
                DetailFullCount = sv.fullCount;
                if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0)
                {
                    AddNewDetailRow(false);
                }
            };

            productionServiceClient.UpdateOrInsertTblTradeAgreementDetailCompleted += (s, x) =>
            {
                var savedRow = SelectedMainRow.DetailsList.ElementAtOrDefault(x.outindex);

                if (savedRow != null)
                {
                    savedRow.InjectFrom(x.Result);
                }
            };

            productionServiceClient.GetTblTradeAgreementTransactionCompleted += (d, s) =>
            {
                foreach (var variable in s.Result)
                {
                    var newrow = new TradeAgreementTransaction();
                    newrow.InjectFrom(variable);
                    MainRowList.Add(newrow);
                }
                Loading   = false;
                FullCount = s.fullCount;
                if (SearchWindow != null)
                {
                    SearchWindow.FullCount = s.fullCount;
                    SearchWindow.Loading   = false;
                }
                if (FullCount == 0 && MainRowList.Count == 0)
                {
                    AddNewMainRow(true);
                }
            };

            productionServiceClient.DeleteTblTradeAgreementDetailCompleted += (s, ev) =>
            {
                Loading = false;
                if (ev.Error != null)
                {
                    throw ev.Error;
                }

                var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result);

                if (oldrow != null)
                {
                    SelectedMainRow.DetailsList.Remove(oldrow);
                }
            };

            productionServiceClient.SaveTradeAgreementCompleted += (s, sv) =>
            {
                if (SelectedMainRow == null)
                {
                    SelectedMainRow = new TradeAgreementTransaction();
                }
                SelectedMainRow.InjectFrom(sv.savedHeader);
                SelectedMainRow.TblLkpSeason  = sv.savedHeader.TblLkpSeason;
                SelectedMainRow.TblLkpSeason1 = SeasonList.FirstOrDefault(r => r.Iserial == SelectedMainRow.TblLkpSeason);
                //SelectedMainRow.DetailsList.Clear();
                foreach (var item in SelectedMainRow.DetailsList)
                {
                    var newRow = sv.Result.FirstOrDefault(d => d.ItemCode == item.ItemCode && d.TblColor == item.TblColor &&
                                                          d.TblTradeAgreementHeader == item.HeaderIserial && d.AccSize == item.AccSize);
                    if (newRow != null)
                    {
                        item.Iserial       = newRow.Iserial;
                        item.HeaderIserial = newRow.TblTradeAgreementHeader;
                        item.TradeAgreementTransactionIserial = newRow.TblTradeAgreementHeader1.TblTradeAgreementTransaction.Value;
                    }
                }
                RaisePropertyChanged(nameof(IsHeaderSaved));
                MessageBox.Show(strings.Saved);
                Loading = true;
            };
            productionServiceClient.DeleteTradeAgreementHeaderCompleted += (d, s) =>
            {
                SelectedMainRow = new TradeAgreementTransaction();

                if (currentUi.DisplayName == "العربية")
                {
                    MessageBox.Show("Deleted");
                }
                else
                {
                    MessageBox.Show("Deleted");
                }
            };
            // ده هيحتاج تعديل
            LoadingDetail = new RelayCommand <DataGridRowEventArgs>((e) =>
            {
                if (SelectedMainRow.DetailsList.Count < PageSize)
                {
                    return;
                }
                if (SelectedMainRow.DetailsList.Count - 2 < e.Row.GetIndex() && SelectedMainRow.DetailsList.Count < DetailFullCount &&
                    !Loading)
                {
                    string size = null, vendor = null, color = null, ItemType = null, ItemCode = null;
                    string key  = "AccSize";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        size = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }
                    key = "Vendor";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        vendor = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }

                    key = "Color";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        color = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }
                    key = "ItemType";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        ItemType = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                    }
                    key = "ItemCode";
                    if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                    {
                        ItemCode = Convert.ToString(valueObjecttemp.First(w => w.Key.StartsWith(key)).Value);
                    }
                    productionServiceClient.GetTblTradeAgreementDetailListFabricViewAsync(
                        SelectedMainRow.DetailsList.Count, PageSize, SelectedMainRow.Iserial, ItemCode,
                        color, size, vendor, ItemType);
                }
            });
            // ده هيحتاج تعديل
            FilterCommand = new RelayCommand <FilterEvent>((e) =>
            {
                SelectedMainRow.DetailsList.Clear();

                valueObjecttemp.Clear();

                foreach (var f in e.FiltersPredicate)
                {
                    valueObjecttemp.Add(f.FilterColumnInfo.PropertyPath, f.FilterText);
                }

                string size = null, vendor = null, color = null, ItemType = null, ItemCode = null;
                string key  = "AccSize";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    size = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }
                key = "Vendor";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    vendor = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }

                key = "Color";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    color = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }
                key = "ItemType";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    ItemType = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value;
                }
                key = "ItemCode";
                if (valueObjecttemp.Any(w => w.Key.StartsWith(key)))
                {
                    ItemCode = Convert.ToString(valueObjecttemp.First(w => w.Key.StartsWith(key)).Value);
                }
                productionServiceClient.GetTblTradeAgreementDetailListFabricViewAsync(
                    0, PageSize, SelectedMainRow.Iserial, ItemCode, color, size, vendor, ItemType);
            });
            NewDetail = new RelayCommand <KeyEventArgs>((e) =>
            {
                if (e.Key == Key.Down)
                {
                    //var currentRowIndex = (SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow));
                    //if (currentRowIndex == (SelectedMainRow.DetailsList.Count - 1))
                    //{
                    //    AddNewDetailRow(true);
                    //}
                }
            });
            DeleteDetail = new RelayCommand <KeyEventArgs>((e) =>
            {
                if (e.Key == Key.Delete)
                {
                    var DetailGrid = e.OriginalSource as OsGrid;
                    SelectedDetailRows.Clear();
                    foreach (var row in DetailGrid.SelectedItems)
                    {
                        SelectedDetailRows.Add(row as TradeAgreementDetailModel);
                    }
                    DeleteDetailRow();
                }
            });
            SaveDetail = new RelayCommand <DataGridRowEditEndedEventArgs>((e) => { SaveDetailRow(); });
            Client.GetAllSeasonsCompleted += (s, e) =>
            {
                SeasonList.Clear();
                foreach (var row in e.Result)
                {
                    TblLkpSeason temp = new TblLkpSeason();
                    temp.InjectFrom(row);
                    SeasonList.Add(temp);
                }
            };

            AddNewMainRow(false);
            GetComboData();
            GetMaindata();
        }
Exemplo n.º 9
0
        public VisaMachineViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.VisaMachineForm.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblVisaMachineViewModel>();
                SelectedMainRow = new TblVisaMachineViewModel();


                if (MainRowList.Any() && (SelectedMainRow == null))
                {
                    SelectedMainRow = MainRowList.FirstOrDefault();
                }

                Glclient.GetTblVisaMachineCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblVisaMachineViewModel();
                        newrow.TblbankPerRow = new TblBank();
                        newrow.InjectFrom(row);

                        if (row.TblBank1 != null)
                        {
                            newrow.TblbankPerRow.InjectFrom(row.TblBank1);
                        }

                        newrow.JournalAccountTypePerRow = new GlService.GenericTable();
                        if (newrow.TblJournalAccountType.HasValue)
                        {
                            newrow.JournalAccountTypePerRow =
                                JournalAccountTypeList.FirstOrDefault(jAT => jAT.Iserial == newrow.TblJournalAccountType.Value);
                        }

                        var entity = sv.EntityAccounts.FirstOrDefault(x => x.TblJournalAccountType == newrow.TblJournalAccountType &&
                                                                      x.Iserial == row.EntityAccount);
                        if (entity != null)
                        {
                            newrow.EntityPerRow.InjectFrom(entity); newrow.RaiseEntityChanged();
                        }


                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("VisaMachines");
                    }
                };

                Glclient.UpdateOrInsertTblVisaMachineCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblVisaMachineCompleted += (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);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                Glclient.GetVisaMachineBanksCompleted += (s, sv) =>
                {
                    BankList = sv.Result;
                };

                Glclient.GetVisaMachineBanksAsync(LoggedUserInfo.DatabasEname);

                GetMaindata();
            }
        }
Exemplo n.º 10
0
        public JournalViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.Journal.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblJournalViewModel>();
                SelectedMainRow = new TblJournalViewModel();

                var currencyClient = new GlServiceClient();
                currencyClient.GetGenericCompleted += (s, sv) =>
                {
                    CurrencyList = sv.Result;
                };
                currencyClient.GetGenericAsync("TblCurrency", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

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

                var journalTypeClient = new GlServiceClient();
                journalTypeClient.GetGenericCompleted += (s, sv) =>
                {
                    JournalTypeList = sv.Result;
                };
                journalTypeClient.GetGenericAsync("TblJournalType", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);
                Glclient.GetTblJournalCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblJournalViewModel();
                        newrow.InjectFrom(row);

                        newrow.JournalAccountTypePerRow = new GenericTable();
                        if (row.TblJournalAccountType1 != null)
                        {
                            newrow.JournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType1);
                        }
                        newrow.JournalTypePerRow = new GenericTable();
                        newrow.JournalTypePerRow.InjectFrom(row.TblJournalType1);
                        newrow.CurrencyPerRow = new GenericTable();
                        newrow.CurrencyPerRow.InjectFrom(row.TblCurrency1);

                        newrow.HeaderSequencePerRow      = row.TblSequence;
                        newrow.DetailSequencePerRow      = row.TblSequence1;
                        newrow.OffsetEntityAccountPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == row.TblJournalAccountType && x.Iserial == row.Entity);

                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("Journal");
                    }
                };

                Glclient.UpdateOrInsertTblJournalsCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                    Loading = false;
                };
                Glclient.DeleteTblJournalCompleted += (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);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                GetMaindata();
            }
        }
Exemplo n.º 11
0
        public BankTransactionTypeViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.BankTransactionType.ToString());
                Glclient = new GlServiceClient();

                var currencyClient = new GlServiceClient();
                currencyClient.GetGenericCompleted += (s, sv) => { BankTransactionTypeGroupList = sv.Result; };
                currencyClient.GetGenericAsync("TblBankTransactionTypeGroup", "%%", "%%", "%%", "Iserial", "ASC", LoggedUserInfo.DatabasEname);

                MainRowList     = new SortableCollectionView <TblBankTransactionTypeViewModel>();
                SelectedMainRow = new TblBankTransactionTypeViewModel();

                Glclient.GetTblBankTransactionTypeCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblBankTransactionTypeViewModel
                        {
                            BankTransactionTypeGroupPerRow = new GenericTable()
                        };
                        newrow.InjectFrom(row);
                        if (row.TblBankTransactionTypeGroup1 != null)
                        {
                            newrow.BankTransactionTypeGroupPerRow.InjectFrom(row.TblBankTransactionTypeGroup1);
                        }
                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any())
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("BankTransactionType");
                    }
                };

                Glclient.UpdateOrInsertTblBankTransactionTypesCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblBankTransactionTypeCompleted += (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);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                GetMaindata();
            }
        }
Exemplo n.º 12
0
        public SalesOrderColorThemeViewModel()
        {
            if (!DesignerProperties.IsInDesignTool)
            {
                GetItemPermissions(PermissionItemName.ColorThemesForm.ToString());

                lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) =>
                {
                    BrandSectionList.Clear();
                    foreach (var row in sv.Result)
                    {
                        BrandSectionList.Add(new GenericTable().InjectFrom(row.TblLkpBrandSection1) as GenericTable);
                    }
                };
                var seasonClient = new CRUD_ManagerServiceClient();
                seasonClient.GetGenericCompleted += (s, sv) =>
                {
                    SeasonList = sv.Result;
                };
                seasonClient.GetGenericAsync("TblLkpSeason", "%%", "%%", "%%", "Iserial", "ASC");

                MainRowList = new SortableCollectionView <TblSalesOrderColorThemeViewModel>();
                MainRowList.CollectionChanged += MainRowList_CollectionChanged;
                SelectedMainRow = new TblSalesOrderColorThemeViewModel();


                Client.GetAllBrandsCompleted += (s, sv) =>
                {
                    BrandList = sv.Result;
                };
                Client.GetAllBrandsAsync(LoggedUserInfo.Iserial);

                Client.GetTblSalesOrderColorThemeCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblSalesOrderColorThemeViewModel();
                        newrow.InjectFrom(row);
                        MainRowList.Add(newrow);
                    }
                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }

                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }

                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("Style");
                    }
                };

                Client.UpdateOrInsertTblSalesOrderColorThemeCompleted += (s, x) =>
                {
                    var savedRow = (TblSalesOrderColorThemeViewModel)MainRowList.GetItemAt(x.outindex);

                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                };

                Client.DeleteTblSalesOrderColorThemeCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        throw ev.Error;
                    }

                    var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial);
                    if (oldrow != null)
                    {
                        MainRowList.Remove(oldrow);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                //   Client.GetSeasonalMasterListNotLinkedToSalesorder
            }
        }
Exemplo n.º 13
0
        public CashDepositeTypeViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.CashdepositeTypeForm.ToString());
                Glclient        = new GlServiceClient();
                MainRowList     = new SortableCollectionView <TblCashDepositeTypeViewModel>();
                SelectedMainRow = new TblCashDepositeTypeViewModel();


                if (MainRowList.Any() && (SelectedMainRow == null))
                {
                    SelectedMainRow = MainRowList.FirstOrDefault();
                }

                //if (FullCount == 0 && MainRowList.Count == 0)
                //{
                //    AddNewMainRow(false);
                //}

                Glclient.GetTblCashDepositTypeCompleted += (s, sv) =>
                {
                    CashDepositTypeList = sv.Result;
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblCashDepositeTypeViewModel();
                        newrow.TblSequencePerRow       = new GenericTable();
                        newrow.DepositeTypeGroupPerRow = new GenericTable();
                        newrow.InjectFrom(row);

                        if (row.TblSequence1 != null)
                        {
                            newrow.TblSequencePerRow.InjectFrom(row.TblSequence1);
                        }
                        if (row.DepositeTypeGroup != null && row.DepositeTypeGroup != 0)
                        {
                            newrow.DepositeTypeGroupPerRow.InjectFrom(CashDepositTypeList.FirstOrDefault(x => x.Iserial == newrow.DepositeTypeGroup));
                        }

                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export = false;
                        ExportGrid.ExportExcel("CashDepositeType");
                    }
                };

                Glclient.UpdateOrInsertTblCashDepositTypeCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                };
                Glclient.DeleteTblCashDepositTypesCompleted += (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);
                    }
                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                Glclient.GetCashDepositeSequenceCompleted += (s, sv) =>
                {
                    SequenceList = sv.Result;
                };

                Glclient.GetCashDepositeSequenceAsync(LoggedUserInfo.DatabasEname);

                GetMaindata();
            }
        }
Exemplo n.º 14
0
        public GenericViewModelCollection(string tablEname, PermissionItemName userJobsForm)
        {
            if (DesignerProperties.IsInDesignTool)
            {
                return;
            }
            TablEname = tablEname;
            Client    = new _Proxy.CRUD_ManagerServiceClient();
            GetItemPermissions(userJobsForm.ToString());

            Client.GetGenericCompleted += (s, ev) =>
            {
                Loading = false;
                GenericMapper.InjectFromObCollection(MainRowList, ev.Result);
                //FullCount = ev.fullCount;
                if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0))
                {
                    SelectedMainRow = MainRowList.FirstOrDefault();
                }
                if (FullCount == 0 && MainRowList.Count == 0)
                {
                    AddNewMainRow(false);
                }

                if (Export)
                {
                    Export = false;
                    ExportGrid.ExportExcel(userJobsForm.ToString());
                }
            };

            MainRowList = new SortableCollectionView <GenericViewModel>();

            Client.GenericUpdateOrInsertCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                Loading = false;
                MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
            };

            Client.DeleteGenericCompleted += (s, ev) =>
            {
                if (ev.Error != null)
                {
                    MessageBox.Show(ev.Error.Message);
                }
                Loading = false;
                var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result);
                if (oldrow != null)
                {
                    MainRowList.Remove(oldrow);
                }
                if (!MainRowList.Any())
                {
                    AddNewMainRow(false);
                }
            };
            GetMaindata();
        }
Exemplo n.º 15
0
        public JournalSettingViewModel()
        {
            if (!IsDesignTime)
            {
                GetItemPermissions(PermissionItemName.JournalSetting.ToString());
                Glclient = new GlServiceClient();

                MainRowList     = new ObservableCollection <TblJournalSettingViewModel>();
                SelectedMainRow = new TblJournalSettingViewModel();

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


                Glclient.GetTblJournalSettingCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblJournalSettingViewModel();
                        newrow.InjectFrom(row);

                        MainRowList.Add(newrow);
                    }

                    Loading   = false;
                    FullCount = sv.fullCount;
                    if (MainRowList.Any() && (SelectedMainRow == null))
                    {
                        SelectedMainRow = MainRowList.FirstOrDefault();
                    }
                    if (FullCount == 0 && MainRowList.Count == 0)
                    {
                        AddNewMainRow(false);
                    }
                    if (Export)
                    {
                        Export      = false;
                        AllowExport = true;
                        //ExportGrid.ExportExcel("Account");
                    }
                };

                Glclient.UpdateOrInsertTblJournalSettingsCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    try
                    {
                        MainRowList.ElementAt(ev.outindex).InjectFrom(ev.Result);
                    }
                    catch (Exception)
                    {
                    }
                    Loading = false;
                };
                Glclient.DeleteTblJournalSettingCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    foreach (var item in ev.Result.ToList())
                    {
                        var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == item);
                        if (oldrow != null)
                        {
                            MainRowList.Remove(oldrow);
                        }
                    }

                    if (!MainRowList.Any())
                    {
                        AddNewMainRow(false);
                    }
                };

                Glclient.GetTblJournalSettingEntityCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblJournalSettingEntityViewModel();
                        newrow.JournalAccountTypePerRow = new GenericTable();
                        newrow.JournalAccountTypePerRow.InjectFrom(row.TblJournalAccountType1);

                        newrow.JournalPerRow = new TblJournal();
                        newrow.JournalPerRow.InjectFrom(row.TblJournal1);
                        newrow.EntityPerRow =
                            sv.entityList.FirstOrDefault(x => x.TblJournalAccountType == row.TblJournalAccountType &&
                                                         x.Iserial == row.EntityAccount && x.scope == row.Scope);
                        newrow.InjectFrom(row);
                        SelectedMainRow.DetailsList.Add(newrow);
                    }
                    Loading         = false;
                    DetailFullCount = sv.fullCount;
                    if (SelectedMainRow.DetailsList.Any() && (SelectedDetailRow == null))
                    {
                        SelectedDetailRow = SelectedMainRow.DetailsList.FirstOrDefault();
                    }

                    if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count(x => x.Iserial >= 0) == 0)
                    {
                        AddNewDetailRow(false);
                    }

                    if (Export)
                    {
                        AllowExport = true;
                        Export      = false;
                    }
                };

                Glclient.UpdateOrInsertTblJournalSettingEntitysCompleted += (s, x) =>
                {
                    var savedRow = SelectedMainRow.DetailsList.ElementAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                    Loading = false;
                };

                Glclient.DeleteTblJournalSettingEntityCompleted += (s, ev) =>
                {
                    Loading = false;

                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    foreach (var item in ev.Result.ToList())
                    {
                        var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == item);
                        if (oldrow != null)
                        {
                            SelectedMainRow.DetailsList.Remove(oldrow);
                        }
                    }
                    if (!SelectedMainRow.DetailsList.Any())
                    {
                        AddNewDetailRow(false);
                    }
                };

                var glRuleTypeClient = new GlServiceClient();
                glRuleTypeClient.GetGenericCompleted += (s, sv) => { CostCenterTypeList = sv.Result; };
                glRuleTypeClient.GetGenericAsync("TblCostCenterType", "%%", "%%", "%%", "Iserial", "ASC",
                                                 LoggedUserInfo.DatabasEname);

                Glclient.GetTblJournalSettingCostCenterCompleted += (s, sv) =>
                {
                    foreach (var row in sv.Result)
                    {
                        var newrow = new TblJournalSettingCostCenterViewModel();
                        if (row.TblCostCenter1 != null)
                        {
                            newrow.CostCenterPerRow = new TblCostCenter();
                            newrow.CostCenterPerRow.InjectFrom(row.TblCostCenter1);

                            if (row.TblCostCenter1.TblCostCenterType1 != null)
                            {
                                newrow.CostCenterTypePerRow.InjectFrom(row.TblCostCenter1.TblCostCenterType1);
                            }
                        }


                        newrow.InjectFrom(row);

                        SelectedMainRow.SubDetailList.Add(newrow);
                    }
                    Loading            = false;
                    DetailSubFullCount = sv.fullCount;

                    if (SelectedMainRow.SubDetailList.Any() &&
                        (SelectedSubDetailRow == null))
                    {
                        SelectedSubDetailRow = SelectedMainRow.SubDetailList.FirstOrDefault();
                    }

                    if (DetailSubFullCount == 0 && SelectedMainRow.SubDetailList.Count(x => x.Iserial >= 0) == 0)
                    {
                        AddNewSubDetailRow(false);
                    }
                    if (ExportGrid != null)
                    {
                        ExportGrid.ScrollIntoView(SelectedSubDetailRow, ExportGrid.Columns[1]);
                        ExportGrid.CurrentColumn = ExportGrid.Columns[1];
                        ExportGrid.Focus();
                    }
                };

                Glclient.UpdateOrInsertTblJournalSettingCostCentersCompleted += (s, x) =>
                {
                    var savedRow = SelectedMainRow.SubDetailList.ElementAt(x.outindex);
                    if (savedRow != null)
                    {
                        savedRow.InjectFrom(x.Result);
                    }
                    Loading = false;
                };

                Glclient.DeleteTblJournalSettingCostCenterCompleted += (s, ev) =>
                {
                    if (ev.Error != null)
                    {
                        MessageBox.Show(ev.Error.Message);
                    }
                    foreach (var item in ev.Result.ToList())
                    {
                        var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == item);
                        if (oldrow != null)
                        {
                            SelectedMainRow.DetailsList.Remove(oldrow);
                        }
                    }
                    if (!SelectedMainRow.SubDetailList.Any())
                    {
                        AddNewSubDetailRow(false);
                    }
                };

                GetMaindata();
            }
        }