예제 #1
0
        public void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.CurrentRow != null)
            {
                string id            = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
                string nameClient    = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                string numberClient  = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
                string adressClient  = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
                string commentClient = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();

                editData.idClient         = int.Parse(id);
                editData.editClient.Text  = nameClient;
                editData.editNumber.Text  = numberClient;
                editData.textBox1.Text    = adressClient;
                editData.editComment.Text = commentClient;
                editData.textBoxId.Text   = id;
                idInt = int.Parse(id);
            }
            editData.Show();
            this.Close();
        }
예제 #2
0
        private void saveTovar_Click(object sender, EventArgs e)
        {
            {
                int inserted = 0;

                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    bool isSelected = Convert.ToBoolean(row.Cells["checkTovar"].Value);
                    if (isSelected)
                    {
                        string constring = @"Data Source=DESKTOP-43BJ3R7\SQLEXPRESS;Initial Catalog=uchet;Integrated Security=True";
                        using (SqlConnection con = new SqlConnection(constring))
                        {
                            using (SqlCommand cmd = new SqlCommand(@"INSERT INTO sostavzakaz (name_zak, price_zak ,id_tovar, id_client) VALUES(@nameTov, @priceTov ,@idTov, @idClient)", con))
                            {
                                cmd.Parameters.AddWithValue("@nameTov", row.Cells["nametovar"].Value);
                                cmd.Parameters.AddWithValue("@priceTov", row.Cells["price"].Value);
                                cmd.Parameters.AddWithValue("@idTov", row.Cells["id"].Value);
                                cmd.Parameters.Add("@idClient", SqlDbType.Int).Value = idClientTovar;
                                con.Open();
                                cmd.ExecuteNonQuery();
                                con.Close();
                            }
                        }
                        inserted++;
                    }
                }

                if (inserted > 0)
                {
                    MessageBox.Show(string.Format("{0} строк добавлено.", inserted), "Message");
                }


                editData.dataGridView1.Update();
                editData.dataGridView1.Refresh();
                editData.Show();
                this.Close();
            }
        }
예제 #3
0
        private void priceTovar_FormClosed(object sender, FormClosedEventArgs e)
        {
            editData editData = new editData();

            editData.Show();
        }