示例#1
0
文件: Form1.cs 项目: Ebengrad-bit/bd
        private void button6_Click(object sender, EventArgs e)
        {
            var rov = dgrv_provider.SelectedRows.Count > 0 ? dgrv_provider.SelectedRows[0] : null;

            if (rov == null)
            {
                MessageBox.Show("Строчку выбери", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            var form = new ProvForm();

            form.Name_.Text = rov.Cells["name"].Value.ToString();
            form.chir.Text  = rov.Cells["score"].Value.ToString();

            var res = form.ShowDialog();

            if (res == DialogResult.OK)
            {
                var name       = form.Name_.Text;
                var score      = form.chir.Text;
                var connection = new SqlConnection(address_and_else);
                connection.Open();
                //var reqiest = "INSERT INTO Nazarov_Abonent (name,\"second name\", \"third name\", comment, address) VALUES ('" + fname + "' ,'" + sname + "' ,'" + tname + "' ,'" + comment + "' ,'" + addres + "')";
                //var reqiest = "INSERT INTO Nazarov_Provider (name, score) VALUES ('" + name + "' ,'" + score + "')";
                var reqiest = "UPDATE Nazarov_Provider SET name ='" + name + "', score='" + score + "' WHERE Id=" + rov.Cells["Id"].Value.ToString() + ";";

                var command = new SqlCommand(reqiest, connection);
                command.ExecuteNonQuery();
                connection.Close();
                UpdateAll();
            }
        }
示例#2
0
文件: Form1.cs 项目: Ebengrad-bit/bd
        private void button4_Click_1(object sender, EventArgs e)
        {
            var form = new ProvForm();
            var res  = form.ShowDialog();

            if (res == DialogResult.OK)
            {
                var name       = form.Name_.Text;
                var score      = form.chir.Text;
                var connection = new SqlConnection(address_and_else);
                connection.Open();
                //var reqiest = "INSERT INTO Nazarov_Abonent (name,\"second name\", \"third name\", comment, address) VALUES ('" + fname + "' ,'" + sname + "' ,'" + tname + "' ,'" + comment + "' ,'" + addres + "')";
                var reqiest = "INSERT INTO Nazarov_Provider (name, score) VALUES ('" + name + "' ,'" + score + "')";
                var command = new SqlCommand(reqiest, connection);
                command.ExecuteNonQuery();
                connection.Close();
                UpdateAll();
            }
        }