Beispiel #1
0
        /// <summary>
        /// The SaveSupplier
        /// </summary>
        private void SaveSupplier()
        {
            object[,] objParams = new object[,] { { "suppName", txtSuppName.Text } };

            try
            {
                using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString))
                {
                    var results = new DatabaseProcessor().Process("CreateSupplier", objParams, conn);
                    if (results != null)
                    {
                        if (results.HasRows)
                        {
                            MessageBox.Show(results.GetString(0), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show("Supplier created", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Invoke((MethodInvoker)delegate
                            {
                                Close();
                            });
                        }
                    }

                    results.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// The UpdateProduct
        /// </summary>
        private void UpdateProduct()
        {
            var prodCode   = string.Empty;
            var prodDescr  = string.Empty;
            var prodAmount = 0D;
            var prodSuppId = 0;

            Invoke((MethodInvoker) delegate
            {
                prodCode   = txtProdId.Text;
                prodDescr  = txtProdDescr.Text;
                prodAmount = Convert.ToDouble(txtProdPrice.Text);
                prodSuppId = Convert.ToInt32(cboSupps.SelectedValue);
            });

            object[,] objParams = new object[, ] {
                { "prodDescr", prodDescr },
                { "prodAmount", prodAmount },
                { "prodSuppId", prodSuppId },
                { "prodCode", prodCode },
                { "prodId", _product.Id }
            };

            try
            {
                using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString))
                {
                    var results = new DatabaseProcessor().Process("UpdateProduct", objParams, conn);
                    if (results != null)
                    {
                        if (results.HasRows)
                        {
                            MessageBox.Show(results.GetString(0), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show("Product updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Invoke((MethodInvoker) delegate
                            {
                                Close();
                            });
                        }
                    }

                    results.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
        }