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 CreatePurchaseOrderDetails
        /// </summary>
        /// <param name="poId">The poId<see cref="int"/></param>
        private void CreatePurchaseOrderDetails(int poId)
        {
            foreach (var item in _purchaseOrderDto.productDetail)
            {
                object[,] objParams = new object[, ] {
                    { "poId", poId },
                    { "prodId", item.Id },
                    { "prodAmount", item.Amount },
                    { "prodQty", item.Qty }
                };

                using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString))
                {
                    var results = new DatabaseProcessor().Process("CreatePurchaseOrderDetail", objParams, conn);
                    if (results != null)
                    {
                        results.Close();
                    }
                }
            }

            Invoke((MethodInvoker) delegate
            {
                Close();
            });
        }
Beispiel #3
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());
            }
        }
Beispiel #4
0
        /// <summary>
        /// The RemovePurchaseOrderItem
        /// </summary>
        /// <param name="PurchaseOrderItemId">The PurchaseOrderItemId<see cref="int"/></param>
        private void RemovePurchaseOrderItem(int PurchaseOrderItemId)
        {
            Task.Factory.StartNew(() =>
            {
                using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString))
                {
                    var results = new DatabaseProcessor().Process("RemovePurchaseOrderItem", new object[, ] {
                        { "poId", PurchaseOrderItemId }
                    }, conn);

                    if (results != null)
                    {
                        Invoke((MethodInvoker) delegate
                        {
                            MessageBox.Show("Purchase order item removed", "Removed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            RetrievePurchaseOrderDetail();
                        });

                        results.Close();
                    }
                }
            });
        }
Beispiel #5
0
        /// <summary>
        /// The UpdatePurchaseOrder
        /// </summary>
        private void UpdatePurchaseOrder()
        {
            var newRows = _purchaseOrderDto.productDetail.Where(p => p.NewItem == true).ToList();

            if (newRows != null)
            {
                Task.Factory.StartNew(() =>
                {
                    foreach (var item in newRows)
                    {
                        object[,] objParams = new object[, ] {
                            { "poId", item.PurchaseOrderId },
                            { "prodId", item.ProductId },
                            { "prodAmount", item.Amount },
                            { "prodQty", item.Qty }
                        };

                        using (SqlConnection conn = new SqlConnection(DatabaseProcessor.DatabaseConnectionString))
                        {
                            var results = new DatabaseProcessor().Process("CreatePurchaseOrderDetail", objParams, conn);

                            if (results != null)
                            {
                                results.Close();
                            }
                        }
                    }

                    Invoke((MethodInvoker) delegate
                    {
                        MessageBox.Show("Purchase order updated", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        RetrievePurchaseOrderDetail();
                    });
                });
            }
        }