コード例 #1
0
ファイル: EditInsertLookups.xaml.cs プロジェクト: TataDvd/Git
        public EditInsertLookups()
        {
            LookupsEdidViewModels vm = new LookupsEdidViewModels();

            InitializeComponent();
            this.DataContext = vm;
        }
コード例 #2
0
ファイル: EditInsertLookups.xaml.cs プロジェクト: TataDvd/Git
        public EditInsertLookups(LookupsEdidViewModels vm)
        {
            InitializeComponent();
            this.DataContext = vm;
            TraversalRequest request = new TraversalRequest(FocusNavigationDirection.First);

            MoveFocus(request);
        }
コード例 #3
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var Context = new TempoDataBaseContext();
            var sen     = (sender as Button);

            if (sen != null)
            {
                var cp = sen.CommandParameter as SaldoItem;
                if (cp != null && (cp.Relookup != 0 || cp.RCODELOOKUP != 0))
                {
                    List <FieldValuePair> current = new List <FieldValuePair>();
                    LookupModel           lookup  = null;
                    if (cp.Relookup > 0)
                    {
                        lookup = cp.SysLookup ? Context.GetSysLookup(cp.Relookup) : Context.GetLookup(cp.Relookup);
                    }
                    else
                    {
                        lookup = cp.SysLookup ? Context.GetSysLookup(cp.Relookup) : Context.GetLookup(cp.Relookup);
                    }
                    int i = 0;
                    foreach (var item in lookup.Fields)
                    {
                        if (cp.SysLookup && i == 0)
                        {
                            i++;
                            continue;
                        }
                        current.Add(new FieldValuePair
                        {
                            Name       = item.Name,
                            Value      = "",
                            Length     = item.Length,
                            ReadOnly   = (item.NameEng == "Id") ? false : true,
                            IsRequared = item.IsRequared,
                            IsUnique   = item.IsUnique,
                            RTABLENAME = item.RTABLENAME,
                            FieldName  = item.NameEng
                        });
                    }

                    LookupsEdidViewModels vmm = new LookupsEdidViewModels(current, lookup.LookUpMetaData.Tablename, true);
                    EditInsertLookups     ds  = new EditInsertLookups(vmm);
                    ds.ShowDialog();
                    if (ds.DialogResult.HasValue && ds.DialogResult.Value)
                    {
                        //nov red
                        lookup.Fields.Add(new TableField {
                            DbField = "integer", GROUP = 4, Id = 4, Length = 4, IsRequared = false, NameEng = "FIRMAID", Name = "Фирма Номер"
                        });
                        if (!Context.SaveRow(ds.GetNewFields(), lookup, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id))
                        {
                            MessageBoxWrapper.Show("Получвава се дублиране на елемент от номенклатура! Номенклатурата не е записана!");
                        }
                        else
                        {
                            var dc  = DataContext as SaldoItem;
                            var dat = ds.GetNewFields();
                            if (dat != null)
                            {
                                if (dc != null)
                                {
                                    dc.Value     = dat[1];
                                    dc.Lookupval = dat[2];
                                }
                            }
                            if (dat != null && dat.Count > 5)
                            {
                                if (dc != null)
                                {
                                    dc.Bulstad = dat[3];
                                    dc.Vat     = dat[4];
                                }
                            }
                            OnRefreshExecuted(new FastLookupEventArgs(dc));
                        }
                    }
                    //cp.LookUp.Add(new SaldoItem { Value = ds.GetNewFields()[2], Key = ds.GetNewFields()[1] });
                }
            }
        }
コード例 #4
0
        private void Calculate()
        {
            var Context = new TempoDataBaseContext();
            var cp      = this.DataContext as SaldoItem;

            if (cp != null && (cp.Relookup != 0 || cp.RCODELOOKUP != 0))
            {
                string search = Entrence.ConfigFirmaToLookup.GetField(ConfigTempoSinglenton.GetInstance().CurrentFirma.Id,
                                                                      cp.Relookup);
                List <FieldValuePair> current = new List <FieldValuePair>();
                LookupModel           lookup  = null;
                if (cp.Relookup > 0)
                {
                    lookup = cp.SysLookup ? Context.GetSysLookup(cp.Relookup):Context.GetLookup(cp.Relookup);
                }
                else
                {
                    lookup = cp.SysLookup ? Context.GetSysLookup(cp.Relookup) : Context.GetLookup(cp.Relookup);
                }
                int i = 0;
                foreach (var item in lookup.Fields)
                {
                    if (cp.SysLookup && i == 0)
                    {
                        i++;
                        continue;
                    }
                    var nf = new FieldValuePair
                    {
                        Name       = item.Name,
                        Length     = item.Length,
                        Value      = i == 1 && string.IsNullOrWhiteSpace(search)?searcher.Text:"",
                        ReadOnly   = item.NameEng != "Id",
                        IsRequared = item.IsRequared,
                        IsUnique   = item.IsUnique,
                        RTABLENAME = item.RTABLENAME,
                        FieldName  = item.NameEng
                    };

                    if (item.NameEng == search)
                    {
                        nf.Value = searcher.Text;
                    }
                    current.Add(nf);
                }

                LookupsEdidViewModels vmm = new LookupsEdidViewModels(current, lookup.LookUpMetaData.Tablename, true);
                EditInsertLookups     ds  = new EditInsertLookups(vmm);
                ds.ShowDialog();
                if (ds.DialogResult.HasValue && ds.DialogResult.Value)
                {
                    //nov red
                    if (!cp.SysLookup)
                    {
                        lookup.Fields.Add(new TableField
                        {
                            DbField    = "integer",
                            GROUP      = 4,
                            Id         = 4,
                            Length     = 4,
                            IsRequared = false,
                            NameEng    = "FIRMAID",
                            Name       = "Фирма Номер"
                        });
                    }
                    bool sys = cp.SysLookup?!Context.SaveRow(ds.GetNewFields(), lookup):!Context.SaveRow(ds.GetNewFields(), lookup, ConfigTempoSinglenton.GetInstance().CurrentFirma.Id);
                    if (sys)
                    {
                        MessageBoxWrapper.Show(
                            "Получвава се дублиране на елемент от номенклатура! Номенклатурата не е записана!");
                    }
                    else
                    {
                        var dc  = DataContext as SaldoItem;
                        var dat = ds.GetNewFields();
                        if (dat != null)
                        {
                            dc.Value     = dat[1];
                            dc.Lookupval = dat[2];
                        }
                        if (dat != null && dat.Count > 5)
                        {
                            dc.Bulstad = dat[3];
                            dc.Vat     = dat[4];
                        }
                        dc.LiD = 0;
                        OnRefreshExecuted(new FastLookupEventArgs(dc));
                    }
                }
                //cp.LookUp.Add(new SaldoItem { Value = ds.GetNewFields()[2], Key = ds.GetNewFields()[1] });
            }
        }