예제 #1
0
 private void formReturn_SelectProductEvent(object sender, ProductMasterSearchDepartmentEventArgs e)
 {
     txtRetBarCode.Text = e.ReturnProduct.ProductId;
     //txtGoodsName.Text = e.ReturnProduct.ProductMaster.ProductFullName;
     txtRetQuantity.Text = "1";
     if (goodsReturnForm != null)
     {
         goodsReturnForm.SelectProductEvent -= new EventHandler<AppFrame.Presenter.GoodsIO.ProductMasterSearchDepartmentEventArgs>(formReturn_SelectProductEvent);
         goodsReturnForm.Close();
     }
 }
        void productMasterSearchDepartmentView_SearchProductMasterEvent(object sender, ProductMasterSearchDepartmentEventArgs e)
        {
            ProductMaster searchProductMaster = new ProductMaster();

            if (!string.IsNullOrEmpty(e.ProductMasterId))
            {
                /*long value = 0;
                Int64.TryParse(e.ProductMasterId, out value);*/
                searchProductMaster.ProductMasterId= e.ProductMasterId;
            }
            searchProductMaster.DelFlg = CommonConstants.DEL_FLG_NO;
            searchProductMaster.ProductName= e.ProductMasterName;

            searchProductMaster.ProductType = new ProductType();
            if (e.ProductType != null && e.ProductType.TypeId > 0)
            {

                searchProductMaster.ProductType.TypeId= e.ProductType.TypeId;
            }

            searchProductMaster.ProductSize = new ProductSize();
            if (e.ProductSize != null && e.ProductSize.SizeId > 0)
            {

                searchProductMaster.ProductSize.SizeId= e.ProductSize.SizeId;
            }

            searchProductMaster.ProductColor = new ProductColor();
            if (e.ProductColor != null && e.ProductColor.ColorId > 0)
            {

                searchProductMaster.ProductColor.ColorId= e.ProductColor.ColorId;
            }

            searchProductMaster.Country = new Country();
            if (e.Country != null && e.Country.CountryId > 0)
            {

                searchProductMaster.Country.CountryId= e.Country.CountryId;
            }

            bool allDepartment = false;
            e.ProductMasterList = ProductMasterLogic.FindAllInDepartment(searchProductMaster,allDepartment);
        }
 void productMasterSearchDepartmentView_SelectProductEvent(object sender, ProductMasterSearchDepartmentEventArgs e)
 {
 }
 void productMasterSearchDepartmentView_InitProductMasterSearchDepartmentEvent(object sender, ProductMasterSearchDepartmentEventArgs e)
 {
     var criteria = new ObjectCriteria();
     criteria.AddEqCriteria("DelFlg", (long)0);
     e.ProductTypeList = ProductTypeLogic.FindAll(criteria);
     e.ProductTypeList.Insert(0, new ProductType());
     e.ProductSizeList = ProductSizeLogic.FindAll(criteria);
     e.ProductSizeList.Insert(0, new ProductSize());
     e.ProductColorList = ProductColorLogic.FindAll(criteria);
     e.ProductColorList.Insert(0, new ProductColor());
     e.CountryList = CountryLogic.FindAll(criteria);
     e.CountryList.Insert(0, new Country());
     e.ManufacturerList = ManufacturerLogic.FindAll(criteria);
     e.ManufacturerList.Insert(0, new Manufacturer());
     e.PackagerList = PackagerLogic.FindAll(criteria);
     e.PackagerList.Insert(0, new Packager());
     e.DistributorList = DistributorLogic.FindAll(criteria);
     e.DistributorList.Insert(0, new Distributor());
 }
        private void productMasterSearchDepartmentView_SearchProductEvent(object sender, ProductMasterSearchDepartmentEventArgs e)
        {
            ProductMaster searchProductMaster = e.SelectedProductMaster;
            ObjectCriteria searchByProductMasterCriteria = new ObjectCriteria();
            searchByProductMasterCriteria.AddEqCriteria("Department", CurrentDepartment.Get());
            searchByProductMasterCriteria.AddEqCriteria("ProductMaster", searchProductMaster);
            searchByProductMasterCriteria.AddOrder("CreateDate", false);
            searchByProductMasterCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            IList productsStockIn = DepartmentStockInDetailLogic.FindAllProductMaster(searchProductMaster);
            IList productsInStock = new ArrayList();
            IList productIds = new ArrayList();
            foreach (DepartmentStockInDetail detail in productsStockIn)
            {
                productIds.Add(detail.Product.ProductId);
            }
            ObjectCriteria stockCrit = new ObjectCriteria();
            stockCrit.AddSearchInCriteria("DepartmentStockPK.ProductId", productIds);
            if(e.AvailableInStock)
            {
                stockCrit.AddGreaterCriteria("GoodQuantity", (long) 0);
            }
            IList stockList = DepartmentStockLogic.FindAll(stockCrit);
            if (stockList != null && stockList.Count > 0)
            {
                foreach (DepartmentStock departmentStock in stockList)
                {
                    departmentStock.Product = ProductLogic.FindById(departmentStock.DepartmentStockPK.ProductId);
                    productsInStock.Add(departmentStock);
                }

            }
            e.ProductsInDepartment = productsInStock;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ProductMasterSearchDepartmentForm_Load(object sender, EventArgs e)
        {
            var eventArgs = new ProductMasterSearchDepartmentEventArgs();
            EventUtility.fireEvent(InitProductMasterSearchDepartmentEvent, this, eventArgs);

            AddListItemToCombo(productMasterSearchControl.cbbProductType,
                productMasterSearchControl.cbbProductType,
                eventArgs.ProductTypeList,
                "TypeName",
                productMasterSearchControl.cbbProductType.Text,
                productMasterSearchControl.cbbProductType.Text);

            AddListItemToCombo(productMasterSearchControl.cbbProductSize,
                productMasterSearchControl.cbbProductSize,
                eventArgs.ProductSizeList,
                "SizeName",
                productMasterSearchControl.cbbProductSize.Text,
                productMasterSearchControl.cbbProductSize.Text);

            AddListItemToCombo(productMasterSearchControl.cbbProductColor,
                productMasterSearchControl.cbbProductColor,
                eventArgs.ProductColorList,
                "ColorName",
                productMasterSearchControl.cbbProductColor.Text,
                productMasterSearchControl.cbbProductColor.Text);

            AddListItemToCombo(productMasterSearchControl.cbbCountry,
                productMasterSearchControl.cbbCountry,
                eventArgs.CountryList,
                "CountryName",
                productMasterSearchControl.cbbCountry.Text,
                productMasterSearchControl.cbbCountry.Text);

            AddListItemToCombo(productMasterSearchControl.cbbManufacturer,
                productMasterSearchControl.cbbManufacturer,
                eventArgs.ManufacturerList,
                "ManufacturerName",
                productMasterSearchControl.cbbManufacturer.Text,
                productMasterSearchControl.cbbManufacturer.Text);

            AddListItemToCombo(productMasterSearchControl.cbbDistributor,
                productMasterSearchControl.cbbDistributor,
                eventArgs.DistributorList,
                "DistributorName",
                productMasterSearchControl.cbbDistributor.Text,
                productMasterSearchControl.cbbDistributor.Text);

            AddListItemToCombo(productMasterSearchControl.cbbPackager,
                productMasterSearchControl.cbbPackager,
                eventArgs.PackagerList,
                "PackagerName",
                productMasterSearchControl.cbbPackager.Text,
                productMasterSearchControl.cbbPackager.Text);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvProductMaster_SelectionChanged(object sender, EventArgs e)
 {
     DataGridViewSelectedRowCollection selectedRows = dgvProductMaster.SelectedRows;
     // if has row selected
     if(selectedRows.Count>0)
     {
         ProductMaster selectedProductMaster = productMasterBindingSource[selectedRows[0].Index] as ProductMaster;
         ProductMasterSearchDepartmentEventArgs eventArgs = new ProductMasterSearchDepartmentEventArgs();
         eventArgs.SelectedProductMaster = selectedProductMaster;
         eventArgs.AvailableInStock = chkInStock.Checked;
         EventUtility.fireEvent(SearchProductsEvent,this,eventArgs);
         IList productsInDepartment = eventArgs.ProductsInDepartment;
         deptStockList.Clear();
         foreach (DepartmentStock detail in productsInDepartment)
         {
             deptStockList.Add(detail);
         }
         // TODO : add to detail list
         //deptStockBindingSource.DataSource = productsInDepartment;
         deptStockBindingSource.EndEdit();
         dgvProducts.Refresh();
         dgvProducts.Invalidate();
     }
 }
 private void btnSelect_Click(object sender, EventArgs e)
 {
     DataGridViewSelectedRowCollection selection = dgvProducts.SelectedRows;
     if(selection.Count == 0 )
     {
         return;
     }
     if (SelectProductEvent != null)
     {
         ProductMasterSearchDepartmentEventArgs eventArgs = new ProductMasterSearchDepartmentEventArgs();
         eventArgs.ReturnProduct = deptStockList[selection[0].Index].Product;
         EventUtility.fireEvent(SelectProductEvent, this, eventArgs);
     }
     //Close();
 }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            var eventArgs = new ProductMasterSearchDepartmentEventArgs
            {
                ProductMasterId = productMasterSearchControl.txtProductMasterId.Text,
                Packager = productMasterSearchControl.cbbPackager.SelectedIndex > 0 ? ((Packager)productMasterSearchControl.cbbPackager.SelectedItem) : null,
                ProductMasterName = productMasterSearchControl.txtProductName.Text,
                ProductSize = productMasterSearchControl.cbbProductSize.SelectedIndex > 0 ? ((ProductSize)productMasterSearchControl.cbbProductSize.SelectedItem) : null,
                ProductType = productMasterSearchControl.cbbProductType.SelectedIndex > 0 ? ((ProductType)productMasterSearchControl.cbbProductType.SelectedItem) : null,
                ProductColor = productMasterSearchControl.cbbProductColor.SelectedIndex > 0 ?
                    ((ProductColor)productMasterSearchControl.cbbProductColor.SelectedItem) : null,
                Country = productMasterSearchControl.cbbCountry.SelectedIndex > 0 ? ((Country)productMasterSearchControl.cbbCountry.SelectedItem) : null,
                Manufacturer = productMasterSearchControl.cbbManufacturer.SelectedIndex > 0 ? ((Manufacturer)productMasterSearchControl.cbbManufacturer.SelectedItem) : null,
                Distributor = productMasterSearchControl.cbbDistributor.SelectedIndex > 0 ? ((Distributor)productMasterSearchControl.cbbDistributor.SelectedItem) : null
            };
            EventUtility.fireEvent(SearchProductMasterEvent, sender, eventArgs);
            IList ProductMasterList = eventArgs.ProductMasterList;
            if (ProductMasterList != null)
            {
                if(ProductMasterList.Count == 0)
                {
                    MessageBox.Show("Không tìm thấy mặt hàng nào!", "Kết quả");
                }

                productMasterBindingSource.DataSource = ProductMasterList;
                productMasterBindingSource.ResetBindings(false);
            }
        }
예제 #10
0
        private void form_SelectNewProductEvent(object sender, ProductMasterSearchDepartmentEventArgs e)
        {
            pODNewList[dgvNewBill.CurrentCell.OwningRow.Index].Product = e.ReturnProduct;
            GoodsSaleEventArgs goodsSaleEventArgs = new GoodsSaleEventArgs();
            int selectedIndex = dgvNewBill.CurrentCell.OwningRow.Index;
            goodsSaleEventArgs.SelectedIndex = selectedIndex;
            goodsSaleEventArgs.SelectedPurchaseOrderDetail = bdsNewBill[selectedIndex] as PurchaseOrderDetail;
            /*goodsSaleEventArgs.SelectedPurchaseOrderDetail.Product.ProductId =
                dgvBill.CurrentCell.Value as string;*/
            EventUtility.fireEvent(LoadGoodsEvent, this, goodsSaleEventArgs);

            // event has been modified
            if (goodsSaleEventArgs.SelectedPurchaseOrderDetail != null)
            {
                pODNewList[selectedIndex] = goodsSaleEventArgs.SelectedPurchaseOrderDetail;
                bdsNewBill.EndEdit();
                txtTotalAmount.Text = CalculateTotalPrice(pODNewList).ToString();
                CalculateCharge();
            }

            if (newForm != null)
            {
                newForm.SelectProductEvent -= new EventHandler<AppFrame.Presenter.GoodsIO.ProductMasterSearchDepartmentEventArgs>(form_SelectProductEvent);
                newForm.Close();
            }
        }