예제 #1
0
 /// <summary>
 /// Gets the currently selected invoice charge amount to populate in the combo box when the window first opens.
 /// </summary>
 /// <param name="invoiceNum"></param>
 /// <returns></returns>
 public double GetCharge(int ChargeNum)
 {
     try
     {
         //creates a dataset and a SQL query, then queries for the currently selected invoice date, parses it to a double, then returns it to the window.
         getData = new clsDataAccess();
         DataSet GetChargeDB = new DataSet();
         double  charge      = 0.0;
         int     iRet        = 0;
         string  sSQL        = "SELECT DISTINCT TotalCharge FROM Invoices ";
         GetChargeDB = getData.ExecuteSQLStatement(sSQL, ref iRet);
         string result = GetChargeDB.Tables[0].Rows[ChargeNum][0].ToString();
         Double.TryParse(result, out charge);
         return(charge);
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " ->" + ex.Message);
     }
 }
예제 #2
0
 /// <summary>
 /// Gets the currently selected invoice number to populate in the combo box when the window first opens.
 /// </summary>
 /// <param name="invoiceNum"></param>
 /// <returns></returns>
 public int GetInvoice(int invoiceNum)
 {
     try
     {
         //creates a dataset and a SQL query, then queries for the currently selected invoice number, parses it, then returns it to the window.
         getData = new clsDataAccess();
         DataSet GetInvoiceDB = new DataSet();
         int     num          = 0;
         int     Intresult    = 0;
         string  sSQL         = "SELECT InvoiceNum FROM Invoices";
         GetInvoiceDB = getData.ExecuteSQLStatement(sSQL, ref num);
         string result = GetInvoiceDB.Tables[0].Rows[invoiceNum][0].ToString();
         Int32.TryParse(result, out Intresult);
         return(Intresult);
     }
     catch (Exception ex)
     {
         throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " ->" + ex.Message);
     }
 }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="db">DataAccess class for running queries</param>
        /// <param name="sql">SQL class to get query strings</param>
        public ItemsWindow(clsDataAccess db, clsSQL sql)
        {
            try
            {
                InitializeComponent();

                this.db  = db;
                this.sql = sql;

                // Ensure textboxes are empty
                ItemCodeTB.Text = "";
                ItemDescTB.Text = "";
                ItemCostTB.Text = "";

                PopulateItemsDataGrid();
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " -> " + ex.Message);
            }
        }
예제 #4
0
 /// <summary>
 /// Constructer requires a DataAccess object
 /// </summary>
 /// <param name="db"></param>
 public ItemDao(clsDataAccess db)
 {
     this.db = db;
     iRet    = 0;
 }
예제 #5
0
        /// <summary>
        /// Updates the data grid based on the combo box selections made by the user.
        /// </summary>
        /// <param name="invoice"></param>
        /// <param name="date"></param>
        /// <param name="charge"></param>
        /// <returns></returns>
        public DataSet UpdateDataGrid(string invoice, string date, string charge)
        {
            try
            {
                //creates a dataset, a blank SQL string, then checks what conditions the combo boxes are in. Based on the combo box conditions it will select the appropriate query with the data selected by the user.
                getData = new clsDataAccess();
                DataSet UpdatedGrid = new DataSet();
                string  sSQL        = "";
                int     iRet        = 0;
                if (invoice == null || date == null || charge == null)
                {
                    sSQL = "SELECT  * FROM Invoices";
                }
                else if (invoice != "" && date == "" && charge == "")
                {
                    sSQL = "SELECT  * FROM Invoices WHERE InvoiceNum = " + invoice;
                }

                else if (invoice == "" && date != "" && charge == "")
                {
                    sSQL = "SELECT  * FROM Invoices WHERE InvoiceDate = #" + date + "#";
                }

                else if (invoice == "" && date == "" && charge != "")
                {
                    sSQL = "SELECT  * FROM Invoices WHERE TotalCharge = " + charge;
                }

                else if (invoice != "" && date != "" && charge == "")
                {
                    sSQL = "SELECT  * FROM Invoices WHERE InvoiceNum = " + invoice + " AND InvoiceDate = #" + date + "#";
                }

                else if (invoice == "" && date != "" && charge != "")
                {
                    sSQL = "SELECT  * FROM Invoices WHERE InvoiceDate = #" + date + "#" + " AND TotalCharge =" + charge;
                }

                else if (invoice != "" && date == "" && charge != "")
                {
                    sSQL = "SELECT  * FROM Invoices WHERE InvoiceNum = " + invoice + " AND TotalCharge = " + charge;
                }

                else if (invoice != "" && date != "" && charge != "")
                {
                    sSQL = "SELECT  * FROM Invoices WHERE InvoiceNum = " + invoice + " AND InvoiceDate = #" + date + "#" + " AND TotalCharge = " + charge;
                }

                else if (invoice == "" && date == "" && charge == "")
                {
                    sSQL = "SELECT * FROM Invoices";
                }
                //runs query then returns result.
                UpdatedGrid = getData.ExecuteSQLStatement(sSQL, ref iRet);
                return(UpdatedGrid);
            }
            catch (Exception ex)
            {
                throw new Exception(MethodInfo.GetCurrentMethod().DeclaringType.Name + "." + MethodInfo.GetCurrentMethod().Name + " ->" + ex.Message);
            }
        }