示例#1
0
 private void Update_Product(object sender, RoutedEventArgs e)
 {
     if (ViewModelLocator.MainViewModel.SelectedProduct != null)
     {
         if (isValid() == true)
         {
             SqlConnection con     = SQLCONNECTION.GetConnection();
             SqlCommand    command = new SqlCommand("UPDATE[PRODUCT] SET Product_Name = @Product_Name, Product_Type = @Product_Type, Quantity = @Quantity, Measurement = @Measurement, Original_Price = @Original_Price, Selling_Price = @Selling_Price WHERE Product_ID = '" + ViewModelLocator.MainViewModel.SelectedProduct.ProductID + "'", con);
             command.Parameters.AddWithValue("@Product_Name", TxtName.Text);
             command.Parameters.AddWithValue("@Product_Type", TxtType.Text);
             command.Parameters.AddWithValue("@Quantity", TxtQuantity.Text);
             command.Parameters.AddWithValue("@Measurement", TxtMeasurement.Text);
             command.Parameters.AddWithValue("@Original_Price", TxtOriginalP.Text);
             command.Parameters.AddWithValue("@Selling_Price", TxtSellingP.Text);
             con.Open();
             command.ExecuteNonQuery();
             con.Close();
             MessageBox.Show("Product Updated Successfully", "Update Product", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             MessageBox.Show("Please enter a valid input!", "Error: Invalid Input", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     ViewModelLocator.MainViewModel.RefreshProduct();
 }
示例#2
0
 private void Update_Supplier(object sender, RoutedEventArgs e)
 {
     if (ViewModelLocator.MainViewModel.SelectedSupplierName != null)
     {
         SqlConnection con     = SQLCONNECTION.GetConnection();
         SqlCommand    command = new SqlCommand("UPDATE[SUPPLIER] SET Supplier_Name=@Supplier_Name, Contact_Number=@Contact_Number, Location=@Location WHERE Supplier_ID = '" + ViewModelLocator.MainViewModel.SelectedSupplierName.SupplierID + "'", con);
         command.Parameters.AddWithValue("@Supplier_Name", TxtSName.Text);
         command.Parameters.AddWithValue("@Contact_Number", TxtCN.Text);
         command.Parameters.AddWithValue("@Location", TxtL.Text);
         con.Open();
         command.ExecuteNonQuery();
         con.Close();
         MessageBox.Show("Supplier Updated Successfully", "Update Supplier", MessageBoxButton.OK, MessageBoxImage.Information);
     }
 }
示例#3
0
 public void DeleteSupplier()
 {
     if (SelectedSupplierName != null)
     {
         if (MessageBox.Show("Are you sure?", "Delete Supplier", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             SqlConnection con     = SQLCONNECTION.GetConnection();
             SqlCommand    command = new SqlCommand("DELETE FROM [SUPPLIER] where Supplier_ID=@Supplier_ID", con);
             command.Parameters.AddWithValue("@Supplier_ID", SelectedSupplierName.SupplierID);
             con.Open();
             command.ExecuteNonQuery();
             con.Close();
         }
     }
 }
示例#4
0
 public void DeleteProduct()
 {
     if (SelectedProduct != null)
     {
         if (MessageBox.Show("Are you sure?", "Delete Product", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
         {
             SqlConnection con     = SQLCONNECTION.GetConnection();
             SqlCommand    command = new SqlCommand("DELETE FROM [PRODUCT] where Product_ID=@Product_ID", con);
             command.Parameters.AddWithValue("@Product_ID", SelectedProduct.ProductID);
             con.Open();
             command.ExecuteNonQuery();
             con.Close();
         }
     }
 }
        private void Add_Button(object sender, RoutedEventArgs e)
        {
            SqlConnection  con      = SQLCONNECTION.GetConnection();
            SqlDataAdapter adapter1 = new SqlDataAdapter();
            SqlCommand     command1 = new SqlCommand("INSERT INTO [SUPPLIER](Supplier_Name, Contact_Number, Location) VALUES (@Supplier_Name, @Contact_Number, @Location)", con);

            command1.Parameters.AddWithValue("@Supplier_Name", TxtName.Text);
            command1.Parameters.AddWithValue("@Contact_Number", TxtCN.Text);
            command1.Parameters.AddWithValue("@Location", TxtLoc.Text);
            con.Open();
            command1.ExecuteNonQuery();
            con.Close();
            DialogResult = true;
            MessageBox.Show("Supplier Added Successfully", "New Supplier", MessageBoxButton.OK, MessageBoxImage.Information);
        }
示例#6
0
        public void RefreshSupplier()
        {
            SqlConnection  con = SQLCONNECTION.GetConnection();
            SqlDataAdapter sda = new SqlDataAdapter("SELECT * From [SUPPLIER]", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);
            SupplierNameList.Clear();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                SUPPLIER supp = new SUPPLIER();
                supp.SupplierName  = dt.Rows[i]["Supplier_Name"].ToString();
                supp.SupplierID    = Convert.ToInt16(dt.Rows[i]["Supplier_ID"]);
                supp.ContactNumber = dt.Rows[i]["Contact_Number"].ToString();
                supp.Location      = dt.Rows[i]["Location"].ToString();
                SupplierNameList.Add(supp);
            }
        }
示例#7
0
        public void RefreshProduct()
        {
            SqlConnection  con = SQLCONNECTION.GetConnection();
            SqlDataAdapter sda = new SqlDataAdapter("SELECT * From [PRODUCT]", con);
            DataTable      dt  = new DataTable();

            sda.Fill(dt);

            ProductList.Clear();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                PRODUCT prod = new PRODUCT();
                prod.ProductID     = Convert.ToInt16(dt.Rows[i]["Product_ID"]);
                prod.ProductName   = dt.Rows[i]["Product_Name"].ToString();
                prod.ProductType   = dt.Rows[i]["Product_Type"].ToString();
                prod.Quantity      = Convert.ToInt16(dt.Rows[i]["Quantity"]);
                prod.Measurement   = dt.Rows[i]["Measurement"].ToString();
                prod.OriginalPrice = Convert.ToDouble(dt.Rows[i]["Original_Price"]);
                prod.SellingPrice  = Convert.ToDouble(dt.Rows[i]["Selling_Price"]);
                ProductList.Add(prod);
            }
        }
 private void Add_Button(object sender, RoutedEventArgs e)
 {
     if (isValid() == true)
     {
         SqlConnection  con      = SQLCONNECTION.GetConnection();
         SqlDataAdapter adapter1 = new SqlDataAdapter();
         SqlCommand     command1 = new SqlCommand("INSERT INTO [PRODUCT](Product_Name, Product_Type, Quantity, Measurement, Original_Price, Selling_Price) VALUES (@Product_Name, @Product_Type, @Quantity, @Measurement, @Original_Price, @Selling_Price)", con);
         command1.Parameters.AddWithValue("@Product_Name", TxtName.Text);
         command1.Parameters.AddWithValue("@Product_Type", TxtType.Text);
         command1.Parameters.AddWithValue("@Quantity", TxtQuantity.Text);
         command1.Parameters.AddWithValue("@Measurement", TxtMeasurement.Text);
         command1.Parameters.AddWithValue("@Original_Price", TxtOriginalP.Text);
         command1.Parameters.AddWithValue("@Selling_Price", TxtSellingP.Text);
         con.Open();
         command1.ExecuteNonQuery();
         con.Close();
         DialogResult = true;
         MessageBox.Show("Product Added Successfully", "New Product", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     else
     {
         MessageBox.Show("Please enter a valid input!", "Error: Invalid Input", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }