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();
        }
Exemplo n.º 2
0
        private void EditProductButton_Clickk(object sender, EventArgs e)
        {
            if (edit == -1)
            {
                AddProductButton.Hide();
                DeleteProductButton.Hide();
            }
            else
            {
                AddProductButton.Show();
                DeleteProductButton.Show();
            }

            if (edit == 1)
            {
                try
                {
                    Products[ProductsGridView.CurrentCell.RowIndex].Size  = ToInt64(SizeTextBox.Text);
                    Products[ProductsGridView.CurrentCell.RowIndex].Name  = NameTextBox.Text;
                    Products[ProductsGridView.CurrentCell.RowIndex].Price = ToDouble(PriceTextBox.Text);
                    Products[ProductsGridView.CurrentCell.RowIndex].Date  = Convert.ToString(DateTimePickerOfProduct.Value);
                    ProductsGridView.CurrentRow.SetValues(Products[ProductsGridView.CurrentCell.RowIndex].Id, Products[ProductsGridView.CurrentCell.RowIndex].Size, Products[ProductsGridView.CurrentCell.RowIndex].Date, Products[ProductsGridView.CurrentCell.RowIndex].Name, Products[ProductsGridView.CurrentCell.RowIndex].Price);
                    SizeTextBox.Clear();
                    NameTextBox.Clear();
                    PriceTextBox.Clear();
                }
                catch (Exception)
                {
                    MessageBox.Show("Ошибка");
                }
            }
            edit *= -1;
        }
Exemplo n.º 3
0
 private void ClearAllRecords()
 {
     NewCategoryTextBox.Clear();
     ItemNameTextBox.Clear();
     PriceTextBox.Clear();
     CategoryComboBox.SelectedIndex = -1;
 }
Exemplo n.º 4
0
        private void AddPhoneButton_Click(object sender, EventArgs e)
        {
            // create a cellphone object

            CellPhoneInventory myphone = new CellPhoneInventory();

            // get the phone data

            getdata(myphone);

            //Add the cell phone object to the list

            phoneList.Add(myphone);

            // add the entry to the list box

            PhoneListBox.Items.Add(myphone.Brand + " " + myphone.Model);

            // clear the contents of the textbox

            BrandTextBox.Clear();
            ModelTextBox.Clear();
            PriceTextBox.Clear();

            BrandTextBox.Focus();
        }
Exemplo n.º 5
0
 public void Cleardata()
 {
     FilenameLabel.Text = "FileNotSelected";
     PriceTextBox.Clear();
     QuantityTextBox.Clear();
     ProductCodeTextBox.Clear();
     ProductNameTextBox.Clear();
 }
Exemplo n.º 6
0
 private void AddPriceButton_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrWhiteSpace(PriceTextBox.Text))
     {
         textBox1.Text += PriceTextBox.Text + "\r\n";
         WriteTextAsync(textBox1.Text);
         PriceTextBox.Clear();
     }
 }
 private void ClearText()
 {
     PCTextBox.Clear();
     PNTextBox.Clear();
     SNTextBox.Clear();
     SCTextBox.Clear();
     PriceTextBox.Clear();
     StockTextBox.Clear();
 }
Exemplo n.º 8
0
 private void reset()
 {
     bindingDateGridView();
     idTextBox.Clear();
     NameTextBox.Clear();
     PriceTextBox.Clear();
     comboBoxOrderStatus.SelectedIndex = 0;
     comboBoxType.SelectedIndex        = 0;
 }
 /// <summary>
 /// Clears fields and sets necessary fields to prepare for
 /// save.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NewBookButton_Click(object sender, EventArgs e)
 {
     AuthorTextBox.Clear();
     TitleTextBox.Clear();
     ISBNTextBox.Clear();
     PriceTextBox.Clear();
     BookSelectBox.Enabled = false;
     SaveButton.Enabled    = true;
     CancelButton.Enabled  = true;
 }
Exemplo n.º 10
0
 public void Clear()
 {
     PCODETextBox.Clear();
     BarcodeTextBox.Clear();
     PDescTextBox.Clear();
     BrandComboBox.Text    = "";
     CategoryComboBox.Text = "";
     PriceTextBox.Clear();
     PCODETextBox.Focus();
     SaveButton.Enabled   = true;
     UpdateButton.Enabled = false;
 }
Exemplo n.º 11
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();
        }
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are You Really Want To Update This Record", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (result == DialogResult.OK)
            {
                UpdateAllItems();
                MessageBox.Show("Record Updated Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CategoryComboBox.SelectedIndex = -1;
                ItemNameTextBox.Clear();
                PriceTextBox.Clear();
            }
        }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            // Check for empty boxes.
            if (AuthorTextBox.Text == "" || TitleTextBox.Text == "" || ISBNTextBox.Text == "" || PriceTextBox.Text == "" ||
                !Regex.IsMatch(AuthorTextBox.Text, author) || !Regex.IsMatch(TitleTextBox.Text, title) || !Regex.IsMatch(ISBNTextBox.Text, isbn) ||
                !Regex.IsMatch(PriceTextBox.Text, price))
            {
                MessageBox.Show("Invalid Entry:\nAuthor must be First Last\nISBN must be digits only\nPrice must be $xxx.xx format");
                return;
            }

            // Display messagebox -> If user clicks no, cancel database update.
            if (MessageBox.Show("Confirm Update?", "", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            string          ConnectionString = "server=localhost;user=root;database=book store;password="******"Insert into books values(null,'{TitleTextBox.Text}','{AuthorTextBox.Text}','{ISBNTextBox.Text}','{PriceTextBox.Text}')";
                cmd.Connection  = DBConnect;
                cmd.ExecuteNonQuery();
                DBConnect.Close();

                AuthorTextBox.Clear();
                TitleTextBox.Clear();
                ISBNTextBox.Clear();
                PriceTextBox.Clear();

                // Call function to update the combobox with new book added.
                BookSelectComboBox_Click(sender, e);

                BookSelectBox.Enabled = true;
                SaveButton.Enabled    = false;
                MessageBox.Show("Book added to database.");
                return;
            }
            // Else update the currently selected book
            cmd.CommandText = $"Update books set title='{TitleTextBox.Text}', author='{AuthorTextBox.Text}',isbn='{ISBNTextBox.Text}',price='{PriceTextBox.Text}' where title='{BookSelectBox.Text}'";
            cmd.Connection  = DBConnect;
            cmd.ExecuteNonQuery();
            DBConnect.Close();
            MessageBox.Show("Book successfully updated.");
        }
Exemplo n.º 14
0
 private void AddProductButton_Click(object sender, EventArgs e)
 {
     try
     {
         Products.Add(new StoredProduct(NameTextBox.Text, ToDouble(PriceTextBox.Text), ToInt64(SizeTextBox.Text), Convert.ToString(DateTimePickerOfProduct.Value)));
         ProductsGridView.Rows.Add(Products[Product.ID - 1].Id, Products[Product.ID - 1].Size, Products[Product.ID - 1].Date, Products[Product.ID - 1].Name, Products[Product.ID - 1].Price);
     }
     catch (Exception)
     {
         MessageBox.Show("Не все данные введены корректно.");
     }
     SizeTextBox.Clear();
     NameTextBox.Clear();
     PriceTextBox.Clear();
     EnabledButtons();
 }
Exemplo n.º 15
0
        private void AddProoductButton_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();

            con.ConnectionString = ConfigurationManager.ConnectionStrings["MassiveDynamic.Properties.Settings.MassiveDynamicConnectionString"].ConnectionString;

            string insertIntoProductId   = "'" + ProductIDTextBox.Text + "'";
            string insertIntoProductName = "'" + ProductNameTextBox.Text + "'";
            string insertIntoCaegoryId   = "'" + CategoryIdComboBox.Text + "'";
            string insertIntoQPE         = "'" + QuantityPerUnitTextBox.Text + "'";
            string insertIntoUnitPrice   = "'" + PriceTextBox.Text + "'";

            string command = string.Format("insert into Products(ProductID,ProductName,CategoryID,QuantityPerUnit,UnitPrice) values ({0},{1},{2},{3},{4})", insertIntoProductId, insertIntoProductName, insertIntoCaegoryId, insertIntoQPE, insertIntoUnitPrice);

            SqlCommand com = new SqlCommand(command, con);

            com.CommandType = CommandType.Text;
            try
            {
                con.Open();
                com.ExecuteNonQuery();

                MessageBox.Show("Данните са добавени успешно!");
                ProductIDTextBox.Clear();
                ProductNameTextBox.Clear();
                QuantityPerUnitTextBox.Clear();
                PriceTextBox.Clear();
            }
            catch (Exception exe)
            {
                //извеждаме съобщение с възникналото изключение
                MessageBox.Show(exe.ToString(), "Message/Съобщение:");
            }
            finally
            {
                con.Close();
                this.Close();
            }
        }
Exemplo n.º 16
0
 public void clear()
 {
     ItemTextBox.Clear();
     PriceTextBox.Clear();
     CategoryBox.Text = "";
 }