Exemplo n.º 1
0
        private bool SetSample(SelectionWellViewModel swVM, TextBox tb)
        {
            int  newNumber;
            bool result = false;

            if (String.IsNullOrEmpty(tb.Text))
            {
                tb.Text = (LastNumber + 1).ToString();
            }

            if (int.TryParse(tb.Text, out newNumber))
            {
                if (SetSelectionWell(swVM, newNumber))
                {
                    result       = true;
                    tb.IsEnabled = false;
                }
                else
                {
                    newNumber = 0;
                }
            }
            else
            {
                MessageBox.Show("Значение не является номером!");
                newNumber = 0;
            }

            UpdateControlColor(tb, newNumber);

            return(result);
        }
Exemplo n.º 2
0
 private bool SetSelectionWell(SelectionWellViewModel swVM, int number)
 {
     if (!IsUsedNumber(number, negotiationAssistant.SampleID))
     {
         swVM.Number = number;
         return(true);
     }
     else
     {
         MessageBox.Show("Номер отбора уже занят!");
         return(false);
     }
 }
Exemplo n.º 3
0
        private void LoadWell()
        {
            var wps = new List <WrapPanel>();

            if (negotiationAssistant.GetIDValue(C.NegotiationAssistant.Sample) == 0)
            {
                foreach (var well in negotiationAssistant.Objecte.Wells)
                {
                    var selectionWellVM = new SelectionWellViewModel(negotiationAssistant, well);

                    WrapPanel wp = new WrapPanel();
                    wps.Add(wp);

                    wp.Margin = new Thickness(5);
                    wp.Name   = $"wp{well.Number}";

                    TextBlock Sample = new TextBlock();
                    Sample.Margin   = new Thickness(2);
                    Sample.Padding  = new Thickness(3);
                    Sample.FontSize = 18;
                    Sample.Text     = $"Введите номер отбора для колодца \"{well.PresentNumber}\"";

                    TextBox tbxSampleNumber = new TextBox();
                    tbxSampleNumber.Margin          = new Thickness(2);
                    tbxSampleNumber.Padding         = new Thickness(3);
                    tbxSampleNumber.TextAlignment   = TextAlignment.Left;
                    tbxSampleNumber.MinWidth        = 50;
                    tbxSampleNumber.TextChanged    += (sender, e) => DataBase.NoABC_Int_Dinamic(tbxSampleNumber);
                    tbxSampleNumber.BorderThickness = new Thickness(2);
                    tbxSampleNumber.KeyDown        += (sender, e) =>
                    {
                        if (e.Key == Key.Enter)
                        {
                            SetSample(selectionWellVM, tbxSampleNumber);
                        }
                    };

                    UpdateControlColor(tbxSampleNumber, 0);

                    Button btSetSample = new Button();
                    btSetSample.Margin  = new Thickness(2);
                    btSetSample.Padding = new Thickness(3);
                    btSetSample.Content = "Занести номер";
                    btSetSample.Click  += (sender, e) =>
                    {
                        SetSample(selectionWellVM, tbxSampleNumber);
                    };

                    wp.Children.Add(Sample);
                    wp.Children.Add(tbxSampleNumber);
                    wp.Children.Add(btSetSample);

                    EditNegotiationAssistant.SetRowFromGrid(MyTools.GL_Auto);
                    EditNegotiationAssistant.SetFromGrid(wp);
                }
            }
            else
            {
                EditorSample();
            }

            Button bt = new Button();

            EditNegotiationAssistant.SetRowFromGrid(MyTools.GL_Auto);
            EditNegotiationAssistant.SetFromGrid(bt);
            bt.Content = "Подтвердить выбор колодцев";
            bt.Click  += (sender, e) =>
            {
                if (negotiationAssistant.SampleID == 0)
                {
                    MessageBox.Show("Колодцы не заполнены");
                    return;
                }

                foreach (var wp in wps)
                {
                    wp.Children.Clear();
                }

                EditNegotiationAssistant.KillControl(bt);
                //EditNegotiationAssistant.KillControl(new Objecte(negotiationAssistant.IDObjecte, true).Wells.Select(x => $"wp{x.Number}").ToArray());
                EditNegotiationAssistant.RowDefinitions.RemoveRange(1, EditNegotiationAssistant.RowDefinitions.Count - 1);
                EditorSample();
            };
        }