Exemplo n.º 1
0
        public void TestDbContex()
        {
            using (DbContextApp db = DbContextApp.GetDbContextApp)
            {
                TableFirst tableFirst1 = new TableFirst
                {
                    A1 = 6000.ToString()
                };
                TableFirst tableFirst2 = new TableFirst
                {
                    A1 = 99999.ToString()
                };

                db.TableFirsts.AddRange(tableFirst1, tableFirst2);
                db.SaveChanges();

                List <TableFirst> table = db.TableFirsts.ToList();
                table.ForEach(item => Console.WriteLine(item.A1 + Environment.NewLine));

                db.TableFirsts.RemoveRange(db.TableFirsts.Select(item => item).ToArray());
                db.SaveChanges();

                if (!db.TableFirsts.Any())
                {
                    Console.WriteLine("База пуста");
                }
            }
        }
Exemplo n.º 2
0
        public void EditInTable(TableFirst invoice, Parameter[] property, Type fieldsType)
        {
            TextBox    textB;
            DatePicker datePicker;
            ComboBox   comboBox;
            string     text;

            FieldInfo[] fields = fieldsType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
            foreach (Parameter p in property)
            {
                FieldInfo f = fields.Where(f => f.Name.Contains(p.name) == true).FirstOrDefault();
                text = f.GetValue(invoice).ToString();
                switch (Type.GetTypeCode(p.type))
                {
                case TypeCode.String:
                    textB      = (TextBox)StackP.Children.OfType <TextBox>().Where(t => t.Name == p.name).FirstOrDefault();
                    textB.Text = text;
                    break;

                case TypeCode.DateTime:
                    datePicker      = (DatePicker)StackP.Children.OfType <DatePicker>().Where(t => t.Name == p.name).FirstOrDefault();
                    datePicker.Text = text;
                    break;

                case TypeCode.Int32:
                case TypeCode.Int64:
                case TypeCode.Single:
                    textB      = (TextBox)StackP.Children.OfType <TextBox>().Where(t => t.Name == p.name).FirstOrDefault();
                    textB.Text = text;
                    break;

                case TypeCode.Object:
                    if (type == typeof(Provider) || type == typeof(Invoice) || type == typeof(Payment) || type == typeof(Goods))
                    {
                        comboBox = (ComboBox)StackP.Children.OfType <ComboBox>().Where(t => t.Name == p.name).FirstOrDefault();
                        comboBox.SelectedValue = int.Parse(text);
                    }
                    else
                    {
                        MessageBox.Show("Тип не опреділився (Error521).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        throw new IndexOutOfRangeException();
                    }
                    break;

                default:
                    MessageBox.Show("Тип не опреділився (Error521).", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    throw new IndexOutOfRangeException();
                }
            }
        }
Exemplo n.º 3
0
        public static void ParserTxtToDbContext(IParser parser)
        {
            DbContextApp app = DbContextApp.GetDbContextApp;

            OneRowTxt[]  modelsParser = parser.GetValueInTxtFile();
            TableFirst[] tableFirsts  = new TableFirst[modelsParser.Length];

            for (int index = 0; index < tableFirsts.Length; index++)
            {
                tableFirsts[index] = new TableFirst
                {
                    A1  = modelsParser[index].XA1,
                    B1  = modelsParser[index].XB1,
                    V1  = modelsParser[index].XV1,
                    G1  = modelsParser[index].XG1,
                    X2  = modelsParser[index].X2,
                    X3  = modelsParser[index].X3,
                    X4  = modelsParser[index].X4,
                    X5  = modelsParser[index].X5,
                    X6  = modelsParser[index].X6,
                    X7  = modelsParser[index].X7,
                    X8  = modelsParser[index].X8,
                    X9  = modelsParser[index].X9,
                    X10 = modelsParser[index].X10,
                    X11 = modelsParser[index].X11,
                    X12 = modelsParser[index].X12,
                    X13 = modelsParser[index].X13,
                    X14 = modelsParser[index].X14
                }
            }
            ;
            app.TableFirsts.AddRange(tableFirsts);

            try
            {
                app.SaveChanges();
            }
            catch (Exception exception)
            {
                Logger.Logger.Error(exception, nameof(Convert), nameof(ParserTxtToDbContext));

                throw;
            }
        }

        #endregion
    }
Exemplo n.º 4
0
        public void CreateWindow(TableFirst table)
        {
            typeMain = table.GetType();
            var type = table.GetType().GetProperty("GetProperty").GetValue(null);

            if (type is Parameter[] list)
            { /*type.GetType() == typeof(string[]))*/
                CreateLine(list);
                Point position = new Point(0, 0);
                foreach (var t in list)
                {
                    AddInput(t.type, t.name, out position);
                }
                AddButtonSave(position);
            }
            this.SizeToContent = SizeToContent.WidthAndHeight;
            //this.ResizeMode = ResizeMode.NoResize;
        }