Esempio n. 1
0
        private void editPurchasesToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            EditPurchase newForm = new EditPurchase();

            newForm.Owner = this;
            newForm.Show();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (goodsIndexRow == -1)
            {
                if (show_GoodsDataGridView.RowCount == 0)
                {
                    MessageBox.Show("Добавьте товар");
                }
                else
                {
                    MessageBox.Show("Вы не выбрали товар");
                }
                return;
            }
            SqlConnectionStringBuilder connect = new SqlConnectionStringBuilder();

            connect.InitialCatalog     = "kleinkind";
            connect.DataSource         = @"ALEKSEY-PC";
            connect.ConnectTimeout     = 30;
            connect.IntegratedSecurity = true;
            using (SqlConnection cn = new SqlConnection())
            {
                cn.ConnectionString = connect.ConnectionString;
                try
                {
                    SqlCommand myCommand = new SqlCommand("Add_Purchase", cn);
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@Goods", goodsIndexRow);
                    myCommand.Parameters.AddWithValue("@Counts", Convert.ToInt32(textBox1.Text));
                    myCommand.Parameters.AddWithValue("@PriceUS", Convert.ToDecimal(textBox2.Text));
                    myCommand.Parameters.AddWithValue("@Exchange", Convert.ToDecimal(textBox3.Text));
                    myCommand.Parameters.AddWithValue("@Date", dateTimePicker1.Value.Date.ToString("yyyy-MM-dd"));
                    cn.Open();
                    myCommand.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    MessageBox.Show(ex.Message);
                }
                catch (FormatException)
                {
                    MessageBox.Show("Вы ввели некорректные данные");
                }
                finally
                {
                    cn.Close();
                }
            }
            textBox1.Text = ""; textBox2.Text = ""; dateTimePicker1.Value = DateTime.Now;
            EditPurchase main = this.Owner as EditPurchase;

            main.ReLoad();
            Close();
        }
Esempio n. 3
0
        private void viewPurchasesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditPurchase newForm = new EditPurchase();

            newForm.Show();
        }