Ejemplo n.º 1
0
        /// <summary>
        /// CalculateItemCode: Logic for new ItemCode
        /// Date        Version     Name        Comments
        /// 12/06/19    1.0         Dylan       Created Method
        /// </summary>
        private static string CalculateItemCode()
        {
            clsSQL db;

            db = new clsSQL();
            /// <summary>
            /// potentialItemCode: Stores itemCode until an unused one is found
            /// </summary>
            string potentialItemCode = "0";

            string sNumUsedItemCode = db.ExecuteScalarSQL(clsItemsSQL.IsItemCode(potentialItemCode));

            if (sNumUsedItemCode != "0")
            {
                while (sNumUsedItemCode != "0")
                {
                    potentialItemCode = (Int32.Parse(potentialItemCode) + 1).ToString();
                    sNumUsedItemCode  = db.ExecuteScalarSQL(clsItemsSQL.IsItemCode(potentialItemCode));
                }
                return(potentialItemCode);
            }
            else
            {
                return(potentialItemCode);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// ItemDataGrid_CurrentCellChanged: Updates the Edit Name and Edit Cost textboxes
        /// Date        Version     Name        Comments
        /// 12/06/19    1.0         Dylan       Created Method
        /// </summary>
        /// /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ItemDataGrid_CurrentCellChanged(object sender, EventArgs e)
        {
            try
            {
                if (ItemDataGrid.CurrentCell != null && ItemDataGrid.Items.IndexOf(ItemDataGrid.CurrentItem) != -1)
                {
                    if (bIsDeleting == false)
                    {
                        //// <summary>
                        /// iRowNum: Stores selected row index
                        /// </summary>
                        int iRowNum = ItemDataGrid.Items.IndexOf(ItemDataGrid.CurrentItem);

                        if (iRowNum < ds.Tables[0].Rows.Count)
                        {
                            txtEditName.Text = ds.Tables[0].Rows[iRowNum][1].ToString();
                            txtEditCost.Text = ds.Tables[0].Rows[iRowNum].ItemArray[2].ToString();
                            sCurrentItemCode = db.ExecuteScalarSQL(clsItemsSQL.GetItemCode(txtEditName.Text));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ClsHandleError.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                           MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// DeleteItem: Logic for deleting item
        /// Date        Version     Name        Comments
        /// 11/16/19    1.0         Dylan       Created Method
        /// </summary>
        internal static bool DeleteItem(string inputItemCode)
        {
            try
            {
                //This Method will allow users to delete an existing item
                //ItemCodewill be passed in
                //ItemCode will be used to find the row to be deleted
                //If the ItemCode is found in the LineItems table, the row
                //will not be deleted
                clsSQL db;

                db = new clsSQL();
                /// <summary>
                /// inInvoice: Stores returned Scalar count of matching items in invoice
                /// </summary>
                string inInvoice = db.ExecuteScalarSQL(clsItemsSQL.IsItemInInvoice(inputItemCode));
                if (inInvoice != "0")
                {
                    return(false);
                }
                else
                {
                    db.ExecuteNonQuery(clsItemsSQL.DeleteItemList(inputItemCode));
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles when the user clicks the Search Invoice menu item
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuSearchInvoice_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                wndSearch searchWindow = new wndSearch();
                this.Hide();
                searchWindow.ShowDialog();
                int     iRet = 0;
                DataSet ds;
                // store data in dateset
                invoiceNumber = clsSearchLogic.strSelectedInvoice;

                if (invoiceNumber != "")
                {
                    ds = db.ExecuteSQLStatement(clsMainSQL.queryInvoice(Convert.ToInt32(invoiceNumber)), ref iRet);
                    string InvoiceDatePull = db.ExecuteScalarSQL(clsMainSQL.queryDate(Convert.ToInt32(invoiceNumber)));

                    //update labels
                    invoiceLbl.Content     = "Invoice Number: " + invoiceNumber;
                    invoiceDateLbl.Content = InvoiceDatePull;

                    // extract dataset items into observable list
                    currentInvoiceItems = clsMainLogic.ConvertDataSetToList(ds);

                    // bind observable list to the data source
                    invoiceItemDataGrid.ItemsSource = currentInvoiceItems;

                    // set edit invoice to true
                    editInvoiceMode = true;
                    EditMode(editInvoiceMode);
                }

                this.Show();
            }
            catch (Exception ex)
            {
                ClsHandleError.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                                           MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// AddItem: Logic for adding item
        /// Date        Version     Name        Comments
        /// 11/16/19    1.0         Dylan       Created Method
        /// </summary>
        internal static bool AddItem(string itemDescAdd, string itemCostAdd)
        {
            try
            {
                //This Method will allow users to add a new item
                //ItemCode, ItemDesc, and Cost of the new item will be passed in
                //These variables will be put into a new row in the table
                clsSQL db;

                db = new clsSQL();
                /// <summary>
                /// itemDesc: Stores ItemDesc
                /// </summary>
                string itemDesc = itemDescAdd;
                /// <summary>
                /// itemCost: Stores ItemCost
                /// </summary>
                string itemCost = itemCostAdd;
                /// <summary>
                /// sDuplicateItemDesc: Stores returned Scalar Count
                /// </summary>
                string sDuplicateItemDesc = db.ExecuteScalarSQL(clsItemsSQL.IsDuplicateItemDesc(itemDesc));
                if (sDuplicateItemDesc == "1")
                {
                    return(false);
                }
                else
                {
                    /// <summary>
                    /// itemCode: Stores returned new item code
                    /// </summary>
                    string itemCode = CalculateItemCode();
                    db.ExecuteNonQuery(clsItemsSQL.AddItemList(itemCode, itemDesc, itemCost));
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." +
                                    MethodInfo.GetCurrentMethod().Name + "->" + ex.Message);
            }
        }