Ejemplo n.º 1
0
        private void Button_Click_3(object sender, RoutedEventArgs e)//обновление
        {
            Regex X = new Regex(@"^\d*(\,\d+)?$");

            if (X.IsMatch(n1_1.Text) && (X.IsMatch(n1_2.Text)) && (X.IsMatch(n1_3.Text)) && (X.IsMatch(n1_4.Text)) && (X.IsMatch(n2_1.Text)) && (X.IsMatch(n2_2.Text)) &&
                (X.IsMatch(n2_3.Text)) && (X.IsMatch(n2_4.Text)) && (X.IsMatch(n3_1.Text)) && (X.IsMatch(n3_2.Text)) && (X.IsMatch(n3_3.Text)) && (X.IsMatch(n3_4.Text)) &&
                (X.IsMatch(n4_1.Text)) && (X.IsMatch(n4_2.Text)) && (X.IsMatch(n4_3.Text)) && (X.IsMatch(n4_4.Text)) && (X.IsMatch(n5_1.Text)) && (X.IsMatch(n5_2.Text)) &&
                (X.IsMatch(n5_3.Text)) && (X.IsMatch(n5_4.Text)) && (X.IsMatch(n6_1.Text)) && (X.IsMatch(n6_2.Text)) && (X.IsMatch(n6_3.Text)) && (X.IsMatch(n6_4.Text)) &&
                (X.IsMatch(n7_1.Text)) && (X.IsMatch(n7_2.Text)) && (X.IsMatch(n7_3.Text)) && (X.IsMatch(n7_4.Text)) && (X.IsMatch(n8_1.Text)) && (X.IsMatch(n8_2.Text)) &&
                (X.IsMatch(n8_3.Text)) && (X.IsMatch(n8_4.Text)) && (X.IsMatch(n9_1.Text)) && (X.IsMatch(n9_2.Text)) && (X.IsMatch(n9_3.Text)) && (X.IsMatch(n9_4.Text)) &&
                (X.IsMatch(k_t.Text)) && (X.IsMatch(k_s.Text)) && (X.IsMatch(o_n.Text)) && (X.IsMatch(p_p.Text)) && (X.IsMatch(v_r.Text)) && (X.IsMatch(Ri_t.Text)) && (X.IsMatch(Rn_t.Text)) && (X.IsMatch(H_t.Text)))
            {
                using (Table_context db = new Table_context())
                {
                    if (string.IsNullOrWhiteSpace(k_t.Text) || string.IsNullOrWhiteSpace(k_s.Text) || string.IsNullOrWhiteSpace(o_n.Text) || string.IsNullOrWhiteSpace(p_p.Text) ||
                        string.IsNullOrWhiteSpace(v_r.Text) || string.IsNullOrWhiteSpace(Ri_t.Text) || string.IsNullOrWhiteSpace(Rn_t.Text) || string.IsNullOrWhiteSpace(H_t.Text) ||
                        string.IsNullOrWhiteSpace(n1_1.Text) || string.IsNullOrWhiteSpace(n1_2.Text) || string.IsNullOrWhiteSpace(n1_3.Text) || string.IsNullOrWhiteSpace(n1_4.Text) ||
                        string.IsNullOrWhiteSpace(n2_1.Text) || string.IsNullOrWhiteSpace(n2_2.Text) || string.IsNullOrWhiteSpace(n2_3.Text) || string.IsNullOrWhiteSpace(n2_4.Text) ||
                        string.IsNullOrWhiteSpace(n3_1.Text) || string.IsNullOrWhiteSpace(n3_2.Text) || string.IsNullOrWhiteSpace(n3_3.Text) || string.IsNullOrWhiteSpace(n3_4.Text) ||
                        string.IsNullOrWhiteSpace(n4_1.Text) || string.IsNullOrWhiteSpace(n4_2.Text) || string.IsNullOrWhiteSpace(n4_3.Text) || string.IsNullOrWhiteSpace(n4_4.Text) ||
                        string.IsNullOrWhiteSpace(n5_1.Text) || string.IsNullOrWhiteSpace(n5_2.Text) || string.IsNullOrWhiteSpace(n5_3.Text) || string.IsNullOrWhiteSpace(n5_4.Text) ||
                        string.IsNullOrWhiteSpace(n6_1.Text) || string.IsNullOrWhiteSpace(n6_2.Text) || string.IsNullOrWhiteSpace(n6_3.Text) || string.IsNullOrWhiteSpace(n6_4.Text) ||
                        string.IsNullOrWhiteSpace(n7_1.Text) || string.IsNullOrWhiteSpace(n7_2.Text) || string.IsNullOrWhiteSpace(n7_3.Text) || string.IsNullOrWhiteSpace(n7_4.Text) ||
                        string.IsNullOrWhiteSpace(n8_1.Text) || string.IsNullOrWhiteSpace(n8_2.Text) || string.IsNullOrWhiteSpace(n8_3.Text) || string.IsNullOrWhiteSpace(n8_4.Text) ||
                        string.IsNullOrWhiteSpace(n9_1.Text) || string.IsNullOrWhiteSpace(n9_2.Text) || string.IsNullOrWhiteSpace(n9_3.Text) || string.IsNullOrWhiteSpace(n9_4.Text)

                        )
                    {
                        MessageBox.Show("Ошибка ввода!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    else
                    {
                        int zh = Convert.ToInt32(box.SelectedItem);
                        var a  = db.table.Where(c => c.Id == zh).FirstOrDefault();
                        a.k_t_base = Convert.ToDouble(k_t.Text);
                        a.k_s_base = Convert.ToDouble(k_s.Text);
                        a.o_s_base = Convert.ToDouble(o_n.Text);
                        a.p_p_base = Convert.ToDouble(p_p.Text);
                        a.v_r_base = Convert.ToDouble(v_r.Text);
                        a.ri_base  = Convert.ToDouble(Ri_t.Text);
                        a.rn_base  = Convert.ToDouble(Rn_t.Text);
                        a.h_base   = Convert.ToDouble(H_t.Text);
                        a.t1_1     = Convert.ToDouble(n1_1.Text); a.t1_2 = Convert.ToDouble(n1_2.Text); a.t1_3 = Convert.ToDouble(n1_3.Text); a.t1_4 = Convert.ToDouble(n1_4.Text);
                        a.t2_1     = Convert.ToDouble(n2_1.Text); a.t2_2 = Convert.ToDouble(n2_2.Text); a.t2_3 = Convert.ToDouble(n2_3.Text); a.t2_4 = Convert.ToDouble(n2_4.Text);
                        a.t3_1     = Convert.ToDouble(n3_1.Text); a.t3_2 = Convert.ToDouble(n3_2.Text); a.t3_3 = Convert.ToDouble(n3_3.Text); a.t3_4 = Convert.ToDouble(n3_4.Text);
                        a.t4_1     = Convert.ToDouble(n4_1.Text); a.t4_2 = Convert.ToDouble(n4_2.Text); a.t4_3 = Convert.ToDouble(n4_3.Text); a.t4_4 = Convert.ToDouble(n4_4.Text);
                        a.t5_1     = Convert.ToDouble(n5_1.Text); a.t5_2 = Convert.ToDouble(n5_2.Text); a.t5_3 = Convert.ToDouble(n5_3.Text); a.t5_4 = Convert.ToDouble(n5_4.Text);
                        a.t6_1     = Convert.ToDouble(n6_1.Text); a.t6_2 = Convert.ToDouble(n6_2.Text); a.t6_3 = Convert.ToDouble(n6_3.Text); a.t6_4 = Convert.ToDouble(n6_4.Text);
                        a.t7_1     = Convert.ToDouble(n7_1.Text); a.t7_2 = Convert.ToDouble(n7_2.Text); a.t7_3 = Convert.ToDouble(n7_3.Text); a.t7_4 = Convert.ToDouble(n7_4.Text);
                        a.t8_1     = Convert.ToDouble(n8_1.Text); a.t8_2 = Convert.ToDouble(n8_2.Text); a.t8_3 = Convert.ToDouble(n8_3.Text); a.t8_4 = Convert.ToDouble(n8_4.Text);
                        a.t9_1     = Convert.ToDouble(n9_1.Text); a.t9_2 = Convert.ToDouble(n9_2.Text); a.t9_3 = Convert.ToDouble(n9_3.Text); a.t9_4 = Convert.ToDouble(n9_4.Text);
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                MessageBox.Show("Ошибка ввода!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 2
0
 private void Button_Click_4(object sender, RoutedEventArgs e)//загрузка
 {
     using (Table_context db = new Table_context())
     {
         System.Data.SqlClient.SqlParameter param = new System.Data.SqlClient.SqlParameter("@Id", "%" + box.SelectedItem + "");
         var table = db.Database.SqlQuery <Table_base>("SELECT * FROM Table_base WHERE Id LIKE @Id", param);
         foreach (var table_base in table)
         {
             k_t.Text  = Convert.ToString(table_base.k_t_base);
             k_s.Text  = Convert.ToString(table_base.k_s_base);
             o_n.Text  = Convert.ToString(table_base.o_s_base);
             p_p.Text  = Convert.ToString(table_base.p_p_base);
             v_r.Text  = Convert.ToString(table_base.v_r_base);
             n1_1.Text = Convert.ToString(table_base.t1_1); n1_2.Text = Convert.ToString(table_base.t1_2); n1_3.Text = Convert.ToString(table_base.t1_3); n1_4.Text = Convert.ToString(table_base.t1_4);
             n2_1.Text = Convert.ToString(table_base.t2_1); n2_2.Text = Convert.ToString(table_base.t2_2); n2_3.Text = Convert.ToString(table_base.t2_3); n2_4.Text = Convert.ToString(table_base.t2_4);
             n3_1.Text = Convert.ToString(table_base.t3_1); n3_2.Text = Convert.ToString(table_base.t3_2); n3_3.Text = Convert.ToString(table_base.t3_3); n3_4.Text = Convert.ToString(table_base.t3_4);
             n4_1.Text = Convert.ToString(table_base.t4_1); n4_2.Text = Convert.ToString(table_base.t4_2); n4_3.Text = Convert.ToString(table_base.t4_3); n4_4.Text = Convert.ToString(table_base.t4_4);
             n5_1.Text = Convert.ToString(table_base.t5_1); n5_2.Text = Convert.ToString(table_base.t5_2); n5_3.Text = Convert.ToString(table_base.t5_3); n5_4.Text = Convert.ToString(table_base.t5_4);
             n6_1.Text = Convert.ToString(table_base.t6_1); n6_2.Text = Convert.ToString(table_base.t6_2); n6_3.Text = Convert.ToString(table_base.t6_3); n6_4.Text = Convert.ToString(table_base.t6_4);
             n7_1.Text = Convert.ToString(table_base.t7_1); n7_2.Text = Convert.ToString(table_base.t7_2); n7_3.Text = Convert.ToString(table_base.t7_3); n7_4.Text = Convert.ToString(table_base.t7_4);
             n8_1.Text = Convert.ToString(table_base.t8_1); n8_2.Text = Convert.ToString(table_base.t8_2); n8_3.Text = Convert.ToString(table_base.t8_3); n8_4.Text = Convert.ToString(table_base.t8_4);
             n9_1.Text = Convert.ToString(table_base.t9_1); n9_2.Text = Convert.ToString(table_base.t9_2); n9_3.Text = Convert.ToString(table_base.t9_3); n9_4.Text = Convert.ToString(table_base.t9_4);
             Ri_t.Text = Convert.ToString(table_base.ri_base); Rn_t.Text = Convert.ToString(table_base.rn_base); H_t.Text = Convert.ToString(table_base.h_base);
         }
     }
 }
Ejemplo n.º 3
0
        private void ListBox_Loaded(object sender, RoutedEventArgs e)//заполнение listbox
        {
            using (Table_context db = new Table_context())
            {
                var table = db.Database.SqlQuery <Table_base>("SELECT Id FROM Table_base");

                int[] countries = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
                foreach (var s in countries)
                {
                    box.Items.Add(s);
                }
            }
        }
Ejemplo n.º 4
0
 private void DataGrid_Loaded(object sender, RoutedEventArgs e)
 {
     using (Table_context db = new Table_context())
     {
         var Table_R = db.table;
         foreach (Table_base u in Table_R)
         {
             MessageBox.Show(Convert.ToString(u.kol));
             List <Table_content> result = new List <Table_content>(Convert.ToInt32(kol));
             for (int i = 0; i <= u.kol; i++)
             {
                 result.Add(new Table_content(i, 0, 0, 0));
             }
             DG.ItemsSource = result;
         }
     }
 }
Ejemplo n.º 5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)//сохраниение
        {
            Regex X = new Regex(@"^\d*(\,\d+)?$");

            if (X.IsMatch(n1_1.Text) && (X.IsMatch(n1_2.Text)) && (X.IsMatch(n1_3.Text)) && (X.IsMatch(n1_4.Text)) && (X.IsMatch(n2_1.Text)) && (X.IsMatch(n2_2.Text)) &&
                (X.IsMatch(n2_3.Text)) && (X.IsMatch(n2_4.Text)) && (X.IsMatch(n3_1.Text)) && (X.IsMatch(n3_2.Text)) && (X.IsMatch(n3_3.Text)) && (X.IsMatch(n3_4.Text)) &&
                (X.IsMatch(n4_1.Text)) && (X.IsMatch(n4_2.Text)) && (X.IsMatch(n4_3.Text)) && (X.IsMatch(n4_4.Text)) && (X.IsMatch(n5_1.Text)) && (X.IsMatch(n5_2.Text)) &&
                (X.IsMatch(n5_3.Text)) && (X.IsMatch(n5_4.Text)) && (X.IsMatch(n6_1.Text)) && (X.IsMatch(n6_2.Text)) && (X.IsMatch(n6_3.Text)) && (X.IsMatch(n6_4.Text)) &&
                (X.IsMatch(n7_1.Text)) && (X.IsMatch(n7_2.Text)) && (X.IsMatch(n7_3.Text)) && (X.IsMatch(n7_4.Text)) && (X.IsMatch(n8_1.Text)) && (X.IsMatch(n8_2.Text)) &&
                (X.IsMatch(n8_3.Text)) && (X.IsMatch(n8_4.Text)) && (X.IsMatch(n9_1.Text)) && (X.IsMatch(n9_2.Text)) && (X.IsMatch(n9_3.Text)) && (X.IsMatch(n9_4.Text)) &&
                (X.IsMatch(k_t.Text)) && (X.IsMatch(k_s.Text)) && (X.IsMatch(o_n.Text)) && (X.IsMatch(p_p.Text)) && (X.IsMatch(v_r.Text)) && (X.IsMatch(Ri_t.Text)) && (X.IsMatch(Rn_t.Text)) && (X.IsMatch(H_t.Text)))
            {
                if (string.IsNullOrWhiteSpace(k_t.Text) || string.IsNullOrWhiteSpace(k_s.Text) || string.IsNullOrWhiteSpace(o_n.Text) || string.IsNullOrWhiteSpace(p_p.Text) ||
                    string.IsNullOrWhiteSpace(v_r.Text) || string.IsNullOrWhiteSpace(Ri_t.Text) || string.IsNullOrWhiteSpace(Rn_t.Text) || string.IsNullOrWhiteSpace(H_t.Text) ||
                    string.IsNullOrWhiteSpace(n1_1.Text) || string.IsNullOrWhiteSpace(n1_2.Text) || string.IsNullOrWhiteSpace(n1_3.Text) || string.IsNullOrWhiteSpace(n1_4.Text) ||
                    string.IsNullOrWhiteSpace(n2_1.Text) || string.IsNullOrWhiteSpace(n2_2.Text) || string.IsNullOrWhiteSpace(n2_3.Text) || string.IsNullOrWhiteSpace(n2_4.Text) ||
                    string.IsNullOrWhiteSpace(n3_1.Text) || string.IsNullOrWhiteSpace(n3_2.Text) || string.IsNullOrWhiteSpace(n3_3.Text) || string.IsNullOrWhiteSpace(n3_4.Text) ||
                    string.IsNullOrWhiteSpace(n4_1.Text) || string.IsNullOrWhiteSpace(n4_2.Text) || string.IsNullOrWhiteSpace(n4_3.Text) || string.IsNullOrWhiteSpace(n4_4.Text) ||
                    string.IsNullOrWhiteSpace(n5_1.Text) || string.IsNullOrWhiteSpace(n5_2.Text) || string.IsNullOrWhiteSpace(n5_3.Text) || string.IsNullOrWhiteSpace(n5_4.Text) ||
                    string.IsNullOrWhiteSpace(n6_1.Text) || string.IsNullOrWhiteSpace(n6_2.Text) || string.IsNullOrWhiteSpace(n6_3.Text) || string.IsNullOrWhiteSpace(n6_4.Text) ||
                    string.IsNullOrWhiteSpace(n7_1.Text) || string.IsNullOrWhiteSpace(n7_2.Text) || string.IsNullOrWhiteSpace(n7_3.Text) || string.IsNullOrWhiteSpace(n7_4.Text) ||
                    string.IsNullOrWhiteSpace(n8_1.Text) || string.IsNullOrWhiteSpace(n8_2.Text) || string.IsNullOrWhiteSpace(n8_3.Text) || string.IsNullOrWhiteSpace(n8_4.Text) ||
                    string.IsNullOrWhiteSpace(n9_1.Text) || string.IsNullOrWhiteSpace(n9_2.Text) || string.IsNullOrWhiteSpace(n9_3.Text) || string.IsNullOrWhiteSpace(n9_4.Text)

                    )
                {
                    MessageBox.Show("Ошибка ввода!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    using (Table_context db = new Table_context())
                    {
                        Table_base n1 = new Table_base
                        {
                            t1_1     = Convert.ToDouble(n1_1.Text), t1_2 = Convert.ToDouble(n1_2.Text), t1_3 = Convert.ToDouble(n1_3.Text), t1_4 = Convert.ToDouble(n1_4.Text),
                            t2_1     = Convert.ToDouble(n2_1.Text), t2_2 = Convert.ToDouble(n2_2.Text), t2_3 = Convert.ToDouble(n2_3.Text), t2_4 = Convert.ToDouble(n2_4.Text),
                            t3_1     = Convert.ToDouble(n3_1.Text), t3_2 = Convert.ToDouble(n3_2.Text), t3_3 = Convert.ToDouble(n3_3.Text), t3_4 = Convert.ToDouble(n3_4.Text),
                            t4_1     = Convert.ToDouble(n4_1.Text), t4_2 = Convert.ToDouble(n4_2.Text), t4_3 = Convert.ToDouble(n4_3.Text), t4_4 = Convert.ToDouble(n4_4.Text),
                            t5_1     = Convert.ToDouble(n5_1.Text), t5_2 = Convert.ToDouble(n5_2.Text), t5_3 = Convert.ToDouble(n5_3.Text), t5_4 = Convert.ToDouble(n5_4.Text),
                            t6_1     = Convert.ToDouble(n6_1.Text), t6_2 = Convert.ToDouble(n6_2.Text), t6_3 = Convert.ToDouble(n6_3.Text), t6_4 = Convert.ToDouble(n6_4.Text),
                            t7_1     = Convert.ToDouble(n7_1.Text), t7_2 = Convert.ToDouble(n7_2.Text), t7_3 = Convert.ToDouble(n7_3.Text), t7_4 = Convert.ToDouble(n7_4.Text),
                            t8_1     = Convert.ToDouble(n8_1.Text), t8_2 = Convert.ToDouble(n8_2.Text), t8_3 = Convert.ToDouble(n8_3.Text), t8_4 = Convert.ToDouble(n8_4.Text),
                            t9_1     = Convert.ToDouble(n9_1.Text), t9_2 = Convert.ToDouble(n9_2.Text), t9_3 = Convert.ToDouble(n9_3.Text), t9_4 = Convert.ToDouble(n9_4.Text),
                            k_t_base = Convert.ToDouble(k_t.Text),
                            k_s_base = Convert.ToDouble(k_s.Text),
                            o_s_base = Convert.ToDouble(o_n.Text),
                            p_p_base = Convert.ToDouble(p_p.Text),
                            v_r_base = Convert.ToDouble(v_r.Text),
                            ri_base  = Convert.ToDouble(Ri_t.Text),
                            rn_base  = Convert.ToDouble(Rn_t.Text),
                            h_base   = Convert.ToDouble(H_t.Text)
                        };

                        db.table.Add(n1);
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                MessageBox.Show("Ошибка ввода!", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }