Exemple #1
0
        private void editSalesToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            EditSale newForm = new EditSale();

            newForm.Owner = this;
            newForm.Show();
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (goodsIndexRow == -1)
            {
                if (show_GoodsDataGridView.RowCount == 0)
                {
                    MessageBox.Show("Как можно продавать, ничего не купив?");
                }
                else
                {
                    MessageBox.Show("Вы не выбрали товар");
                }
                return;
            }

            if (clientsIndexRow == -1)
            {
                if (show_ClientsDataGridView.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_Sale", cn);
                    myCommand.CommandType = CommandType.StoredProcedure;
                    myCommand.Parameters.AddWithValue("@Goods", goodsIndexRow);
                    myCommand.Parameters.AddWithValue("@Counts", Convert.ToInt32(textBox1.Text));
                    myCommand.Parameters.AddWithValue("@PriceUA", Convert.ToDecimal(textBox2.Text));
                    myCommand.Parameters.AddWithValue("@Client", clientsIndexRow);
                    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;
            EditSale main = this.Owner as EditSale;

            main.ReLoad();
            Close();
        }
Exemple #3
0
        private void viewSalesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            EditSale newForm = new EditSale();

            newForm.Show();
        }