private void SaveButton_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("Data Source=DESKTOP-P024OII\\TARIQULPC;Initial Catalog=Library_Management_System;Integrated Security=True");

            try
            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = "insert into BooksInfo values('" + BookNameTextBox.Text + "', '" + AuthorNameTextBox.Text + "', '" + dateTimePicker1.Text + "', " + PriceTextBox.Text + ", " + QuantityTextBox.Text + ", " + QuantityTextBox.Text + ")";
                cmd.ExecuteNonQuery();
                MessageBox.Show("Book is successfully added");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                con.Close();
            }
            BookNameTextBox.Clear();
            AuthorNameTextBox.Clear();
            PriceTextBox.Clear();
            QuantityTextBox.Clear();
        }
Exemple #2
0
 private void addButton_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(MenuNameTextBox.Text))
     {
         if (!string.IsNullOrEmpty(TypeComboBox.SelectedIndex.ToString()))
         {
             if (!string.IsNullOrEmpty(priceTextBox.Text))
             {
                 int result = ms.AddMenu(MenuNameTextBox.Text, Convert.ToInt32(priceTextBox.Text), Convert.ToInt32(QuantityTextBox.Text), TypeComboBox.SelectedItem.ToString());
                 if (result == 1)
                 {
                     MessageBox.Show("Item successfully added to menu!");
                     mda = new MenuDataAccess();
                     dataGridView1.DataSource = mda.GetMenuData();
                     MenuNameTextBox.Clear();
                     priceTextBox.Clear();
                     QuantityTextBox.Clear();
                     TypeComboBox.SelectedItem = null;
                 }
             }
             else
             {
                 MessageBox.Show("Please Enter a price!");
             }
         }
         else
         {
             MessageBox.Show("Please Enter quantity!");
         }
     }
     else
     {
         MessageBox.Show("Please Enter name!");
     }
 }
Exemple #3
0
 private void clearButton_Click(object sender, EventArgs e)
 {
     MenuNameTextBox.Clear();
     priceTextBox.Clear();
     QuantityTextBox.Clear();
     TypeComboBox.SelectedItem = null;
 }
Exemple #4
0
        private bool IsValidated()
        {
            if (QuantityTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Please add new quantity.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                QuantityTextBox.Clear();
                QuantityTextBox.Focus();
                HasValidationFailed = true;
                return(false);
            }

            int  result    = 0;
            bool isNumeric = int.TryParse(QuantityTextBox.Text.Trim(), out result);

            if (!isNumeric)
            {
                MessageBox.Show("Quantity should be interger (1,2,3,...).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                QuantityTextBox.Clear();
                QuantityTextBox.Focus();
                HasValidationFailed = true;
                return(false);
            }

            return(true);
        }
Exemple #5
0
 public void Cleardata()
 {
     FilenameLabel.Text = "FileNotSelected";
     PriceTextBox.Clear();
     QuantityTextBox.Clear();
     ProductCodeTextBox.Clear();
     ProductNameTextBox.Clear();
 }
Exemple #6
0
        private bool IsValidated()
        {
            if (ClientNameTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Client Name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ClientNameTextBox.Focus();
                return(false);
            }

            if (ItemNameComboBox.SelectedIndex == -1)
            {
                MessageBox.Show("Item Name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (QuantityTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Quantity is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                QuantityTextBox.Focus();
                return(false);
            }

            else
            {
                int  tempQuantity;
                bool isNumeric = int.TryParse(QuantityTextBox.Text.Trim(), out tempQuantity);

                if (!isNumeric)
                {
                    MessageBox.Show("Quantity should be integer value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    QuantityTextBox.Clear();
                    QuantityTextBox.Focus();
                    return(false);
                }
            }

            if (UnitPriceTextBox.Text.Trim() == string.Empty)
            {
                MessageBox.Show("Unit Price is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UnitPriceTextBox.Focus();
                return(false);
            }
            else
            {
                decimal n;
                bool    isDecimal = decimal.TryParse(UnitPriceTextBox.Text.Trim(), out n);

                if (!isDecimal)
                {
                    MessageBox.Show("Unit Price should be decimal value.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UnitPriceTextBox.Clear();
                    UnitPriceTextBox.Focus();
                    return(false);
                }
            }

            return(true);
        }
Exemple #7
0
 private void pictureBox3_Click(object sender, EventArgs e)
 {
     MedicineIdTextBox.Clear();
     SellingPriceTextBox.Clear();
     MedicineNameTextBox.Clear();
     QuantityTextBox.Clear();
     BuyingPriceTextBox.Clear();
     ManufacturerTextBox.Clear();
 }
Exemple #8
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            int result = ms.EditMenu(id, MenuNameTextBox.Text, Convert.ToInt32(priceTextBox.Text), Convert.ToInt32(QuantityTextBox.Text), TypeComboBox.SelectedItem.ToString());

            mda = new MenuDataAccess();
            dataGridView1.DataSource = mda.GetMenuData();
            MessageBox.Show("Item details successfully saved!");
            MenuNameTextBox.Clear();
            priceTextBox.Clear();
            QuantityTextBox.Clear();
            TypeComboBox.SelectedItem = null;
        }
Exemple #9
0
        /// <summary>
        /// Overi spravnost udaju mnozstvi pridavane polozky.
        /// Vstup musi byt ciselny, nesmi byt prazdny ani 0.
        /// </summary>
        /// <returns></returns>
        public bool VerifyQuantityInput()
        {
            string quantityString = QuantityTextBox.Text;

            if (!(int.TryParse(quantityString, out int quantity) &&
                  quantityString.Length > 0))
            {
                QuantityTextBox.Clear();
                QuantityFieldTLPanel.BackColor = Color.MistyRose;
                Message.QuantityFormatWarning();
                return(false);
            }
Exemple #10
0
        private void ClearButton_Click(object sender, EventArgs e)
        {
            //Clear Textboxes
            TitleTextBox.Clear();
            PriceTextBox.Clear();
            ExtendedPriceTextBox.Clear();
            DiscountedPriceTextBox.Clear();
            DiscountTextBox.Clear();
            QuantityTextBox.Clear();

            //Set focus on Quantity
            QuantityTextBox.Focus();
        }
Exemple #11
0
        private void AddOrderDetailsButton_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();

            //символен низ за връзка към базата данни – взема се от файл с име app.config
            con.ConnectionString = ConfigurationManager.ConnectionStrings["MassiveDynamic.Properties.Settings.MassiveDynamicConnectionString"].ConnectionString;
            //символен низ със заявката към базата данни
            string insertIntoOrderId       = "'" + orderIDComboBox.Text + "'";
            string insertIntoProductIDName = "'" + numberOfProductComboBox.Text + "'";
            string insertIntounitPrice     = "'" + UnitPriceTextBox.Text + "'";
            string insertQuantity          = "'" + QuantityTextBox.Text + "'";

            //INSERT INTO table_name (column1,column2,column3,...)  VALUES(value1, value2, value3,...);  Insert into cheatSheet
            string insertCommand = string.Format("insert into OrderDetails (OrderID,ProductID,UnitPrice,Quantiy) values({0},{1},{2},{3});", insertIntoOrderId, insertIntoProductIDName, insertIntounitPrice, insertQuantity);

            SqlCommand com = new SqlCommand(insertCommand, con);

            //определяне на типа на командата - в конкретния случай е текст
            com.CommandType = CommandType.Text;

            try
            {
                //отваряме връзката към базата данни
                con.Open();
                //изпълняваме командата / в този случай нямаме връщан резултат
                com.ExecuteNonQuery();

                //извеждаме съобщение, че всичко е преминало успешно
                MessageBox.Show("Данните са добавени успешно!",
                                "Message/Съобщение");
                //изчистваме въведената стойност в текстовото поле

                UnitPriceTextBox.Clear();
                QuantityTextBox.Clear();
            }
            //ако не е преминало всичко успешно, това означава, че е възникнало изключение
            catch (Exception exe)
            {
                //извеждаме съобщение с възникналото изключение
                MessageBox.Show(exe.ToString(), "Message/Съобщение:");
            }
            //затваря се връзката към базата данни
            con.Close();
            //затваря се отворената форма
            this.Close();
        }
Exemple #12
0
        private void CancelOrderButton_Click(object sender, EventArgs e)
        {
            NewOrderButton.Enabled     = true;
            PrintOrderButton.Enabled   = false;
            PrintPreviewButton.Enabled = false;
            CancelOrderButton.Enabled  = false;
            ItemGroupBox.Enabled       = false;

            ClientNameTextBox.Clear();
            ItemNameComboBox.SelectedIndex = -1;
            QuantityTextBox.Clear();
            UnitPriceTextBox.Clear();
            CurrentStockTextBox.Clear();
            TotalAmountTextBox.Text = "0";
            SalesTaxTextBox.Text    = "0";
            TotalToPayTextBox.Text  = "0";

            CartDataGridView.DataSource = null;
            shoppingCart.Clear();
        }
        /// <summary>
        /// The currently selected book in the ComboBox will be added to the order summary grid.
        /// If the selection already exists in the table, the quantity is updated and the line total recalculates.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddTitleButton_Click(object sender, EventArgs e)
        {
            // Check if user has selected a book in the dropDown menu. If not,
            // show message and set focus to the dropDown.
            if (BookSelectionBox.SelectedIndex == -1)
            {
                BookSelectionBox.Focus();
                MessageBox.Show("Select a Book from the DropDown Menu first.", "No Book Selected");
                return;
            }

            // Following block checks if value passed in quantity box is valid.
            // If not, display message and set focus to quantity box.
            int parse;

            if (int.TryParse(QuantityTextBox.Text, out parse) == false || parse == 0)
            {
                MessageBox.Show("Enter a valid quantity.", "Invalid Quantity");
                QuantityTextBox.Clear();
                QuantityTextBox.Focus();
                return;
            }

            string[] bookData         = new string[4];
            string   connectionString = "server=localhost;user=root;database=book store;password="******"select title, author, isbn, price from books where title='{BookSelectionBox.Text}'", DBConnect);
                // Open Connection and retrieve data using mysql reader
                // SRC: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/retrieving-data-using-a-datareader
                DBConnect.Open();

                // Read book data into bookData array.
                MySqlDataReader reader = command.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();
                    bookData[0] = reader.GetString(0);
                    bookData[1] = reader.GetString(1);
                    bookData[2] = reader.GetString(2);
                    bookData[3] = reader.GetString(3);
                }
                DBConnect.Close();
            }

            Book tempBook   = new Book(bookData[1], bookData[2], bookData[3], bookData[0]); // Create a tempBook to alias the currently selected item in the comboBox.
            int  currentQty = 0;                                                            // Variable will track quantity of selected book already in the data grid.
            bool inTable    = false;                                                        // Variable tracks whether the selected book is already in the grid.

            // Foreach loop checks if entry already exists. Also updates global qty.
            foreach (DataGridViewRow row in OrderSummaryData.Rows)
            {
                // If entry already exists, update currentQty.
                if (row.Cells[0].Value.ToString().Contains(tempBook.Title))
                {
                    currentQty     += Convert.ToInt32(row.Cells[2].Value);
                    currentRowIndex = row.Index;
                    inTable         = true;
                }
            }


            // If entry didn't exist in table, create a row and set row index to the new row.
            if (!inTable)
            {
                // If this is a subsequent addition.
                if (firstTitleAdded)
                {
                    // Add a row and set to the new row's index - 1. I could not figure out why this was
                    // necessary but it was the only way I could get the form to work.
                    OrderSummaryData.Rows.Add();
                    currentRowIndex = OrderSummaryData.NewRowIndex - 1;
                }
                // If this is the first addition, set the bool and continue at first index.
                else
                {
                    firstTitleAdded = true;
                }
            }
            // Set the cells of the added row to the book's attributes.
            OrderSummaryData.Rows[currentRowIndex].Cells[0].Value = tempBook.Title;
            OrderSummaryData.Rows[currentRowIndex].Cells[1].Value = tempBook.Price;
            // Update the quantity with the previous qty, if any, plus the new user-input qty.
            OrderSummaryData.Rows[currentRowIndex].Cells[2].Value = Convert.ToInt32(QuantityTextBox.Text) + currentQty;

            // Extract the price, without the dollar sign, and multiply it with the quantity.
            double num1  = Convert.ToDouble(OrderSummaryData.Rows[currentRowIndex].Cells[2].Value);
            double num2  = Convert.ToDouble(tempBook.Price.Substring(1));
            double total = num1 * num2;

            OrderSummaryData.Rows[currentRowIndex].Cells[3].Value = total.ToString("C2");   // Add to 0.00 to keep 2 numbers after decimal point.

            // Calculate subtotal, tax, and total. Re-using num1 and num2 as subtotal and tax, respectively.
            num1 = 0; num2 = 0; total = 0;
            // Loop adds each line total and stores in num1 (subtotal).
            foreach (DataGridViewRow row in OrderSummaryData.Rows)
            {
                string temp = row.Cells[3].Value.ToString();   // First create a temp string with the line total string.
                num1 += Convert.ToDouble(temp.Substring(1));   // Extract the string without the '$' and store as subtotal.
            }

            num2  = 0.1 * num1;     // Calculate tax (10% of subtotal).
            total = num1 + num2;    // Total = tax + subtotal.

            // Set the textBoxes with subtotal, tax, total.
            SubtotalTextBox.Text      = num1.ToString("C2");
            TaxTextBox.Text           = num2.ToString("C2");
            TotalTextBox.Text         = total.ToString("C2");
            CancelOrderButton.Enabled = true;       // Allow cancel order
        }
Exemple #14
0
        private void AddNewProduct_Click(object sender, EventArgs e)
        {
            if (IDTextBox.Text == "")
            {
                MessageBox.Show("ID can't be blank!!!", "Blank ID");
            }
            else if (NameTextBox.Text == "")
            {
                MessageBox.Show("Name can't be blank!!!", "Blank Name");
            }
            else if (UnitListComboBox.Text == "")
            {
                MessageBox.Show("Unit can't be blank!!!", "Blank Quantity");
            }
            else if (QuantityTextBox.Text == "")
            {
                MessageBox.Show("Quantity can't be blank!!!", "Blank Quantity");
            }
            else if (MoneyTextBox.Text == "")
            {
                MessageBox.Show("Money can't be blank!!!", "Blank Quantity");
            }
            else if (MoneyUnitComboBox.Text == "")
            {
                MessageBox.Show("Money Unit can't be blank!!!", "Blank Quantity");
            }
            else
            {
                int size   = -1;
                int result = -1;
                try
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("id", typeof(int));
                    dt.Columns.Add("name", typeof(string));
                    dt.Columns.Add("unit", typeof(string));
                    dt.Columns.Add("quantity", typeof(int));
                    dt.Columns.Add("money", typeof(int));
                    dt.Columns.Add("moneyunit", typeof(string));
                    size = 0;

                    DBUtils.OpenConnection(conn);
                    string cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductID='" + IDTextBox.Text + "' or ProductName='" + NameTextBox.Text.ToUpper() + "';";

                    SqlCommand    command    = new SqlCommand(cmd, conn);
                    SqlDataReader dataReader = command.ExecuteReader();

                    Product temp = new Product();
                    while (dataReader.Read())
                    {
                        temp.setID((int)dataReader.GetValue(0));
                        temp.setName(dataReader.GetValue(1).ToString().ToUpper());
                        temp.setUnit(dataReader.GetValue(2).ToString());
                        temp.setQuantity((int)dataReader.GetValue(3));
                        temp.setMoney((int)dataReader.GetValue(4));
                        temp.setMoneyunit(dataReader.GetValue(5).ToString());

                        if (temp.getID() == Int32.Parse(IDTextBox.Text) | (temp.getName().ToUpper().CompareTo(NameTextBox.Text.ToUpper()) == 0))
                        {
                            dt.Rows.Add(temp.getID(), temp.getName().ToUpper(), temp.getUnit(), temp.getQuantity(), temp.getMoney(), temp.getMoneyunit());
                            Console.WriteLine(dt.Rows[size].Field <int>(0) + "\t" + dt.Rows[size].Field <string>(1) + "\t"
                                              + dt.Rows[size].Field <string>(2) + "\t" + dt.Rows[size].Field <int>(3) + "\t"
                                              + dt.Rows[size].Field <int>(4) + "\t" + dt.Rows[size].Field <string>(5));
                            Console.WriteLine("BYID - > size:" + size);
                            size++;
                        }
                    }
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);

                    if (size == 0)
                    {
                        string Query = "insert into StockManagementSystemDatabase.dbo.Product_Cards_Table(ProductID,ProductName,ProductUnit,ProductQuantity, ProductMoney, ProductMoneyUnit) " +
                                       "values('" + this.IDTextBox.Text + "','" + this.NameTextBox.Text.ToUpper() + "','" + this.UnitListComboBox.Text + "','" + this.QuantityTextBox.Text +
                                       "','" + this.MoneyTextBox.Text + "','" + this.MoneyUnitComboBox.Text + "');";

                        SqlCommand MyCommand = new SqlCommand(Query, conn);

                        DBUtils.OpenConnection(conn);
                        MyCommand.ExecuteNonQuery();
                        MessageBox.Show("Save product", "SUCCESS INSERT");

                        //FillDataGridView();

                        cardTable.Rows.Add(this.IDTextBox.Text, this.NameTextBox.Text.ToUpper(), this.UnitListComboBox.Text, this.QuantityTextBox.Text, this.MoneyTextBox.Text, this.MoneyUnitComboBox.Text);
                        DataGridView_Products.DataSource = cardTable;
                        DataGridView_Products.Refresh();


                        string Query2 = "insert into StockManagementSystemDatabase.dbo.Move_Table(MoveProductID,MoveType,MoveDate,MoveQuantity,MoveQuantityUnit) " +
                                        "values('" + this.IDTextBox.Text + "','entry','" + DateTime.Today.ToString("yyyy-MM-dd") + "','" + this.QuantityTextBox.Text + "','" + this.UnitListComboBox.Text + "');";

                        SqlCommand MyCommand2 = new SqlCommand(Query2, conn);

                        DBUtils.OpenConnection(conn);
                        MyCommand2.ExecuteNonQuery();
                        DBUtils.CloseConnection(conn);


                        result = 1;
                    }
                    else
                    {
                        result = 2;
                    }
                }
                catch
                {
                    if (result == 2)
                    {
                        MessageBox.Show("Same Product", "WARNING");
                        IDTextBox.Clear();
                        NameTextBox.Clear();
                    }
                    else if (result == -1)
                    {
                        MessageBox.Show("NOLUYO!");
                    }
                }
                finally
                {
                    DBUtils.CloseConnection(conn);
                    DataGridView_Products.DataSource = cardTable;
                    DataGridView_Products.Refresh();
                    FillDataGridView();

                    IDTextBox.Clear();
                    NameTextBox.Clear();
                    UnitListComboBox.Text = "";
                    QuantityTextBox.Clear();
                    MoneyTextBox.Clear();
                    MoneyUnitComboBox.Text = "";
                }
            }
        }
Exemple #15
0
        private void UpdateThisButton_Click(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("id", typeof(int));
                dt.Columns.Add("name", typeof(string));
                dt.Columns.Add("unit", typeof(string));
                dt.Columns.Add("quantity", typeof(int));
                dt.Columns.Add("money", typeof(int));
                dt.Columns.Add("moneyunit", typeof(string));

                DBUtils.OpenConnection(conn);
                string cmd = "Select * from StockManagementSystemDatabase.dbo.Product_Cards_Table where ProductID=" + IDTextBox.Text + ";";

                SqlCommand    command    = new SqlCommand(cmd, conn);
                SqlDataReader dataReader = command.ExecuteReader();

                if (!dataReader.Read())
                {
                    MessageBox.Show("This product already exists.", "EXIST");
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);
                }
                else
                {
                    dataReader.Close();
                    DBUtils.CloseConnection(conn);

                    string Query = "update StockManagementSystemDatabase.dbo.Product_Cards_Table set ProductID='" + IDTextBox.Text
                                   + "',ProductName='" + NameTextBox.Text + "',ProductUnit='" + UnitListComboBox.Text + "',ProductQuantity='" + QuantityTextBox.Text
                                   + "',ProductMoney='" + this.MoneyTextBox.Text + "',ProductMoneyUnit='" + this.MoneyUnitComboBox.Text + "' WHERE ProductID=@ProductID;";

                    SqlCommand MyCommand = new SqlCommand(Query, conn);

                    MyCommand.Parameters.AddWithValue("@ProductID", IDTextBox.Text.ToString());

                    DBUtils.OpenConnection(conn);
                    MyCommand.ExecuteNonQuery();
                    MessageBox.Show("Update product", "SUCCESS UPDATE");
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message, "ERROR");
            }
            finally
            {
                DBUtils.CloseConnection(conn);
                FillDataGridView();

                InformationTextBox.Visible = false;
                AddNewProduct.Visible      = true;

                IDTextBox.Enabled   = true;
                NameTextBox.Enabled = true;

                IDTextBox.Clear();
                NameTextBox.Clear();
                UnitListComboBox.Text = "";
                QuantityTextBox.Clear();
                MoneyTextBox.Clear();
                MoneyUnitComboBox.Text = "";
            }
        }
Exemple #16
0
        private void AddToCartButton_Click(object sender, EventArgs e)
        {
            if (IsValidated())
            {
                if (Convert.ToInt16(QuantityTextBox.Text.Trim()) > Convert.ToInt16(CurrentStockTextBox.Text))
                {
                    MessageBox.Show("Quantity can't be greater than current stock!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                bool hasSameProductSelectedAgain = false;


                //If Product Is Reselected and Add it's value so update it's previous Value
                foreach (DataGridViewRow row in CartDataGridView.Rows)
                {
                    if (Convert.ToInt16(row.Cells["ItemId"].Value) == Convert.ToInt16(ItemNameComboBox.SelectedValue))
                    {
                        row.Cells["Quantity"].Value   = Convert.ToInt16(row.Cells["Quantity"].Value) + Convert.ToInt16(QuantityTextBox.Text);
                        row.Cells["TotalPrice"].Value = Convert.ToInt16(row.Cells["Quantity"].Value) * Convert.ToDecimal(row.Cells["UnitPrice"].Value);
                        hasSameProductSelectedAgain   = true;
                    }
                }

                if (hasSameProductSelectedAgain == false)
                {
                    CartItem item = new CartItem()
                    {
                        ItemId     = Convert.ToInt16(ItemNameComboBox.SelectedValue),
                        ItemName   = ItemNameComboBox.Text,
                        Quantity   = Convert.ToInt16(QuantityTextBox.Text.Trim()),
                        UnitPrice  = Convert.ToDecimal(UnitPriceTextBox.Text.Trim()),
                        TotalPrice = Convert.ToInt16(QuantityTextBox.Text.Trim()) * Convert.ToDecimal(UnitPriceTextBox.Text.Trim())
                    };

                    // Array, Collection, List, DataTable and DataSet
                    shoppingCart.Add(item);

                    CartDataGridView.DataSource = null;
                    CartDataGridView.DataSource = shoppingCart;
                }

                decimal totalAmount = shoppingCart.Sum(x => x.TotalPrice);
                TotalAmountTextBox.Text = totalAmount.ToString();

                decimal totalSalesTax = (16 * totalAmount) / 100;
                SalesTaxTextBox.Text = totalSalesTax.ToString();

                decimal totalPay = totalAmount + totalSalesTax;
                TotalToPayTextBox.Text = totalPay.ToString();

                //update stock in MySQL
                int productId = Convert.ToInt16(ItemNameComboBox.SelectedValue);
                int quantity  = Convert.ToInt16(QuantityTextBox.Text);
                UpdateStockLevel(productId, quantity);


                ItemNameComboBox.SelectedIndex = -1;
                QuantityTextBox.Clear();
                UnitPriceTextBox.Clear();
                CurrentStockTextBox.Clear();
            }
        }
Exemple #17
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if ((int)companyNameComboBox.SelectedValue == -1)
            {
                MessageBox.Show("Please Select a Company");
                return;
            }
            if ((int)itemNameComboBox.SelectedValue == -1)
            {
                MessageBox.Show("Please Select a Item");
                return;
            }
            StockOut newStockOut = new StockOut();

            newStockOut.CompanyId = (int)companyNameComboBox.SelectedValue;
            newStockOut.ItemId    = (int)itemNameComboBox.SelectedValue;
            int Quantity;

            if (int.TryParse(QuantityTextBox.Text, out Quantity))
            {
                if (Quantity > 0)
                {
                    int availableQuantity = Convert.ToInt32(availableQuantityTextBox.Text);
                    newStockOut.TakenQuantity = Quantity;
                }
                else
                {
                    MessageBox.Show("Please Enter Amount for Stock");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Invalid Value");
                return;
            }
            newStockOut.InsertDate = DateTime.Now;
            //newStockOut.AvailableQuantity = Convert.ToInt32(availableQuantityTextBox.Text) - Convert.ToInt32(QuantityTextBox.Text);
            //newStockOut.ReorderLevel = Convert.ToInt32(reorderlevelTextBox.Text);
            //if (newStockOut.AvailableQuantity>newStockOut.TakenQuantity)
            //{
            //    int count = 0;
            //    List<StockOut> stockOuts = new List<StockOut>();
            //    stockOuts.Add(newStockOut);
            //    foreach (StockOut stockOut in stockOuts)
            //    {
            //        count++;
            //        ListViewItem item=new ListViewItem();
            //        item.Text = count.ToString();
            //        if (!list)
            //        {

            //        }
            //    }
            //}
            companyNameComboBox.SelectedValue = -1;
            itemNameComboBox.SelectedValue    = -1;
            reorderlevelTextBox.Clear();
            availableQuantityTextBox.Clear();
            QuantityTextBox.Clear();
        }
        private void BatchPrintButton_Click(object sender, RoutedEventArgs e)
        {
            if (PrintDatePicker.SelectedDate == null)

            {
                MessageBox.Show(" Please Select Date of BatchPrint", "Applicaiton Info", MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return;
            }
            if (ModelSelectorComboBox.SelectedIndex == -1)

            {
                MessageBox.Show(" Please Select Model", "Applicaiton Info", MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return;
            }
            String model = Models[ModelSelectorComboBox.SelectedIndex].Name;
            String code  = Models[ModelSelectorComboBox.SelectedIndex].Code;



            String date = PrintDatePicker.SelectedDate.Value.ToString("yyMMdd");

            int serialNo;

            if (int.TryParse(InitialSerialNoTextBox.Text, out serialNo) == false)
            {
                MessageBox.Show(" Invalid Initial Serial No", "Applicaiton Info", MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return;
            }

            int quantity;

            if (int.TryParse(QuantityTextBox.Text, out quantity) == false)
            {
                MessageBox.Show(" Invalid Quantity of Reprints", "Applicaiton Info", MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return;
            }

            BatchPrintArgs bpa;

            if (F1RadioButton.IsChecked == true)
            {
                bpa = new BatchPrintArgs(model, code, date, serialNo, quantity, REPRINT_STAGE.F1);
            }
            else if (M1RadioButton.IsChecked == true)
            {
                bpa = new BatchPrintArgs(model, code, date, serialNo, quantity, REPRINT_STAGE.M1);
            }
            else if (IntegratedRadioButton.IsChecked == true)
            {
                bpa = new BatchPrintArgs(model, code, date, serialNo, quantity, REPRINT_STAGE.INTEGRATED);
            }
            else if (CombinationRadioButton.IsChecked == true)
            {
                bpa = new BatchPrintArgs(model, code, date, serialNo, quantity, REPRINT_STAGE.COMBINATION);
            }
            else
            {
                MessageBox.Show(" Please Select stage of Reprint", "Applicaiton Info", MessageBoxButton.OK,
                                MessageBoxImage.Information);
                return;
            }

            if (BatchPrint != null)
            {
                BatchPrint(this, bpa);
            }

            PrintDatePicker.SelectedDate        = null;
            ModelSelectorComboBox.SelectedIndex = -1;
            InitialSerialNoTextBox.Clear();
            QuantityTextBox.Clear();

            F1RadioButton.IsChecked = M1RadioButton.IsChecked = IntegratedRadioButton.IsChecked
                                                                    = CombinationRadioButton.IsChecked = false;
        }
Exemple #19
0
 void Cleardata()
 {
     QuantityTextBox.Clear();
 }