Ejemplo n.º 1
0
 public bool CheckIfExistInRepo(Product pro)
 {
     return (Task.Navigator.GetController(SaleTask.RepoView) as RepoController).CheckIfExist(pro);
 }
Ejemplo n.º 2
0
 private void DatabaseProductPersist(Product product, int changingType)
 {
     switch (changingType)
     {
         case ModelChangeEventArg.INSERT:
             ProductDao.Insert(product);
             break;
         case ModelChangeEventArg.UPDATE:
             ProductDao.Update(product);
             break;
         case ModelChangeEventArg.REMOVE:
             ProductDao.Delete(product);
             break;
     }
 }
Ejemplo n.º 3
0
        public void CancelProductToRepo(Product product, Boolean discardOnMissing)
        {
            SaleTask task = (Task as SaleTask);

            if (task.CurrentBillProduct == null)
            {
                MessageBox.Show("请选择货物");
                return;
            }

            Product removedProduct = task.CurrentBillProduct;
            (View as IBillsView).RemoveFromProductsList(removedProduct);
            task.CancelProductToRepo(removedProduct, discardOnMissing);

            (View as IBillsView).RefreshCurrentProduct();
        }
Ejemplo n.º 4
0
 public void UpdateProduct(Product product)
 {
     (Task as SaleTask).TriggerRepoProductsChanged(null, new ProductChangeEventArg(product, ModelChangeEventArg.UPDATE));
 }
Ejemplo n.º 5
0
        public void WithdrawProductsToSemiProducts(Product p, DateTime warehousingDate,int count)
        {
            SemiProduct semiproduct = (from s in SemiProductDao.GetAll()
                        where s.WarehousingDate.Date == warehousingDate.Date
                            && s.Norm.Equals(p.Norm)
                            && s.Name.Equals(p.Name)
                            && s.Material.Equals(p.Material)
                        select s).ToList<SemiProduct>()[0];

            semiproduct.Quantity += count;
            this.UpdateSemiProduct(semiproduct);
        }
Ejemplo n.º 6
0
 public void SelectProductInList(Product product)
 {
     int index = (this.productsDataGridView.DataSource as BindingSource).IndexOf(product);
     int count = this.productsDataGridView.Rows.Count;
     if(index<count && index >=0)
     {
         this.productsDataGridView.Rows[index].Selected = true;
         this.productsDataGridView.Refresh();
     }
 }
Ejemplo n.º 7
0
 public static void Delete(Product product)
 {
     DatabaseHelper.ProductCollection.Remove(Query<Product>.EQ(e => e.Id, product.Id));
 }
Ejemplo n.º 8
0
        public void AddCurrentSemiProductToProduct(SemiProduct semiproduct, int count)
        {
            if(semiproduct.Quantity < count)
            {
                MessageBox.Show("分配超额");
                return;
            }

            semiproduct.Quantity -= count;
            this.UpdateSemiProduct(semiproduct);

            List<Product> products = (from s in (Task as SaleTask).Products
                                       where
                                           s.Norm.Equals(semiproduct.Norm)
                                           && s.Name.Equals(semiproduct.Name)
                                           && s.Material.Equals(semiproduct.Material)
                                       select s).ToList<Product>();
            Product theProduct;
            if (products.Count > 0)
            {
                theProduct = products[0];
                theProduct.Quantity += count;

                (Task as SaleTask).TriggerRepoProductsChanged(null, new ProductChangeEventArg(theProduct, ModelChangeEventArg.UPDATE));
            }
            else
            {
                theProduct = new Product()
                {
                    Quantity = count,
                    Name = semiproduct.Name,
                    Norm = semiproduct.Norm,
                    Material = semiproduct.Material,
                    Demand = 0,
                };

                (Task as SaleTask).Products.Add(theProduct);
                (Task as SaleTask).TriggerRepoProductsChanged(null, new ProductChangeEventArg(theProduct, ModelChangeEventArg.INSERT));
            }
        }
Ejemplo n.º 9
0
        public bool CheckIfExist(Product pro)
        {
            List<Product> specificProduct = (from p in ProductDao.GetAll() where p.Equals(pro) select p).ToList();

            return specificProduct.Count >= 1 ? true : false;
        }
Ejemplo n.º 10
0
        /** if the returned product does not exist in repo, then create it **/
        public void ReturnProductToRepo(Product pro, int count)
        {
            // check if the product exist, if exist, then increase by extra products quantities
            List<Product> specificProduct = (from p in ProductDao.GetAll()
                                             where p.Equals(pro)
                                             select p).ToList();

            if (specificProduct.Count > 0)
            {
                specificProduct[0].Quantity += count;
                specificProduct[0].Demand += count;

                // check if exist in current repo products list
                List<Product> currentSpecificProduct = (from p in Products
                                                        where p.Equals(pro)
                                                        select p).ToList();
                // update current list
                if (currentSpecificProduct.Count > 0)
                {
                    currentSpecificProduct[0].Quantity = specificProduct[0].Quantity;
                    currentSpecificProduct[0].Demand = specificProduct[0].Demand;
                }
                TriggerRepoProductsChanged(this, new ProductChangeEventArg(specificProduct[0], ModelChangeEventArg.UPDATE));
            }
            else
            {
                Product missedProduct = pro.Clone() as Product;
                missedProduct.Demand = count;
                missedProduct.Quantity = count;
                Products.Add(missedProduct);
                TriggerRepoProductsChanged(this, new ProductChangeEventArg(missedProduct, ModelChangeEventArg.INSERT));
            }

            // check if the bill is ready for assemblage
            if (CurrentBill.Products.Count == 0 || CurrentBill.Products.Count<Product>(b => b.Quantity < b.Demand) > 0)
            {
                CurrentBill.AssemblageOK = false;
                CurrentBill.Completed = false;
            }
            BillDao.Update(CurrentBill);
        }
Ejemplo n.º 11
0
 public void RemoveFromProductsList(Product product)
 {
     (bill_productsGridView.DataSource as BindingSource).Remove(product);
 }
Ejemplo n.º 12
0
        public void CancelProductToRepo(Product product, Boolean discardOnMissing)
        {
            // check if the product exist, if exist, then increase by extra products quantities
            List<Product> specificProduct = (from p in ProductDao.GetAll()
                                            where p.Equals(product)
                                            select p).ToList();
            if(specificProduct.Count>0) // exist
            {
                // change the quantity and demand
                specificProduct[0].Quantity += product.Quantity;
                specificProduct[0].Demand -= (product.Demand - product.Quantity);

                // check if exist in current repo products list
                List<Product> currentSpecificProduct = (from p in Products
                                                        where p.Equals(product)
                                                        select p).ToList();
                // update current list
                if (currentSpecificProduct.Count > 0)
                {
                    currentSpecificProduct[0].Quantity = specificProduct[0].Quantity;
                    currentSpecificProduct[0].Demand = specificProduct[0].Demand;
                }

                TriggerRepoProductsChanged(this, new ProductChangeEventArg(specificProduct[0], ModelChangeEventArg.UPDATE));
            }

            // not exist, unconsistency state
            if(!discardOnMissing)
            {
                Product missedProduct = product.Clone() as Product;
                missedProduct.Demand = 0;
                Products.Add(missedProduct);
                TriggerRepoProductsChanged(this, new ProductChangeEventArg(missedProduct, ModelChangeEventArg.INSERT));
            }

            // check if the bill is ready for assemblage
            if (CurrentBill.Products.Count == 0 || CurrentBill.Products.Count<Product>(b => b.Quantity < b.Demand) > 0)
            {
                CurrentBill.AssemblageOK = false;
                CurrentBill.Completed = false;
            }
            BillDao.Update(CurrentBill);
        }
Ejemplo n.º 13
0
 public static void Update(Product product)
 {
     DatabaseHelper.ProductCollection.Save(product);
 }
Ejemplo n.º 14
0
 public static void Insert(Product product)
 {
     product.Id = new MongoDB.Bson.ObjectId();
     DatabaseHelper.ProductCollection.Insert<Product>(product);
 }
Ejemplo n.º 15
0
        public void ReturnProductToRepo(Product product, int count)
        {
            SaleTask task = (Task as SaleTask);

            if (task.CurrentBillProduct == null)
            {
                MessageBox.Show("请选择货物");
                return;
            }

            Product returnedProduct = task.CurrentBillProduct;
            returnedProduct.Quantity = 0;
            task.ReturnProductToRepo(returnedProduct, count);

            (View as IBillsView).RefreshCurrentProduct();
        }
Ejemplo n.º 16
0
 /*
  * product modify method
  */
 public void DeleteProduct(Product product)
 {
     // since in the form view layer, we called bindingsource.remove method, it will also delete the object of model layer
     // here we just call the event trigger method to notify the observors to take actions
     (Task as SaleTask).TriggerRepoProductsChanged(null, new ProductChangeEventArg(product, ModelChangeEventArg.REMOVE));
 }
Ejemplo n.º 17
0
 public void SetCurrentBillProduct(Product product)
 {
     (Task as SaleTask).CurrentBillProduct = product;
 }
Ejemplo n.º 18
0
        public List<SemiProduct> GetRelatedSemiProducts(Product p)
        {
            List<SemiProduct> list = (from s in SemiProductDao.GetAll()
                        where
                            s.Norm.Equals(p.Norm)
                            && s.Name.Equals(p.Name)
                            && s.Material.Equals(p.Material)
                            && s.InitialQuantity>s.Quantity
                        select s).ToList<SemiProduct>();

            return list;
        }
Ejemplo n.º 19
0
 public ProductChangeEventArg(Product changedProduct, int changingType)
 {
     this.ChangedProduct = changedProduct;
     this.ChangingType = changingType;
 }
Ejemplo n.º 20
0
 public void Set(Product p)
 {
     if (this.Name.Equals(p.Name) &&
         this.Material.Equals(p.Material) &&
         this.Norm.Equals(p.Norm))
     {
         this.Quantity = p.Quantity;
         this.Demand = p.Demand;
         this.Remark = p.Remark;
         this.UnitPrice = p.UnitPrice;
     }
     else
     {
         throw new Exception("不能对不同类型的product调用set方法");
     }
 }