示例#1
0
        private void editPurchasesToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            EditPurchase newForm = new EditPurchase();

            newForm.Owner = this;
            newForm.Show();
        }
示例#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();
        }
示例#3
0
文件: Main.cs 项目: aloha-an/Goods2
        private void viewPurchasesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditPurchase newForm = new EditPurchase();

            newForm.Show();
        }