private void DepartmentPriceUpdateForm_Load(object sender, EventArgs e)
        {
            var eventArgs = new DepartmentPriceUpdateEventArgs();
            EventUtility.fireEvent(InitDepartmentPriceEvent, this, eventArgs);

            productMasterSearchControl.cbbProductType.DataSource = eventArgs.ProductTypeList;
            productMasterSearchControl.cbbProductType.DisplayMember = "TypeName";

            productMasterSearchControl.cbbProductSize.DataSource = eventArgs.ProductSizeList;
            productMasterSearchControl.cbbProductSize.DisplayMember = "SizeName";

            productMasterSearchControl.cbbProductColor.DataSource = eventArgs.ProductColorList;
            productMasterSearchControl.cbbProductColor.DisplayMember = "ColorName";

            productMasterSearchControl.cbbCountry.DataSource = eventArgs.CountryList;
            productMasterSearchControl.cbbCountry.DisplayMember = "CountryName";

            productMasterSearchControl.cbbDistributor.DataSource = eventArgs.DistributorList;
            productMasterSearchControl.cbbDistributor.DisplayMember = "DistributorName";

            productMasterSearchControl.cbbManufacturer.DataSource = eventArgs.ManufacturerList;
            productMasterSearchControl.cbbManufacturer.DisplayMember = "ManufacturerName";

            productMasterSearchControl.cbbDistributor.DataSource = eventArgs.DistributorList;
            productMasterSearchControl.cbbDistributor.DisplayMember = "DistributorName";
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (DepartmentPriceList != null && DepartmentPriceList.Count > 0)
            {
                IList updatePriceList = new ArrayList();
                for (int i = 0; i < dgvProduct.RowCount; i++)
                {
                    foreach (DepartmentPrice oldPrice in DepartmentPriceList)
                    {
                        if (oldPrice.ProductMaster.ProductMasterId.Equals(dgvProduct[PRODUCT_ID_POS, i].Value.ToString()))
                        {
                            long newPrice = 0;
                            // validate input
                            if (!NumberUtility.CheckLongNullIsZero(dgvProduct[PRODUCT_NEW_PRICE_POS, i].Value, out newPrice))
                            {
                                MessageBox.Show("Error at line: " + i + "");
                                return;
                            }
                            else if (newPrice != 0 && oldPrice.Price != newPrice)
                            {
                                oldPrice.Price = newPrice;
                                updatePriceList.Add(oldPrice);
                                break;
                            }
                        }
                    }
                }

                if (updatePriceList.Count > 0)
                {
                    var eventArgs = new DepartmentPriceUpdateEventArgs {DepartmentPriceList = updatePriceList};
                    EventUtility.fireEvent(SaveDepartmentPriceEvent, this, eventArgs);
                    if (_currentEventArgs != null)
                    {
                        EventUtility.fireEvent(SearchDepartmentPriceEvent, this, _currentEventArgs);
                        DepartmentPriceList = _currentEventArgs.DepartmentPriceList;
                        PopulateDataGrid();
                    }
                    MessageBox.Show("Thay đổi giá thành công");
                }
                else
                {
                    MessageBox.Show("Nothing to update");
                }
            }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            var eventArgs = new DepartmentPriceUpdateEventArgs
                                {
                                    ProductMasterId = productMasterSearchControl.txtProductMasterId.Text,
                                    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,
                                    Packager = productMasterSearchControl.cbbPackager.SelectedIndex > 0 ? ((Packager)productMasterSearchControl.cbbPackager.SelectedItem) : null
                                };
            EventUtility.fireEvent(SearchDepartmentPriceEvent, this, eventArgs);

            DepartmentPriceList = eventArgs.DepartmentPriceList;
            _currentEventArgs = eventArgs;
            PopulateDataGrid();

            DateTime dateTime = new DateTime(2008, 10, 10);
            long l = dateTime.Ticks;
        }
        private void DepartmentPriceUpdateForm_Load(object sender, EventArgs e)
        {
            var eventArgs = new DepartmentPriceUpdateEventArgs();
            EventUtility.fireEvent(InitDepartmentPriceEvent, this, eventArgs);

            productMasterSearchControl.cbbProductType.DataSource = eventArgs.ProductTypeList;
            productMasterSearchControl.cbbProductType.DisplayMember = "TypeName";

            productMasterSearchControl.cbbProductSize.DataSource = eventArgs.ProductSizeList;
            productMasterSearchControl.cbbProductSize.DisplayMember = "SizeName";

            productMasterSearchControl.cbbProductColor.DataSource = eventArgs.ProductColorList;
            productMasterSearchControl.cbbProductColor.DisplayMember = "ColorName";

            productMasterSearchControl.cbbCountry.DataSource = eventArgs.CountryList;
            productMasterSearchControl.cbbCountry.DisplayMember = "CountryName";

            productMasterSearchControl.cbbDistributor.DataSource = eventArgs.DistributorList;
            productMasterSearchControl.cbbDistributor.DisplayMember = "DistributorName";

            productMasterSearchControl.cbbManufacturer.DataSource = eventArgs.ManufacturerList;
            productMasterSearchControl.cbbManufacturer.DisplayMember = "ManufacturerName";

            productMasterSearchControl.cbbDistributor.DataSource = eventArgs.DistributorList;
            productMasterSearchControl.cbbDistributor.DisplayMember = "DistributorName";
            if(ClientSetting.IsSubStock())
            {
                btnPutPrice.Visible = false;
                btnSave.Visible = false;
                label1.Visible = false;
                label2.Visible = false;
                txtPrice.Visible = false;
                txtWholeSalePrice.Visible = false;

            }
        }
 public void departmentStockDetailView_InitDepartmentPriceUpdateEvent(object sender, DepartmentPriceUpdateEventArgs 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.ManufacturerList = ManufacturerLogic.FindAll(criteria);
     e.ManufacturerList.Insert(0, new Manufacturer());
     e.CountryList = CountryLogic.FindAll(criteria);
     e.CountryList.Insert(0, new Country());
     e.PackagerList = PackagerLogic.FindAll(criteria);
     e.PackagerList.Insert(0, new Packager());
     e.DistributorList = DistributorLogic.FindAll(criteria);
     e.DistributorList.Insert(0, new Distributor());
 }
        public void departmentStockDetailView_SearchDepartmentPriceEvent(object sender, DepartmentPriceUpdateEventArgs e)
        {
            var subCriteria = new SubObjectCriteria("ProductMaster");
            subCriteria.AddLikeCriteria("ProductMasterId", e.ProductMasterId + "%");
            subCriteria.AddLikeCriteria("ProductName", e.ProductMasterName + "%");
            subCriteria.AddEqCriteria("ProductType", e.ProductType);
            subCriteria.AddEqCriteria("ProductSize",  e.ProductSize);
            subCriteria.AddEqCriteria("ProductColor", e.ProductColor);
            subCriteria.AddEqCriteria("Country", e.Country);
            subCriteria.AddEqCriteria("Packager", e.Packager);
            subCriteria.AddEqCriteria("Manufacturer", e.Manufacturer);
            subCriteria.AddEqCriteria("Distributor", e.Distributor);

            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddSubCriteria("ProductMaster", subCriteria);
            criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", CurrentDepartment.Get().DepartmentId);

            e.DepartmentPriceList = DepartmentPriceLogic.FindAll(criteria);
        }
        public void departmentStockDetailView_SaveDepartmentPriceEvent(object sender, DepartmentPriceUpdateEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            foreach (DepartmentPrice price in e.DepartmentPriceList)
            {
                price.UpdateDate = DateTime.Now;
                price.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
                DepartmentPriceLogic.Update(price);
                sb.Append(price.ToString()).Append("\r\n");
            }
            ClientUtility.Log(logger, sb.ToString(), CommonConstants.ACTION_UPDATE_PRICE);
        }
        public void departmentStockDetailView_SearchDepartmentPriceEvent(object sender, DepartmentPriceUpdateEventArgs e)
        {
            var subCriteria = new SubObjectCriteria("ProductMaster");
            subCriteria.AddLikeCriteria("ProductMasterId", "%" + e.ProductMasterId + "%");
            if(e.AbsoluteFinding)
            {
                subCriteria.AddEqCriteria("ProductName", e.ProductMasterName);
            }
            else
            {
                subCriteria.AddLikeCriteria("ProductName", "%" + e.ProductMasterName + "%");
            }
            if(e.ProductType!=null)
            {
                subCriteria.AddEqCriteria("ProductType", e.ProductType);
            }

            if (e.ProductSize != null)
            {
                subCriteria.AddEqCriteria("ProductSize", e.ProductSize);
            }

            if (e.ProductColor != null)
            {
                subCriteria.AddEqCriteria("ProductColor", e.ProductColor);
            }

            if (e.Country != null)
            {
                subCriteria.AddEqCriteria("Country", e.Country);
            }

            if (e.Packager != null)
            {
                subCriteria.AddEqCriteria("Packager", e.Packager);
            }

            if (e.Manufacturer != null)
            {
                subCriteria.AddEqCriteria("Manufacturer", e.Manufacturer);
            }

            if (e.Distributor != null)
            {
                subCriteria.AddEqCriteria("Distributor", e.Distributor);
            }

            subCriteria.AddOrder("ProductName",false);
            subCriteria.AddOrder("ProductColor", false);
            subCriteria.AddOrder("ProductSize", false);
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            if(e.ZeroPrice)
            {
                criteria.AddEqCriteria("Price", (long) 0);
            }
            if(e.ZeroWholeSalePrice)
            {
                criteria.AddEqCriteria("WholeSalePrice", (long) 0);
            }
            criteria.AddSubCriteria("ProductMaster", subCriteria);
            /*criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", 0);*/

            e.DepartmentPriceList = DepartmentPriceLogic.FindAll(criteria);
        }