Example #1
0
        private void DG_Show_Add(object sender, MouseButtonEventArgs e)
        {
            if (DG.SelectedIndex == -1)
            {
                return;
            }
            var elem = (DG.Items[DG.SelectedIndex] as ThisShow);

            if (elem.NegotiationAssistandID > 0)
            {
                MyTools.DeleteRowsByID(G.NegotiationAssistant, false, elem.NegotiationAssistandID);
                elem.NegotiationAssistandID = 0;
            }
            else
            {
                elem.NegotiationAssistandID = MyTools.AddRowFromTable(true, G.NegotiationAssistant,
                                                                      new KeyValuePair <int, object>(C.NegotiationAssistant.Objecte, elem.ID),
                                                                      new KeyValuePair <int, object>(C.NegotiationAssistant.YM, DateControl_Class.SelectMonth));
            }
            DataGridRow row = (DataGridRow)DG.ItemContainerGenerator.ContainerFromIndex(DG.SelectedIndex);

            row.Background   = (DG.Items[row.GetIndex()] as ThisShow).NegotiationAssistandID > 0 ? Brushes.Green : Brushes.White;
            DG.SelectedIndex = DG.SelectedIndex + (DG.SelectedIndex != DG.Items.Count - 1 ? 1 : -1);
            text.Text        = $"План: {Values.Where(x => (x as ThisShow).NegotiationAssistandID > 0).Count()}";
        }
        void Act_Click(object sender, RoutedEventArgs e)
        {
            var _querry = G.Volume.QUERRY()
            .SHOW
            .WHERE
            .C(C.Volume.Sample, selectionWell.SampleID);
            _querry.DO();

            if (G.Volume.Rows.Count > 0)
            {
                SearchGrid_Window sg = new SearchGrid_Window(G.Volume, null, null, new C_SettingSearchDataGrid(DefDeleg: true));
                sg.ShowDialog();

                if (sg.SelectID > 0)
                {
                    var table = T.NormDoc.CreateSubTable();

                    table.QUERRY().SHOW.WHERE.ARC(C.NormDoc.Volume, C.Volume.Sample).EQUI.BV(selectionWell.SampleID).DO();

                    MyTools.AddRowFromTable(table, new KeyValuePair<int, object>(C.NormDoc.Volume, sg.SelectID));
                }

                LoadAct();
            }
            else
            { MessageBox.Show("Объёмы не указаны"); }
        }
Example #3
0
        public override bool StartLoad()
        {
            int    num    = 0;
            double volume = 0;

            foreach (var file in _files.ToArray())
            {
                if (file.objecte == null)
                {
                    continue;
                }

                if (file.sample == null)
                {
                    if (file.Volume > 0)
                    {
                        _files.Remove(file);
                    }

                    continue;
                }

                if (file.period != null)
                {
                    if (_volumes.FirstOrDefault(x => x.SampleID == file.sample.ID && x.PeriodID == file.period.ID) != null)
                    {
                        G.Volume.QUERRY()
                        .SET
                        .C(C.Volume.Value, file.Volume)
                        .WHERE
                        .ID(_volumes.First(x => x.SampleID == file.sample.ID).ID)
                        .DO();
                    }
                    else
                    {
                        MyTools.AddRowFromTable(G.Volume,
                                                new KeyValuePair <int, object>(C.Volume.Sample, file.sample.ID),
                                                new KeyValuePair <int, object>(C.Volume.Period, file.period == null ? AdditionnTable.ListPeriod.Last(x => x.YM < date).ID : file.period.ID),
                                                new KeyValuePair <int, object>(C.Volume.Value, file.Volume));
                    }

                    _files.Remove(file);
                    num++;
                    volume += file.Volume;
                }
            }

            if (num > 0)
            {
                MessageBox.Show($"Выгружено записей: {num} на объём: {volume}");
                ResetDG();
                return(true);
            }
            else
            {
                MessageBox.Show($"Ничего выгрузить не удалось =(");
                return(false);
            }
        }
        private void LoadAct()
        {
            ShowAct.Children.Clear();
            ShowAct.RowDefinitions.Clear();
            ShowAct.ColumnDefinitions.Clear();
            ShowAct.SetRowFromGrid(MyTools.GL_Auto);
            Button add = new Button {
                Content = "Добавить акт"
            };
            //var samples = Values.Select(x => Logic.LogicInstances.SampleLogic.FirstOrDefault(x.SampleID)).ToArray();\
            var samples = selectionWell.Sample.SelectionWells.ToArray();

            add.Click += (sender, e) =>
            {
                var _querry = G.Volume.QUERRY()
                              .SHOW
                              .WHERE
                              .C(C.Volume.Sample, samples.First().ID);
                for (int i = 1; i < samples.Length; i++)
                {
                    _querry.OR.C(C.Volume.Sample, samples[i].ID);
                }
                _querry.DO();
                SearchGrid_Window sg = new SearchGrid_Window(G.Volume, null, null, new C_SettingSearchDataGrid(DefDeleg: true));
                sg.ShowDialog();
                if (sg.SelectID > 0)
                {
                    MyTools.AddRowFromTable(G.NormDoc, new KeyValuePair <int, object>(C.NormDoc.Volume, sg.SelectID));
                }
                LoadAct();
            };
            ShowAct.SetFromGrid(add);
            if (samples.Any())
            {
                var querry = G.NormDoc.QUERRY()
                             .SHOW
                             .WHERE
                             .ARC(C.NormDoc.Volume, C.Volume.Sample, C.Sample.YM).EQUI.BV(DateControl_Class.SelectMonth);
                querry.AND.OB().ARC(C.NormDoc.Volume, C.Volume.Sample).EQUI.BV(samples.First().ID);
                for (int i = 1; i < samples.Length; i++)
                {
                    querry.OR.ARC(C.NormDoc.Volume, C.Volume.Sample).EQUI.BV(samples[i].ID);
                }
                querry.DO();

                List <NormDoc> normDocs = new List <NormDoc>();
                int            count    = G.NormDoc.Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    ShowAct.SetRowFromGrid(MyTools.GL_Auto);
                    normDocs.Add(Logic.LogicInstances.NormDocLogic.FirstOrDefault(G.NormDoc.Rows.GetID(i)));
                    ShowAct.SetFromGrid(normDocs.Last().GetEditor(new MyTools.C_SettingFromRowEdit(MyTools.EPosition.Vertical)));
                }
            }
        }
        private void ClientsObjects_Click(object sender, RoutedEventArgs e)
        {
            var objs = Helpers.LogicHelper.ObjecteLogic.Find(DateControl_Class.SelectMonth).ToArray();

            foreach (var objecte in objs)
            {
                objecte.InitializeColumns();
            }

            SG = new SearchGrid_Window(objs
                                       , new C_SettingSearchDataGrid(ThisDelegate: MouseDoubleClick
                                                                     , ColorConditions: new ColorCondition(column.DateClose
                                                                                                           , (text) => text.TryParseInt() > 0 && text.TryParseInt() <= DateControl_Class.SelectMonth
                                                                                                           , Brushes.Red)
                                                                     , DopText: $"Последний номер папки: {G.Objecte.QUERRY().GET.C(C.Objecte.NumberFolder).Max(C.Objecte.NumberFolder).By(C.Objecte.NumberFolder).DO()[0].Value}"));

            {
                var MiAdd = new MenuItem();
                MiAdd.Header = "Добавить";
                MiAdd.Click += (senderAdd, eAdd) =>
                {
                    G.Client.QUERRY().SHOW.WHERE.AC(C.Client.INN).EQUI.BV("000").DO();
                    uint clientID;

                    if (G.Client.Rows.Count == 0)
                    {
                        clientID = MyTools.AddRowFromTable(G.Client, new KeyValuePair <int, object>(C.Client.INN, "000"), new KeyValuePair <int, object>(C.Client.YMFrom, DateControl_Class.SelectMonth - 1));
                    }
                    else
                    {
                        clientID = G.Client.Rows.GetID(0);
                    }

                    SG.SelectWindowSearth(new Client_Window(clientID));

                    SG.ReSet(Helpers.LogicHelper.ClientsLogic.Find(DateControl_Class.SelectMonth).ToArray());
                };
                SG.ThisMenu.Items.Add(MiAdd);
            }

            {
                var btShowAll = new Button {
                    Content = "Показать все"
                };
                btShowAll.Click += (senderS, eS) =>
                {
                    SG.ReSet(Helpers.LogicHelper.ClientsLogic.Find(DateControl_Class.SelectMonth).ToArray());
                    btShowAll.IsEnabled = false;
                };
                SG.ThisMenu.Items.Add(btShowAll);
            }

            this.SelectWindowSearth(SG);
        }
 private void SetWellSampleNumber(Well well, int number)
 {
     if (negotiationAssistant.SampleID == 0)
     {
         negotiationAssistant.SampleID = MyTools.AddRowFromTable(G.Sample,
                                                                 new KeyValuePair <int, object>(C.Sample.YM, DateControl_Class.SelectMonth),
                                                                 new KeyValuePair <int, object>(C.Sample.Worker, negotiationAssistant.WorkerID),
                                                                 new KeyValuePair <int, object>(C.Sample.Status, (uint)data.EStatus.Selected));
     }
     MyTools.AddRowFromTable(G.SelectionWell,
                             new KeyValuePair <int, object>(C.SelectionWell.Well, well.ID),
                             new KeyValuePair <int, object>(C.SelectionWell.Sample, negotiationAssistant.SampleID),
                             new KeyValuePair <int, object>(C.SelectionWell.Number, number)
                             );
 }
Example #7
0
        public override bool StartLoad()
        {
            G.NormDoc.QUERRY()
            .SHOW
            .WHERE
            .ARC(C.NormDoc.Volume, C.Volume.Sample, C.Sample.YM).EQUI.BV(YM - 1)
            .DO();
            NormDoc[] normDocs = new NormDoc[G.NormDoc.Rows.Count];
            for (int i = 0; i < normDocs.Length; i++)
            {
                normDocs[i] = new NormDoc(G.NormDoc.Rows.GetID(i));
            }
            show[]  _temp = shows.ToArray();
            load_sw load  = new load_sw(_temp.Length, new Func <int, bool>(
                                            IndexRow =>
            {
                show temp = _temp[IndexRow];
                if (temp.VolumeID > 0)
                {
                    if (normDocs.FirstOrDefault(x => temp.act == x.Act && temp.invoces == x.Invoces && temp.score == x.Score) == null)
                    {
                        MyTools.AddRowFromTable(G.NormDoc,
                                                new KeyValuePair <int, object>(C.NormDoc.Act, temp.act),
                                                new KeyValuePair <int, object>(C.NormDoc.Score, temp.score),
                                                new KeyValuePair <int, object>(C.NormDoc.Invoces, temp.invoces),
                                                new KeyValuePair <int, object>(C.NormDoc.Volume, temp.VolumeID),
                                                new KeyValuePair <int, object>(C.NormDoc.Date, temp._date),
                                                new KeyValuePair <int, object>(C.NormDoc.Summ, temp.summ),
                                                new KeyValuePair <int, object>(C.NormDoc.Resolution, PollutionBase_Class.AllResolution.First(x => x.CurtName.Contains(temp.type_calc)).ID)
                                                );
                    }

                    shows.Remove(temp);
                }

                return(true);
            }));

            _progress = new Progress_Form(load);
            _progress.ShowDialog();
            DG.ItemsSource = null;
            DG.ItemsSource = shows;
            return(true);
        }
Example #8
0
            protected override bool Do()
            {
                var values = PollutionBase_Class.GetValuesFromYM(YM);
                var select = PollutionBase_Class.GetSelectionWellFromYM(YM);
                int act    = 0;

                foreach (var one in shows)
                {
                    Action(++act);
                    var sw = select.FirstOrDefault(x => x.Number == one.select);
                    if (sw == null)
                    {
                        message += $"{one.select}-C-{MyTools.YearMonth_From_YM(YM, DivisionSymbol: "/")}, ";
                        continue;
                    }
                    foreach (var val in one.value)
                    {
                        var value = values.FirstOrDefault(x => x.NumberSel == one.select && x.Pollution.UniqueKey == val.Key);
                        if (value != null)
                        {
                            if (value.Value != val.Value)
                            {
                                if (!ForceDownload)
                                {
                                    compares.Add(new Compare(val.Key, value.Value, val.Value, sw));
                                }
                                else
                                {
                                    value.Value = val.Value;
                                }
                            }
                        }
                        else
                        {
                            MyTools.AddRowFromTable(G.ValueSelection,
                                                    new KeyValuePair <int, object>(C.ValueSelection.Pollution, pollutions.First(x => x.UniqueKey == val.Key).ID),
                                                    new KeyValuePair <int, object>(C.ValueSelection.SelectionWell, sw.ID),
                                                    new KeyValuePair <int, object>(C.ValueSelection.Value, val.Value));
                        }
                    }
                }
                return(true);
            }
Example #9
0
        private void ClientsObjects_Click(object sender, RoutedEventArgs e)
        {
            var objs = AllClients.GetClients(AllClients.GetObjects(false).ToList(), false);

            SG = new SearchGrid_Window(objs, new C_SettingSearchDataGrid
                                           (ThisDelegate: MouseDoubleClick,
                                           ColorConditions: new ColorCondition
                                               (column.DateClose,
                                               ((text) => { return(text.TryParseInt() > 0 && text.TryParseInt() <= DateControl_Class.SelectMonth); }),
                                               Brushes.Red)
                                           , DopText: $"Последний номер папки: {objs.Max(x=>x.NumberFolder)}"));
            MenuItem MiAdd = new MenuItem();

            MiAdd.Header = "Добавить";
            MiAdd.Click += (senderAdd, eAdd) =>
            {
                try
                { SG.SelectID = MyTools.AddRowFromTable(G.Client, new KeyValuePair <int, object>(C.Client.INN, "000"), new KeyValuePair <int, object>(C.Client.YMFrom, DateControl_Class.SelectMonth - 1)); }
                catch
                {
                    MessageBox.Show("В базе существует пустой клиент с ИНН \"000\"");
                    return;
                }
                MouseDoubleClick(null, null);
                SG.ReSet(AllClients.GetClients(AllClients.GetObjects(true).ToList(), true));
            };
            SG.ThisMenu.Items.Add(MiAdd);
            Button btShowAll = new Button {
                Content = "Показать все"
            };

            btShowAll.Click += (senderS, eS) =>
            {
                SG.ReSet(AllClients.GetClients(AllClients.GetObjects(true).ToList(), true));
                btShowAll.IsEnabled = false;
            };
            SG.ThisMenu.Items.Add(btShowAll);
            this.SelectWindowSearth(SG);
        }
Example #10
0
        private void DG_Show_Add(object sender, MouseButtonEventArgs e)
        {
            if (DG.SelectedIndex == -1)
            {
                return;
            }
            var elem = (DG.Items[DG.SelectedIndex] as IThisShow);

            if (elem.NegotiationAssistandID > 0)
            {
                MyTools.DeleteRowsByID(G.NegotiationAssistant, false, elem.NegotiationAssistandID);
                elem.NegotiationAssistandID = 0;
            }
            else
            {
                if ((bool)G.NegotiationAssistant.QUERRY().EXIST
                    .WHERE
                    .AC(C.NegotiationAssistant.Objecte).EQUI.BV(elem.ID)
                    .AND
                    .AC(C.NegotiationAssistant.YM).EQUI.BV(DateControl_Class.SelectMonth).DO()[0].Value
                    )
                {
                    throw new System.Exception($"Negotiation assistand allready exist:\r\nobject id = {elem.ID}, ym = {DateControl_Class.SelectMonth}");
                }
                else
                {
                    elem.NegotiationAssistandID = MyTools.AddRowFromTable(true, G.NegotiationAssistant,
                                                                          new KeyValuePair <int, object>(C.NegotiationAssistant.Objecte, elem.ID),
                                                                          new KeyValuePair <int, object>(C.NegotiationAssistant.YM, DateControl_Class.SelectMonth));
                }
            }

            DataGridRow row = (DataGridRow)DG.ItemContainerGenerator.ContainerFromIndex(DG.SelectedIndex);

            row.Background   = (DG.Items[row.GetIndex()] as IThisShow).NegotiationAssistandID > 0 ? Brushes.Green : Brushes.White;
            DG.SelectedIndex = DG.SelectedIndex + (DG.SelectedIndex != DG.Items.Count - 1 ? 1 : -1);
            text.Text        = $"План: {Values.Where(x => (x as IThisShow).NegotiationAssistandID > 0).Count()}";
        }
Example #11
0
        private void AdderMenuWithDefaultKeys(TextBlock tb, DataBase.ISTable table
                                              , KeyValuePair <int, object>[] keys
                                              , KeyValuePair <int, object>[] updateKeys
                                              , params KeyValuePair <int, object>[] values)
        {
            MenuItem MI = new MenuItem();

            MI.Header = $"Добавить \"{table.Parent.AlterName}\"";
            var t = tb;

            MI.Click += (sender, e) =>
            {
                selectThisTC = ThisTC.SelectedIndex;
                try
                {
                    var tempTable = table.Parent.CreateSubTable(false);

                    if (keys.Any())
                    {
                        {
                            var query = tempTable.QUERRY().SHOW.WHERE;

                            foreach (var value in keys)
                            {
                                if (value.Key < 0)
                                {
                                    var tmp = query.ID((uint)value.Value).AND;
                                }
                                else
                                {
                                    var tmp = query.C(value.Key, value.Value).AND;
                                }
                            }

                            ((DataBase.IDo)query).DO();
                        }
                    }

                    if (tempTable.Rows.Count > 0)
                    {
                        foreach (var updateKey in updateKeys)
                        {
                            tempTable.Rows.Set(0, updateKey.Key, updateKey.Value);
                        }

                        table.Rows.Add(tempTable.Rows.GetID(0));
                    }
                    else
                    {
                        MyTools.AddRowFromTable(table, values);
                    }
                }
                catch
                {
                    MessageBox.Show("Вы пытаетесь добавить дубликат записи!");
                    return;
                }

                var sc = new MyTools.C_SelectControl(t);

                DrawClient();
                DrawObject();
                sc.ReSelect(t);

                ThisTC.SelectedIndex = selectThisTC;
            };

            tb.ContextMenu = new ContextMenu();
            tb.ContextMenu.Items.Add(MI);
        }
Example #12
0
        public void LoadCoefficient()
        {
            TC.Items.Clear();
            PollutionBase_Class.LoadCoefficient(true);
            TabItem TI = new TabItem();

            TI.Header = "Коэффициенты";
            TC.Items.Add(TI);
            TC.SelectedIndex = 0;
            Grid grid = new Grid();

            grid.SetColumnsFromGrid(2, MyTools.GL_Auto);
            TI.Content = MyTools.VerticalHorisontalScroll(grid);

            var list = Helpers.LogicHelper.CoefficientLogic.Find();

            foreach (var one in list)
            {
                grid.SetRowFromGrid(MyTools.GL_Auto);
                grid.SetFromGrid(one.GetEditor
                                 (
                                     SFE,
                                     new MyTools.C_DefColumn(C.Coefficient.Pollution, size),
                                     new MyTools.C_DefColumn(C.Coefficient.Resolution, size),
                                     new MyTools.C_DefColumn(C.Coefficient.Compare, size),
                                     new MyTools.C_DefColumn(C.Coefficient.YMFrom, size),
                                     new MyTools.C_DefColumn(C.Coefficient.YMTo, size)
                                 ), Column: 0);
                WrapPanel WP = new WrapPanel();
                WP.Orientation = Orientation.Vertical;
                grid.SetFromGrid(WP);
                foreach (var val in one.CoefficientValues)
                {
                    List <MyTools.C_DefColumn> columns = new List <MyTools.C_DefColumn>();
                    if (one.Compare)
                    {
                        var Poll = PollutionBase_Class.AllPolutions.FirstOrDefault(x => x.ID == one.PollutionID);
                        if (Poll != null)
                        {
                            if (Poll.HasRange)
                            {
                                columns.Add(new MyTools.C_DefColumn(C.CoefficientValue.From, size, true, Poll.Round));
                            }
                            columns.Add(new MyTools.C_DefColumn(C.CoefficientValue.To, size, true, Poll.Round));
                        }
                    }
                    columns.Add(new MyTools.C_DefColumn(C.CoefficientValue.Value, size));
                    WP.Children.Add(val.GetEditor(SFE, columns.ToArray()));
                }
                Button AddVal = new Button();
                AddVal.Content = "Добавить";
                AddVal.Click  += (sender, e) =>
                {
                    MyTools.AddRowFromTable(G.CoefficientValue, new KeyValuePair <int, object>(C.CoefficientValue.Coefficient, one.ID));
                    LoadCoefficient();
                };
                WP.Children.Add(AddVal);
            }
            grid.SetRowFromGrid(MyTools.GL_Auto);
            Button Add = new Button();

            Add.Content = "Добавить";
            Add.Click  += (sender, e) =>
            {
                MyTools.AddRowFromTable(G.Coefficient, new KeyValuePair <int, object>(C.Coefficient.Compare, false));
                LoadCoefficient();
            };
            grid.SetFromGrid(Add, Column: 0);
        }