예제 #1
0
 void _supplierOperationVM_OnSaved(object sender, Supplier e)
 {
     SupplierCollection.Remove(e);
     SupplierCollection.Add(e);
     _hardwareOperationVM_OnClosed(sender, new EventArgs {
     });
 }
예제 #2
0
		/// <summary>
		/// Конструктор создает объект с привязкой родительского объекта
		/// </summary>
		public Product(Product toCopy)
			: this()
		{
			if (toCopy == null) 
				return;
			_batchNumber = toCopy.BatchNumber;
			_costNew = toCopy.CostNew;
			_costOvehaul = toCopy.CostOverhaul;
			_costServiceable = toCopy.CostServiceable;
			_description = toCopy.Description;
			_manufacturer = toCopy.Manufacturer;
			_measure = toCopy.Measure;
			_partNumber = toCopy.PartNumber;
			_remarks = toCopy.Remarks;
			_serialNumber = toCopy.SerialNumber;
			_standart = toCopy.Standart;


			if (_suppliers == null)
				_suppliers = new SupplierCollection();
			_suppliers.Clear();
			foreach (Supplier supplier in toCopy.Suppliers)
			{
				_suppliers.Add(supplier);
			}

			if (_supplierRelations == null)
				_supplierRelations = new CommonCollection<KitSuppliersRelation>();
			_supplierRelations.Clear();
			foreach (KitSuppliersRelation ksr in toCopy.SupplierRelations)
			{
				_supplierRelations.Add(new KitSuppliersRelation(ksr) {KitId = ItemId});
			}
		}
        public static SupplierCollection ToDtoCollection(this EntityCollection <SupplierEntity> entities)
        {
            OnBeforeEntityCollectionToDtoCollection(entities);
            var seenObjects = new Hashtable();
            var collection  = new SupplierCollection();

            foreach (var entity in entities)
            {
                collection.Add(entity.ToDto(seenObjects, new Hashtable()));
            }
            OnAfterEntityCollectionToDtoCollection(entities, collection);
            return(collection);
        }
예제 #4
0
        public static SupplierCollection GetSupplierData()
        {
            SupplierCollection suppliers = new SupplierCollection();

            Supplier supplier = new Supplier("Supplier#1");

            suppliers.Add(supplier);
            supplier.Add(CreateProduct(supplier.SupplierID, "Product#1"));
            supplier.Add(CreateProduct(supplier.SupplierID, "Product#2"));
            supplier.Add(CreateProduct(supplier.SupplierID, "Product#3"));

            supplier = new Supplier("Supplier#2");
            suppliers.Add(supplier);
            supplier.Add(CreateProduct(supplier.SupplierID, "Product@1"));
            supplier.Add(CreateProduct(supplier.SupplierID, "Product@2"));

            supplier = new Supplier("Supplier#3");
            suppliers.Add(supplier);
            supplier.Add(CreateProduct(supplier.SupplierID, "Product:1"));
            supplier.Add(CreateProduct(supplier.SupplierID, "Product:2"));
            supplier.Add(CreateProduct(supplier.SupplierID, "Product:3"));

            return(suppliers);
        }
예제 #5
0
        /// <summary>
        /// Loads a collection of Supplier objects from the database.
        /// </summary>
        /// <returns>A collection containing all of the Supplier objects in the database.</returns>
        public static SupplierCollection LoadCollection(string spName, SqlParameter[] parms)
        {
            SupplierCollection result = new SupplierCollection();

            using (SqlDataReader reader = SqlHelper.Default.ExecuteReader(spName, parms))
            {
                while (reader.Read())
                {
                    Supplier tmp = new Supplier();
                    tmp.LoadFromReader(reader);
                    result.Add(tmp);
                }
            }
            return(result);
        }
예제 #6
0
        public void _0001_Test()
        {
            SupplierCollection suppliers = new SupplierCollection();

            suppliers.Add(new SuplierItem(1, "Lomex"));
            suppliers.Add(new SuplierItem(2, "TME"));
            suppliers.Add(new SuplierItem(3, "Farnell"));
            suppliers.Add(new SuplierItem(4, "CBA"));

            ProductCollection products = new ProductCollection();

            products.Add(new ProductItem(1, "1N4148", "Dióda", 1));
            products.Add(new ProductItem(2, "BC128", "Tranzisztor", 1));
            products.Add(new ProductItem(3, "AT90CAN128", "Processzor", 2));
            products.Add(new ProductItem(4, "ESD szönyeg", "ESD Védelem", 2));
            //products.Add(new ProductItem(5, "Henkel On", "Forrasztás", 3));
            //products.Add(new ProductItem(6, "Weller WP szürő", "Egészség", 3));
            //products.Add(new ProductItem(7, "Banán", "Gyümölcs", 2));


            /*Data SET*/
            DataSet dataSet = new DataSet("DemoDataSet");

            /*Suppliers*/
            /*SupplierId-PK,SupplierName*/
            DataTable suppliersDt = ToDataTable(suppliers, "Suppliers");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["SupplierId"] };
            dataSet.Tables.Add(suppliersDt);

            /*Products*/
            /*ProductId-PK, ProductName, Description, SupplierId*/
            DataTable productsDt = ToDataTable(products, "Products");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["ProductId"] };
            DataColumn supplierNameColumn = new DataColumn("SupplierName", typeof(string));

            productsDt.Columns.Add(supplierNameColumn);

            dataSet.Tables.Add(productsDt);

            /* */

            DataRelation productsSuppliersRelation = dataSet.Relations.Add("ProductSuppliers",
                                                                           dataSet.Tables["Suppliers"].Columns["SupplierId"],
                                                                           dataSet.Tables["Products"].Columns["SupplierId"], true);



            dataSet.AcceptChanges();

            DataGrid dg = new DataGrid();

            dg.SetDataBinding(dataSet, "Products");

            var form = new Form2();


            form.dataGridView1.DataSource = dataSet;
            form.dataGridView1.DataMember = "Products";

            form.dataGridView2.DataSource = dataSet;
            form.dataGridView2.DataMember = "Suppliers";


            Application.Run(form);
        }
예제 #7
0
        public void _0001_Test()
        {
            SupplierCollection suppliers = new SupplierCollection();

            suppliers.Add(new SuplierItem(1, "Lomex"));
            suppliers.Add(new SuplierItem(2, "TME"));
            suppliers.Add(new SuplierItem(3, "Farnell"));
            suppliers.Add(new SuplierItem(4, "CBA"));

            ProductCollection products = new ProductCollection();

            products.Add(new ProductItem(1, "1N4148", "Dióda", 1));
            products.Add(new ProductItem(2, "BC128", "Tranzisztor", 1));
            products.Add(new ProductItem(3, "AT90CAN128", "Processzor", 2));
            products.Add(new ProductItem(4, "ESD szönyeg", "ESD Védelem", 2));
            //products.Add(new ProductItem(5, "Henkel On", "Forrasztás", 3));
            //products.Add(new ProductItem(6, "Weller WP szürő", "Egészség", 3));
            //products.Add(new ProductItem(7, "Banán", "Gyümölcs", 2));


            /*Data SET*/
            DataSet dataSet = new DataSet("DemoDataSet");

            /*Suppliers*/
            /*SupplierId-PK,SupplierName*/
            DataTable suppliersDt = ToDataTable(suppliers, "Suppliers");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["SupplierId"] };
            dataSet.Tables.Add(suppliersDt);

            /*Products*/
            /*ProductId-PK, ProductName, Description, SupplierId*/
            DataTable productsDt = ToDataTable(products, "Products");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["ProductId"] };
            DataColumn supplierNameColumn = new DataColumn("SupplierName", typeof(string));

            productsDt.Columns.Add(supplierNameColumn);

            dataSet.Tables.Add(productsDt);

            /* */

            DataColumn parentColumn = dataSet.Tables["Suppliers"].Columns["SupplierId"];
            DataColumn childColumn  = dataSet.Tables["Products"].Columns["ProductId"];

            ForeignKeyConstraint fKConstraint;

            fKConstraint                  = new ForeignKeyConstraint("SupplierFKConstraint", parentColumn, childColumn);
            fKConstraint.DeleteRule       = Rule.SetNull;
            fKConstraint.UpdateRule       = Rule.Cascade;
            fKConstraint.AcceptRejectRule = AcceptRejectRule.Cascade;

            dataSet.Tables["Products"].Constraints.Add(fKConstraint);
            dataSet.EnforceConstraints = true;

            dataSet.AcceptChanges();

            var form = new Form2();


            form.dataGridView1.DataSource = dataSet;
            form.dataGridView1.DataMember = "Products";

            form.dataGridView2.DataSource = dataSet;
            form.dataGridView2.DataMember = "Suppliers";

            Application.Run(form);
        }