Пример #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);
            }
        }
Пример #2
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);
            }
        }