Пример #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (Product == null) {
                Product = new Product();
            }
            if (Product.ProductMaster == null)
            {
                Product.ProductMaster = new ProductMaster();
            }
            Product.ProductMaster.ProductName = txtProductName.Text;

            this.Close();
        }
Пример #2
0
 private object[] AddProductToDataGrid(Product product, int rowIndex)
 {
     var obj = new object[MAX_COLUMNS];
     obj[PRODUCT_PRICE_POS] = product.Price;
     obj[PRODUCT_QUANTITY_POS] = product.Quantity;
     if (product.ProductMaster != null)
     {
         obj[PRODUCT_ID_POS] = product.ProductMaster.ProductMasterId;
         obj[PRODUCT_NAME_POS] = product.ProductMaster.ProductName;
         obj[PRODUCT_TYPE_POS] = product.ProductMaster.ProductType.TypeName;
         obj[PRODUCT_SIZE_POS] = product.ProductMaster.ProductSize.SizeName;
         obj[PRODUCT_COLOR_POS] = product.ProductMaster.ProductColor.ColorName;
     }
     obj[MAX_COLUMNS - 1] = rowIndex;
     return obj;
 }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            PurchaseOrderDetail orderDetail = pODList.AddNew();
            orderDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            orderDetail.CreateDate = DateTime.Now;
            orderDetail.UpdateDate = DateTime.Now;
            orderDetail.UpdateId = orderDetail.CreateId;
            orderDetail.DelFlg = 0;
            orderDetail.DepartmentId = CurrentDepartment.Get().DepartmentId;
            orderDetail.Quantity = 1;
            if (GoodsSaleController.PurchaseOrder == null)
            {
                PurchaseOrder order = new PurchaseOrder();
                GoodsSaleController.PurchaseOrder = order;
            }
            orderDetail.PurchaseOrder = GoodsSaleController.PurchaseOrder;
            PurchaseOrderDetailPK purchaseOrderDetailPK = new PurchaseOrderDetailPK();
            purchaseOrderDetailPK.DepartmentId = CurrentDepartment.Get().DepartmentId;
            orderDetail.PurchaseOrderDetailPK = purchaseOrderDetailPK;

            // new product to test
            ProductMaster productMaster = new ProductMaster();
            orderDetail.ProductMaster = productMaster;
            Product product = new Product();
            product.ProductMaster = orderDetail.ProductMaster;
            orderDetail.Product = product;

            GoodsSaleController.PurchaseOrder.PurchaseOrderDetails =
                ObjectConverter.ConvertToNonGenericList<PurchaseOrderDetail>(pODList);
            bdsBill.EndEdit();
            //bdsBill.EndEdit();
        }
Пример #4
0
        public long FindConfirmingQuantity(Product product)
        {
            return (long)HibernateTemplate.Execute(
                                delegate(ISession session)
                                {
                                    IList list = null;
                                    try
                                    {
                                        string queryString =
                                            " SELECT SUM(sodet.Quantity) FROM StockOutDetail sodet,StockOut so " +
                                            " WHERE sodet.StockOut.StockoutId = so.StockoutId AND so.ConfirmFlg = 1 AND so.DelFlg = 0 " +
                                            " AND sodet.DelFlg = 0 and sodet.Product.ProductId = :stockOutId GROUP BY sodet.Product.ProductId";

                                        IQuery iQuery = session.CreateQuery(queryString);
                                        iQuery.SetParameter("stockOutId", product.ProductId);
                                        list = iQuery.List();
                                        if (list == null || list.Count != 1)
                                            return (long)0;
                                        return (long)list[0];
                                    }
                                    catch (Exception e)
                                    {
                                        Console.Out.WriteLine(e.Message);
                                        return 0;
                                    }

                                }
                                );
        }
Пример #5
0
 public long FindConfirmingQuantity(Product product)
 {
     return StockOutDetailDAO.FindConfirmingQuantity(product);
 }
 private bool ExistInList(IList list, Product product)
 {
     foreach (Product product1 in list)
     {
         if(product1.ProductId.Equals(product.ProductId))
         {
             return true;
         }
     }
     return false;
 }
Пример #7
0
        private void dgvProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                var productMasterForm = GlobalUtility.GetFormObject<ProductMasterSearchOrCreateForm>(FormConstants.PRODUCT_MASTER_SEARCH_OR_CREATE_FORM);
                productMasterForm.ShowDialog();

                if (productMasterForm.SelectedProductMaster != null)
                {
                    // check if the product master already existed
                    foreach (Product product in BlockInDetail.Products)
                    {
                        if (product.ProductMaster != null && product.ProductMaster.ProductMasterId == productMasterForm.SelectedProductMaster.ProductMasterId)
                        {
                            return;
                        }
                    }

                    if (e.RowIndex < BlockInDetail.Products.Count)
                    {
                        var product = (Product)BlockInDetail.Products[e.RowIndex];
                        product.ProductMaster = productMasterForm.SelectedProductMaster;
                        ModifyDataGrid(product, e.RowIndex);
                        //BindDataToProducts();
                        //PopulateDataGrid();
                    }
                    else
                    {
                        var product = new Product
                                          {
                                              ProductMaster = productMasterForm.SelectedProductMaster
                                          };
                        BlockInDetail.Products.Add(product);
                        ModifyDataGrid(product, e.RowIndex);
                        //BindDataToProducts();
                        //PopulateDataGrid();
                    }
                }
            }
        }
Пример #8
0
 /// <summary>
 /// Delete Product from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(Product data)
 {
     HibernateTemplate.Delete(data);
 }
Пример #9
0
 /// <summary>
 /// Add Product to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public Product Add(Product data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
Пример #10
0
 public void Update(Product data)
 {
     ProductDAO.Update(data);
 }
Пример #11
0
        private void ModifyDataGrid(Product product, int rowIndex)
        {
            dgvProduct[PRODUCT_PRICE_POS + 1, rowIndex].Value = product.Price;
            dgvProduct[PRODUCT_QUANTITY_POS + 1, rowIndex].Value = product.Quantity;
            if (product.ProductMaster != null)
            {
                dgvProduct[PRODUCT_ID_POS + 1, rowIndex].Value = product.ProductMaster.ProductMasterId;
                dgvProduct[PRODUCT_NAME_POS + 1, rowIndex].Value = product.ProductMaster.ProductName;
                if (product.ProductMaster.ProductType != null)
                {
                    dgvProduct[PRODUCT_TYPE_POS + 1, rowIndex].Value = product.ProductMaster.ProductType.TypeName;
                }

                if (product.ProductMaster.ProductSize != null)
                {
                    dgvProduct[PRODUCT_SIZE_POS + 1, rowIndex].Value = product.ProductMaster.ProductSize.SizeName;
                }

                if (product.ProductMaster.ProductColor != null)
                {
                    dgvProduct[PRODUCT_COLOR_POS + 1, rowIndex].Value = product.ProductMaster.ProductColor.ColorName;
                }
                if (product.ProductMaster.Country != null)
                {
                    dgvProduct[PRODUCT_COUNTRY_POS + 1, rowIndex].Value = product.ProductMaster.Country.CountryName;
                }
                if (product.ProductMaster.Manufacturer != null)
                {
                    dgvProduct[PRODUCT_SUPPLIER_POS + 1, rowIndex].Value = product.ProductMaster.Manufacturer.ManufacturerName;
                }
            }
            else
            {
                dgvProduct[PRODUCT_ID_POS + 1, rowIndex].Value = "";
                dgvProduct[PRODUCT_NAME_POS + 1, rowIndex].Value = "";
                dgvProduct[PRODUCT_TYPE_POS + 1, rowIndex].Value = "";
                dgvProduct[PRODUCT_SIZE_POS + 1, rowIndex].Value = "";
                dgvProduct[PRODUCT_COLOR_POS + 1, rowIndex].Value = "";
                dgvProduct[PRODUCT_COUNTRY_POS + 1, rowIndex].Value = "";
                dgvProduct[PRODUCT_SUPPLIER_POS + 1, rowIndex].Value = "";
            }
        }
Пример #12
0
 /// <summary>
 /// Update Product to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Update(Product data)
 {
     HibernateTemplate.Update(data);
 }
Пример #13
0
        private void dgvProduct_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex >= 0 && e.RowIndex < DepartmentStockInDetailList.Count)
            {
            /*                if (CurrentDepartmentStockIn != null)
                {
                    string productId = dgvProduct[PRODUCT_ID_POS + 1, e.RowIndex].Value.ToString();
                    foreach (DepartmentStockInDetail d in DepartmentStockInDetailList)
                    {
                        if (d.Product.ProductMaster != null
                                && d.Product.ProductMaster.ProductMasterId != null
                                && d.Product.ProductMaster.ProductMasterId.Equals(productId))
                        {
                            return;
                        }
                    }
                }
                */
                var productMasterForm = GlobalUtility.GetFormObject<ProductMasterSearchOrCreateForm>(FormConstants.PRODUCT_MASTER_SEARCH_OR_CREATE_FORM);
                productMasterForm.ShowDialog();
                ProductMaster productMaster = productMasterForm.SelectedProductMaster;
                if (productMaster != null)
                {
                    // check if the product master already existed
                    foreach (DepartmentStockInDetail stockInDetail in DepartmentStockInDetailList)
                    {
                        if (stockInDetail.Product != null && stockInDetail.Product.ProductMaster != null && stockInDetail.Product.ProductMaster.ProductMasterId == productMaster.ProductMasterId)
                        {
                            return;
                        }
                    }

                    if (e.RowIndex < DepartmentStockInDetailList.Count)
                    {
                        var stockInDetail = (DepartmentStockInDetail)DepartmentStockInDetailList[e.RowIndex];
                        if (stockInDetail.Product == null)
                        {
                            stockInDetail.Product = new Product();
                        }
                        stockInDetail.Product.ProductMaster = productMaster;
                        ModifyDataGrid(stockInDetail.Product, e.RowIndex);
                    }
                    else
                    {
                        var product = new Product
                                          {
                                              ProductMaster = productMaster
                                          };
                        DepartmentStockInDetailList.Add(new DepartmentStockInDetail { Product = product });
                        ModifyDataGrid(product, e.RowIndex);
                    }
                }
            }
        }
 private Stock GetStockOfProduct(Product product, IList stockList)
 {
     foreach (Stock stock in stockList)
     {
         if(stock.Product.ProductId == product.ProductId)
         {
             return stock;
         }
     }
     return null;
 }
Пример #15
0
 public void Delete(Product data)
 {
     ProductDAO.Delete(data);
 }
Пример #16
0
 public Product Add(Product data)
 {
     ProductDAO.Add(data);
     return data;
 }
Пример #17
-1
        private void CreateNewBlankPurchaseOrderDetail(BindingSource bill)
        {
            PurchaseOrderDetail orderDetail = (PurchaseOrderDetail)bill.AddNew();
            orderDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
            orderDetail.CreateDate = DateTime.Now;
            orderDetail.UpdateDate = DateTime.Now;
            orderDetail.UpdateId = orderDetail.CreateId;
            orderDetail.DelFlg = 0;
            orderDetail.DepartmentId = CurrentDepartment.Get().DepartmentId;
            orderDetail.Quantity = 1;

            PurchaseOrderDetailPK purchaseOrderDetailPK = new PurchaseOrderDetailPK();
            purchaseOrderDetailPK.DepartmentId = CurrentDepartment.Get().DepartmentId;
            orderDetail.PurchaseOrderDetailPK = purchaseOrderDetailPK;

            // new product to test
            ProductMaster productMaster = new ProductMaster();
            orderDetail.ProductMaster = productMaster;
            Product product = new Product();
            product.ProductMaster = orderDetail.ProductMaster;
            orderDetail.Product = product;
            bill.EndEdit();
        }