示例#1
0
 public UpdateForm(string Package_name, List <package_product_supplier> list_info, package_product_supplier selectedItem)
 {
     InsertName = Package_name;
     List_info  = list_info;
     selected   = selectedItem;
     InitializeComponent();
 }
示例#2
0
 private void btlDelete_Click(object sender, EventArgs e)
 {
     if (product_supplier_packageBox.SelectedRows.Count > 0)
     {
         package_product_supplier itemToDelete = (package_product_supplier)product_supplier_packageBox.SelectedRows[0].DataBoundItem;
         Package_Product_SupplierDB.delete_info(itemToDelete.package_id, itemToDelete.Product_id, itemToDelete.supplier_id);
         name = PackageNameCombo.SelectedItem.ToString();
         info = Package_Product_SupplierDB.getPackageinfo(name);
         DisplayBox_info(info);
     }
     else
     {
         MessageBox.Show("need to choose a row first");
     }
 }
        public static List <package_product_supplier> getPackageinfo(string packageName)
        {
            List <package_product_supplier> package_info = new List <package_product_supplier>();
            SqlConnection connection      = connectionDB.GetConnection();
            string        selectstatement = "select s.SupplierId,p.ProductId,ps.ProductSupplierId,pk.PkgName,p.ProdName,s.SupName,pps.PackageId " +
                                            "from Packages pk inner join Packages_Products_Suppliers pps " +
                                            "on pk.PackageId=pps.PackageId inner join Products_Suppliers ps " +
                                            "on pps.ProductSupplierId=ps.ProductSupplierId inner join Suppliers s on " +
                                            "ps.SupplierId=s.SupplierId inner join Products p on p.ProductId=ps.ProductId " +
                                            "where pk.PkgName=@packagename";

            SqlCommand selectCommand = new SqlCommand(selectstatement, connection);

            selectCommand.Parameters.AddWithValue("@packagename", packageName);
            try
            {
                connection.Open();
                SqlDataReader reader = selectCommand.ExecuteReader();
                while (reader.Read())
                {
                    package_product_supplier initialize_info = new package_product_supplier();
                    initialize_info.packageid         = (int)reader["PackageId"];
                    initialize_info.packagename       = reader["PkgName"].ToString();
                    initialize_info.Productid         = (int)reader["ProductId"];
                    initialize_info.Productname       = reader["ProdName"].ToString();
                    initialize_info.supplierid        = (int)reader["SupplierId"];
                    initialize_info.suppliername      = reader["SupName"].ToString();
                    initialize_info.productsupplierid = (int)reader["ProductSupplierId"];
                    package_info.Add(initialize_info);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(package_info);
        }