private void startersPriceEditBT(object arg)
        {
            int       serviceId = 5;
            EditPrice editPrice = new EditPrice(serviceId, user, res);

            editPrice.Show();
        }
        private void mufflerPriceEditBT(object arg)
        {
            int       serviceId = 1;
            EditPrice editPrice = new EditPrice(serviceId, user, res);

            editPrice.Show();
        }
        private void electricPriceEditBT(object arg)
        {
            int       serviceId = 8;
            EditPrice editPrice = new EditPrice(serviceId, user, res);

            editPrice.Show();
        }
        private void steeringPriceEditBT(object arg)
        {
            int       serviceId = 4;
            EditPrice editPrice = new EditPrice(serviceId, user, res);

            editPrice.Show();
        }
        private void gripPriceEditBT(object arg)
        {
            int       serviceId = 7;
            EditPrice editPrice = new EditPrice(serviceId, user, res);

            editPrice.Show();
        }
        private void suspensionPriceEditBT(object arg)
        {
            int       serviceId = 3;
            EditPrice editPrice = new EditPrice(serviceId, user, res);

            editPrice.Show();
        }
        private void enginePriceEditBT(object arg)
        {
            int       serviceId = 2;
            EditPrice editPrice = new EditPrice(serviceId, user, res);

            editPrice.Show();
        }
 private void EditQwantity_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         e.Handled          = true;
         e.SuppressKeyPress = true;
         EditPrice.Select();
     }
 }
Exemple #9
0
        public JsonResult _AddPrice(EditPrice price)
        {
            var priceEntity = price.ToEntity();

            if (!productService.TryAddPrice(priceEntity))
            {
                return(Json(false));
            }
            return(Json(true));
        }
        private void SubmitEdits_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(EditName.Text) && !string.IsNullOrWhiteSpace(EditDescription.Text) && !string.IsNullOrWhiteSpace(EditPrice.Text) && !string.IsNullOrWhiteSpace(EditQuantity.Text))
            {
                try
                {
                    connection.Open();

                    MySqlCommand cmd = new MySqlCommand();
                    cmd.CommandText = "update items set ITEM_NAME=@ItemName,ITEM_PRICE=@ItemPrice,ITEM_DESCRIPTION=@ItemDescription,ITEM_QUANTATY=@ItemQuantity where ITEM_ID=@ItemId";
                    cmd.Parameters.AddWithValue("@ItemName", EditName.Text);
                    cmd.Parameters.AddWithValue("@ItemPrice", EditPrice.Text);
                    cmd.Parameters.AddWithValue("@ItemDescription", EditDescription.Text);
                    cmd.Parameters.AddWithValue("@ItemQuantity", EditQuantity.Text);
                    cmd.Parameters.AddWithValue("@ItemId", EditId.Text);
                    cmd.Connection = connection;
                    cmd.ExecuteNonQuery();
                    MySqlCommand Com = new MySqlCommand("Select * from items ", connection);

                    MySqlDataAdapter adp = new MySqlDataAdapter(Com);
                    DataSet          ds  = new DataSet();
                    adp.Fill(ds, "LoadDataBinding");
                    EditDataGrid.DataContext = ds;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
                finally
                {
                    connection.Close();
                    MessageBox.Show("Successfully updated", "Success");
                    EditName.Clear();
                    EditDescription.Clear();
                    EditPrice.Clear();
                    EditQuantity.Clear();
                    EditId.Clear();
                }
            }
            else
            {
                MessageBox.Show("Cannot Edit Empty Row ", "ERROR");
            }
        }
        private void DeleteEdits_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(EditName.Text) && !string.IsNullOrWhiteSpace(EditDescription.Text) && !string.IsNullOrWhiteSpace(EditPrice.Text) && !string.IsNullOrWhiteSpace(EditQuantity.Text))
            {
                MessageBoxResult choice = MessageBox.Show("delete selected item ?", "confirmation", MessageBoxButton.YesNo);
                if (choice == MessageBoxResult.Yes)
                {
                    try
                    {
                        connection.Open();
                        MySqlCommand cmd = new MySqlCommand("delete from items where ITEM_ID='" + int.Parse(EditId.Text) + "'", connection);
                        cmd.ExecuteNonQuery();
                        MySqlCommand Com = new MySqlCommand("Select * from items ", connection);

                        MySqlDataAdapter adp = new MySqlDataAdapter(Com);
                        DataSet          ds  = new DataSet();
                        adp.Fill(ds, "LoadDataBinding");
                        EditDataGrid.DataContext = ds;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                    finally
                    {
                        connection.Close();
                        EditId.Clear();
                        EditName.Clear();
                        EditQuantity.Clear();
                        EditPrice.Clear();
                        EditDescription.Clear();
                        MessageBox.Show("item deleted", "confirmed");
                    }
                }
            }
            else
            {
                MessageBox.Show("Select a row to delete", "ERROR");
            }
        }