E
E
evgemiil2017-06-08 18:13:02
SQLite
evgemiil, 2017-06-08 18:13:02

Why doesn't it count?

why is this request not getting a price?

private void button1_Click(object sender, EventArgs e)
        {
            string ConnectionString = @"Data Source=" + sPath + ";New=False;Version=3";
            // находим максимальное значение кода проводок для записи первичного ключа
            String mValue = "select MAX(idhurnProv) from ZhurnProvodok";
            object maxValue = selectValue(ConnectionString, mValue);
            if (Convert.ToString(maxValue) == "")
                maxValue = 0;
            // Обнулить значения переменных
            string sum = "0";
            string count = "0";
            
            string Value1 = null;
            string Value2 = null;
            string Value3 = null;
            if (comboBox1.Text != "")
            {
                //ОС
                Value1 = comboBox1.SelectedValue.ToString();
            }
            if (comboBox2.Text != "")
            {
                //Подразделение
                Value2 = comboBox2.SelectedValue.ToString();
            }
            if (comboBox3.Text != "")
            {
                //МОЛ
                Value3 = comboBox3.SelectedValue.ToString();
            }

            ConnectionString = @"Data Source=" + sPath + ";New=False;Version=3";
            // находим максимальное значение кода проводок для записи первичного ключа
            mValue = "select MAX(idhurnProv) from ZhurnProvodok";
            maxValue = selectValue(ConnectionString, mValue);
            if (Convert.ToString(maxValue) == "")
                maxValue = 0;
            // Обнулить значения переменных
            sum = "0";
            count = "0";
            
            Value1 = null;
            Value2 = null;
            Value3 = null;
            if (comboBox1.Text != "")
            {
                //ОС
                Value1 = comboBox1.SelectedValue.ToString();
            }
            if (comboBox2.Text != "")
            {
                //Подразделение
                Value2 = comboBox2.SelectedValue.ToString();
            }
            if (comboBox3.Text != "")
            {
                //МОЛ
                Value3 = comboBox3.SelectedValue.ToString();
            }
            //Поле количество
            if (textBox2.Text != "")
            {
                count = textBox2.Text;
            }
            //Поиск по базе данных значений
            String selectCost = "select Cena from Mater where IdMat ='" + Value1 + "'";
            double Summa = Convert.ToDouble(selectCost) * Convert.ToDouble(count);
            String selectDT = "select idPlSch from planSchetov where schet = '''10'''";
            object DT = selectValue(ConnectionString, selectDT);
            String selectKT = "select idPlSch from planSchetov where schet = '''60'''";
            object KT = selectValue(ConnectionString, selectKT);
            string add = "INSERT INTO ZhurnProvodok (idhurnProv, date, DB, " 
                + "subDB1, subDB2, subDB3, KR, kolVO, sum, vidOper) VALUES(" + (Convert.ToInt32(maxValue) + 1) 
                + dateTimePicker1.Text + "'," + DT.ToString() + "," + Convert.ToInt32(Value1) 
                + "," + Convert.ToInt32(Value2) + "," + Convert.ToInt32(Value3) + "," 
                + KT.ToString() + "," + Convert.ToDouble(count) + "," + Summa + ", " 
                + Convert.ToInt32(textBox1.Text) + ", " + ",'Поступление материалов','" + ")";
            ExecuteQuery(add);
            selectTable(ConnectionString);
        }

39938dc139fa49bea265eaf6df6826c9.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kek123, 2017-06-08
@kek123

Because in selectCost you have a string that is not converted to double

D
Dmitry Kovalsky, 2017-06-09
@dmitryKovalskiy

String selectCost = "select Cena from Mater where IdMat ='" + Value1 + "'";
double Summa = Convert.ToDouble(selectCost) * Convert.ToDouble(count);

Tell me, do you even understand what is written here?
In case not, you wrote a select query into a string variable (and immediately with a vulnerability), and then you try to convert this query into a fractional number. And what result do you want to get?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question