示例#1
0
        private void ordersDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            var order        = orders.Rows[e.RowIndex];
            var orderDetails = new OrderDetailsForm(user, (Int64)order["OrderId"]);

            orderDetails.MdiParent = this.MdiParent;
            orderDetails.Show();
        }
示例#2
0
        private void sendForm()
        {
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("CreateOrder", connection);
                command.Parameters.AddWithValue("@UserId", user.userId);
                command.Parameters.AddWithValue("@CityId", Convert.ToInt32(cityComboBox.SelectedValue));
                command.Parameters.AddWithValue("@Country", countryComboBox.SelectedValue);
                command.Parameters.AddWithValue("@Street", streetTextBox.Text.Trim());
                command.Parameters.AddWithValue("@Zip", zipTextBox.Text.Trim());
                command.Parameters.AddWithValue("@Telephone", phoneTextBox.Text.Trim());

                command.Parameters.Add("@OrderId", SqlDbType.BigInt);
                command.Parameters["@OrderId"].Direction = ParameterDirection.Output;
                command.CommandType = CommandType.StoredProcedure;
                command.ExecuteNonQuery();

                MessageBox.Show("Order Saved : " + command.Parameters["@OrderId"].Value.ToString());
                productListForm.LoadShoppingCart();
                productListForm.LoadProducts();

                var orderDetail = new OrderDetailsForm(user, (Int64)command.Parameters["@OrderId"].Value);
                orderDetail.MdiParent = this.MdiParent;
                orderDetail.Show();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                connection.Close();
            }
        }