コード例 #1
0
ファイル: PriceChange.cs プロジェクト: bmsmith/NSA-Sandwich
        private void SavePrice_Button_Click(object sender, EventArgs e)
        {
            string newPrice = NewPrice_Textbox.Text.ToString();

            // connect to DB if it is not connected
            if (!nsadb.Connected())
            {
                nsadb.OpenConnection();
            }

            //request the Records to display on the manager orders list
            nsadb.ManagerSetPrice(curitem, newPrice);
            MessageBox.Show("Price Updated!", "Price Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        } //SavePrice_Button_Click
コード例 #2
0
        private void Login_Button_Click(object sender, EventArgs e)
        {
            string Username = Username_Textbox.Text.ToString();
            string Password = Password_Textbox.Text.ToString();
            string isassist = null;

            if (String.IsNullOrWhiteSpace(Username) || String.IsNullOrWhiteSpace(Password))
            {
                MessageBox.Show("Not All Fields Filled In!", "Manager Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                // connect to DB if it is not connected
                if (!nsadb.Connected())
                {
                    nsadb.OpenConnection();
                }

                // Get the loyalty account data from the database
                isassist = nsadb.ManagerLogin(Username, Password);

                if (isassist == "-1")
                {
                    MessageBox.Show("Username or Password Incorrect!", "Manager Login", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }
                else if (isassist == "0")
                {
                    ManagerKiosk frm = new ManagerKiosk(0);
                    frm.Show();
                    frm.FormClosed += new FormClosedEventHandler(ManagerKiosk_FormClosed);
                    this.Hide();
                }
                else if (isassist == "1")
                {
                    ManagerKiosk frm = new ManagerKiosk(1);
                    frm.Show();
                    frm.FormClosed += new FormClosedEventHandler(ManagerKiosk_FormClosed);
                    this.Hide();
                }
            }
        }
コード例 #3
0
        public void LoadOrders()
        {
            try
            {
                int             ordercount = 0;                // the number of orders to display
                List <string>[] Managerdata;                   // the orders that will be displayed
                ArrayList       ListBoxInfo = new ArrayList(); // Array list where formatted text will be stored

                // connect to DB if it is not connected
                if (!nsadb.Connected())
                {
                    nsadb.OpenConnection();
                }

                //request the Records to display on the manager orders list
                ordercount = nsadb.ManagerOrdersData(out Managerdata);

                // Clear any existing data in the list box
                Orders_Listbox.DataSource = null;
                Orders_Listbox.Items.Clear();

                // If there is no data in the database skip attempting to load the List
                // It will cause an error.
                if (ordercount == 0)
                {
                    return;
                }

                //loop over the records and format them in the Array List
                for (int index = 0; index < ordercount; index++)
                {
                    if (Managerdata[2][index] == "0")
                    {
                        ListBoxInfo.Add(new BoxFormat("#" + Managerdata[0][index] + " - " + Managerdata[1][index], Managerdata[0][index]));
                    }
                    else
                    {
                        ListBoxInfo.Add(new BoxFormat("#" + Managerdata[0][index] + " - " + Managerdata[1][index] + " - Refunded", Managerdata[0][index]));
                    }
                }

                // Insert Array List into the List Box
                Orders_Listbox.DataSource = ListBoxInfo;

                // Define which information is actually displayed by the listbox and returned
                Orders_Listbox.DisplayMember = "displayText";
                Orders_Listbox.ValueMember   = "databaseID";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error loading Orders List", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        } // LoadOrders
コード例 #4
0
ファイル: Reports.cs プロジェクト: bmsmith/NSA-Sandwich
        //Sales by week will generate a HTML formatted report int the form of a string.
        // We will use the NSADatabase Class to retrieve the Data.
        // The Table will be in the following format
        // ┌──────────────────────────┐
        // |      Sales By WeeK       |
        // ├──────────────────────────┤
        // |Store - #                 |
        // ├──────────────────────────|
        // │Week│Date│Num Orders│Sales│
        // ├────┼────┼──────────┼─────┤
        // └────┴────┴──────────┴─────┘
        private string SalesByWeek()
        {
            //Stringbuilder for creating the Query to use to get the sales data.
            StringBuilder ByWeekQuery = new StringBuilder();

            //for readability the query is built via multiple appends rather than a single one.
            ByWeekQuery.Append("SELECT storeid, weekofyear(O.timeplaced) as Week, ");
            ByWeekQuery.Append("STR_TO_DATE(CONCAT(CONCAT( DATE_FORMAT(O.timeplaced,'%Y'), ");
            ByWeekQuery.Append("weekofyear(O.timeplaced) ),' Monday'), '%X%V %W') as WeekDate, ");
            ByWeekQuery.Append("sum(O.total) as Sales, sum(O.tax) as SalesTax, count(orderid) as Orders, refunded ");
            ByWeekQuery.Append("FROM orders O WHERE O.refunded = 0 AND storeid IN (");

            //loop over all the stations in the list execpt for the last one adding them
            //to the set of numbers for the in clause
            for (int i = 0; i < (Stores.Count - 1); i++)   // Loop through List with for
            {
                ByWeekQuery.Append(Stores[i].ToString());
                ByWeekQuery.Append(",");
            }

            //adding the last store to the In clause
            ByWeekQuery.Append(Stores[(Stores.Count - 1)].ToString());

            //add the end of the query
            ByWeekQuery.Append(") GROUP BY storeid , Week, refunded;");

            //StringBuilder object.
            StringBuilder ByWeekReport = new StringBuilder();

            if (!nsadb.Connected())
            {
                nsadb.OpenConnection();
            }

            //Create Data reader object using the built query with the database object.
            MySqlDataReader ByWeekData = nsadb.CustomQuery(ByWeekQuery.ToString());

            //Append the top portion of the report again done in multiple appends for readability.
            ByWeekReport.Append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><html><head><title>NSASALES - By Week</title></head>");
            ByWeekReport.Append("<body><table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" summary=\"Sales By Week\" w>");
            ByWeekReport.Append("<thead><th align=\"center\" colspan=\"4\">Sales By Week</th></thead>");

            int storeid = 0;

            //Read the data and Build the HTML File.
            while (ByWeekData.Read())
            {
                //if we hit a new store we need to enter the store Id and header lines.
                if (storeid != (int)ByWeekData["storeid"])
                {
                    storeid = (int)ByWeekData["storeid"];
                    ByWeekReport.Append("<tr><th align=\"left\" colspan=\"4\">Store: ");
                    ByWeekReport.Append(storeid.ToString());
                    ByWeekReport.Append("</th></tr>");
                    ByWeekReport.Append("<tr><th>Week</th><th>Date</th><th>Orders per Week</th><th>Sales in dollars Per Week</th></tr>");
                }

                //Add the weeks data row to the report.
                ByWeekReport.Append("<tr><td align=\"center\">");
                ByWeekReport.Append(ByWeekData["Week"]);
                ByWeekReport.Append("</td><td align=\"center\">");
                ByWeekReport.Append(string.Format("{0:MM/dd/yyyy}", ByWeekData["WeekDate"]));
                ByWeekReport.Append("</td><td align=\"center\">");
                ByWeekReport.Append(ByWeekData["Orders"]);
                ByWeekReport.Append("</td><td align=\"center\">");
                ByWeekReport.Append(String.Format("{0:C}", ByWeekData["Sales"]));
                ByWeekReport.Append("</td></tr>");
            }

            //add the closing tags for the report.
            ByWeekReport.Append("</table></body></html>");


            //must remember to close the reader
            ByWeekData.Close();

            //Close the connection
            nsadb.CloseConnection();

            //return the built report to the calling function.
            return(ByWeekReport.ToString());
        }