Пример #1
0
        private void simpleButton_Search_Click(object sender, EventArgs e)
        {
            //if (lookUpEditDepot.EditValue == null)
            //{
            //    MessageBox.Show(Properties.Resources.deptNotNull, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    lookUpEditDepot.Focus();
            //    return;
            //}
            Model.ProductCategory temp = this.lookUpEditProductCatogry.EditValue as Model.ProductCategory;
            products = this._productManager.GetProductByCondition(temp == null ? null : temp.ProductCategoryId, this.textEditProductNameOrId.Text, this.lookUpEditDepot.EditValue.ToString());

            stocks = (from p in products
                      select new Model.Stock()
            {
                StockId = Guid.NewGuid().ToString(),
                Product = p,
                ProductId = p.ProductId,
                StockQuantity0 = stockManager.GetTheCount0OfProductByProductId(p, this._depotManager.Get(this.lookUpEditDepot.EditValue.ToString())),
                StockQuantity1 = stockManager.GetTheCountByProduct(p),
                DepotStockQuantity = stockManager.GetTheCount1OfProductByProductId(p, this._depotManager.Get(this.lookUpEditDepot.EditValue.ToString())),
                ProductCategory = p.ProductCategory,
                GetDescription = p.ProductDescription,
                CustomerProductName = p.CustomerProductName,
                Stock0Date = stockManager.Get0DateByProduct(p.ProductId)
            }).ToList <Model.Stock>();


            this.bindingSourceStock.DataSource = stocks;
            this.gridControl1.RefreshDataSource();
            barStaticItemCount.Caption = "共" + stocks.Count + "項";
        }
        public async Task <ResponseViewModel> DeleteProductCategory(int id, string userName)
        {
            var response = new ResponseViewModel();

            try
            {
                var category = _db.ProductCategories.FirstOrDefault(d => d.Id == id);

                category = new Model.ProductCategory()
                {
                    IsActive = false
                };

                _db.ProductCategories.Update(category);
                await _db.SaveChangesAsync();

                response.IsSuccess = true;
                response.Message   = "Product category has been deleted.";
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
                response.IsSuccess = true;
                response.Message   = "Error has been occured while deleting the data. Please try again.";
            }

            return(response);
        }
Пример #3
0
        private void buttonEditProductCategoryId_EditValueChanged(object sender, EventArgs e)
        {
            Model.ProductCategory temp = this.buttonEditProductCategoryId.EditValue as Model.ProductCategory;
            //if (_stockEditor.ProductPositionNums.Count != 0)
            //{
            //    _stockEditor.ProductCategoryId = temp.ProductCategoryId;
            //    DialogResult result = MessageBox.Show("是否清理現有詳細", this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            //    switch (result)
            //    {
            //        case DialogResult.OK:
            _stockEditor.ProductPositionNums.Clear();
            // break;
            //        default:
            //            break;
            //    }
            //}
            //else
            {
                _stockEditor.ProductCategoryId = temp.ProductCategoryId;
            }
            string depotId = (this.lookUpEditDepotId.EditValue as Model.Depot) == null ? "" : (this.lookUpEditDepotId.EditValue as Model.Depot).DepotId;

            if (string.IsNullOrEmpty(depotId))
            {
                productlist = this._productManager.DataReaderBind <Model.Product>("select DepotUnitId,Id,ProductId,ProductName,ProductVersion,CustomerProductName,StocksQuantity,ProductDescription from product where ProductCategoryId='" + temp.ProductCategoryId + "'", null, CommandType.Text);
            }
            else
            {
                productlist = this._productManager.DataReaderBind <Model.Product>("select DepotUnitId,Id,ProductId,ProductName,ProductVersion,CustomerProductName,StocksQuantity,ProductDescription from product where ProductCategoryId='" + temp.ProductCategoryId + "' and ProductId in (select ProductId from Stock where DepotId='" + depotId + "')", null, CommandType.Text);
            }
            this.bindingSourceProduct.DataSource = productlist;
            this.Refresh();
        }
Пример #4
0
        private void lookUpEditProductCategory_EditValueChanged(object sender, EventArgs e)
        {
            _stockCheck.Details.Clear();
            if (this.lookUpEditProductCategory.EditValue != null)
            {
                category = this._productCategoryManager.Get(this.lookUpEditProductCategory.EditValue.ToString());
            }
            if (category != null)
            {
                foreach (Model.Product product in this._productManager.Select(category))
                {
                    Model.StockCheckDetail detail = new Book.Model.StockCheckDetail();
                    detail.StockCheckDetailId = Guid.NewGuid().ToString();
                    detail.StockCheckId       = _stockCheck.StockCheckId;

                    detail.Product            = product;
                    detail.ProductId          = product.ProductId;
                    detail.DepotPosition      = product.DepotPosition;
                    detail.DepotPositionId    = product.DepotPositionId;
                    detail.StockCheckQuantity = null;
                    detail.ProductUnitName    = product.DepotUnit.ToString();
                    _stockCheck.Details.Add(detail);
                    //this.bindingSourceEmployee.Position = this.bindingSourceEmployee.IndexOf(detail);
                }
                this.gridControl1.RefreshDataSource();
            }
        }
Пример #5
0
        //查询指定类和客户的货品和公司货品
        public IList <Model.Product> Select(Model.Customer customer, Model.ProductCategory cate)
        {
            Hashtable ht = new Hashtable();

            ht.Add("customerid", customer == null ? "" : customer.CustomerId);
            ht.Add("productcategoryid", cate == null ? "" : cate.ProductCategoryId);
            return(sqlmapper.QueryForList <Model.Product>("Product.SelectByCategoryAndCustomer", ht));
        }
Пример #6
0
        public bool ExistsExcept(Model.ProductCategory e)
        {
            Hashtable paras = new Hashtable();

            paras.Add("newId", e.Id);
            paras.Add("oldId", Get(e.ProductCategoryId) == null?null:Get(e.ProductCategoryId).Id);
            return(sqlmapper.QueryForObject <bool>("ProductCategory.existsexcept", paras));
        }
Пример #7
0
        public void MyClick(ref ChooseItem item)
        {
            ChooseForm f = new ChooseForm();

            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Model.ProductCategory productCaregory = f.SelectedItem as Model.ProductCategory;
                item = new ChooseItem(productCaregory, productCaregory.Id, productCaregory.ProductCategoryName);
            }
        }
Пример #8
0
        public void MyLeave(ref ChooseItem item)
        {
            BL.ProductCategoryManager manager         = new Book.BL.ProductCategoryManager();
            Model.ProductCategory     productCaregory = manager.GetById(item.ButtonText);

            if (productCaregory != null)
            {
                item.EditValue  = productCaregory;
                item.LabelText  = productCaregory.ProductCategoryName;
                item.ButtonText = productCaregory.Id;
            }
        }
Пример #9
0
        private void Validate(Model.ProductCategory productCategory)
        {
            if (string.IsNullOrEmpty(productCategory.Id))
            {
                throw new Helper.RequireValueException(Model.ProductCategory.PROPERTY_ID);
            }

            if (string.IsNullOrEmpty(productCategory.ProductCategoryName))
            {
                throw new Helper.RequireValueException(Model.ProductCategory.PROPERTY_PRODUCTCATEGORYNAME);
            }
        }
 public void ConvertToBusinessObject(out OnlineShoppingCart.Model.ProductCategory ProductCategory)
 {
     ProductCategory = new Model.ProductCategory
     {
         ID = this.Id,
         Category = this.Category,
         IsActive= this.IsActive,
         CreatedOn= this.CreatedOn,
         UpdatedOn= this.UpdatedOn,
         CreatedByUserID=this.CreatedByUserId,
         UpdatedByUserID= this.UpdatedByUserId
     };
 }
Пример #11
0
        public string GetNewId(Model.ProductCategory productCategory)
        {
            // this.Validate(product);
            string sequencekey = productCategory.Id;
            //SequenceManager.Increment(sequencekey);

            // SequenceManager.Increment(sequencekey);
            //  string str=
            // SequenceManager.IncrementVal(sequencekey,);

            int sequenceval = SequenceManager.GetCurrentVal(sequencekey) + 1;

            return(string.Format("{0}{1:d4}", sequencekey, sequenceval));
        }
Пример #12
0
        public JsonResult AddUpd(Model.ProductCategory pcategory)
        {
            string strResult = "FAIL";

            if (pcategory.CategoryName != null)
            {
                MoyeBuy.Com.BLL.ProductCategory category = new BLL.ProductCategory();
                if (category.AddUpdateProductCatgory(pcategory))
                {
                    strResult = "SUCCESS";
                }
            }
            return(Json(strResult));
        }
Пример #13
0
 public async Task <ProductCategory> Get(long id)
 {
     Model.ProductCategory productCategory = null;
     try
     {
         productCategory = await _context.ProductCategories
                           .FirstOrDefaultAsync(x => x.Id == Convert.ToInt64(id));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return(productCategory);
 }
Пример #14
0
        public void Delete(Model.ProductCategory productCategory)
        {
            try
            {
                BL.V.BeginTransaction();
                this.Delete(productCategory.ProductCategoryId);

                BL.V.CommitTransaction();
            }
            catch (Exception ex)
            {
                BL.V.RollbackTransaction();
                throw ex;
            }
        }
        public async Task <ResponseViewModel> SaveProductCategory(ProductCategoryViewModel vm, string userName)
        {
            var response = new ResponseViewModel();

            try
            {
                var category = _db.ProductCategories.FirstOrDefault(d => d.Id == vm.Id);

                if (category == null)
                {
                    category = new Model.ProductCategory()
                    {
                        Name        = vm.Name,
                        Description = vm.Description,
                        IsActive    = true,
                        Picture     = vm.Picture
                    };

                    _db.ProductCategories.Add(category);
                    await _db.SaveChangesAsync();

                    response.IsSuccess = true;
                    response.Message   = "New Product category has been added.";
                }
                else
                {
                    category.Description = vm.Description;
                    category.Name        = vm.Name;
                    category.Picture     = vm.Picture;

                    _db.ProductCategories.Update(category);
                    await _db.SaveChangesAsync();

                    response.IsSuccess = true;
                    response.Message   = "Product category has been updated.";
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
                response.IsSuccess = false;
                response.Message   = "Error has been occured while saving the data. Please try again.";
            }

            return(response);
        }
Пример #16
0
        /// <summary>
        /// Insert a ProductCategory.
        /// </summary>
        public void Insert(Model.ProductCategory productCategory)
        {
            //this.Validate(productCategory);
            //if (this.Exists(productCategory.Id))
            //{
            //    throw new Helper.InvalidValueException(Model.ProductCategory.PROPERTY_ID);
            //}

            //productCategory.ProductCategoryId = Guid.NewGuid().ToString();
            //productCategory.InsertTime = DateTime.Now;
            if (this.Exists(productCategory.Id))
            {
                throw new Helper.InvalidValueException(Model.ProductCategory.PROPERTY_ID);
            }
            productCategory.InsertTime = DateTime.Now;
            productCategory.UpdateTime = DateTime.Now;
            accessor.Insert(productCategory);
        }
Пример #17
0
        private void lookUpEditDepotId_EditValueChanged(object sender, EventArgs e)
        {
            string depotId = (this.lookUpEditDepotId.EditValue as Model.Depot) == null ? "" : (this.lookUpEditDepotId.EditValue as Model.Depot).DepotId;

            _stockEditor.DepotId = depotId;
            Model.ProductCategory temp = this.buttonEditProductCategoryId.EditValue as Model.ProductCategory;

            if (temp == null || temp.ProductCategoryId == null)
            {
                productlist = this._productManager.DataReaderBind <Model.Product>("select DepotUnitId,Id,ProductId,ProductName,ProductVersion,CustomerProductName,StocksQuantity,ProductDescription from product where ProductId in (select ProductId from Stock where DepotId='" + depotId + "')", null, CommandType.Text);
            }
            else
            {
                productlist = this._productManager.DataReaderBind <Model.Product>("select DepotUnitId,Id,ProductId,ProductName,ProductVersion,CustomerProductName,StocksQuantity,ProductDescription from product where ProductCategoryId='" + temp.ProductCategoryId + "' and ProductId in (select ProductId from Stock where DepotId='" + depotId + "')", null, CommandType.Text);
            }
            this.bindingSourceProduct.DataSource = productlist;
            this.Refresh();
        }
Пример #18
0
        private void gridView1_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            Model.ProductCategory pc = this.gridView1.GetRow(e.RowHandle) as Model.ProductCategory;
            if (e.Value == null)
            {
                return;
            }
            switch (e.Column.Name)
            {
            case "gridColumn1":
                pc.Id = e.Value.ToString();
                break;

            case "gridColumn2":
                pc.ProductCategoryName = e.Value.ToString();
                break;
            }
        }
Пример #19
0
        private static void InitDataCategories()
        {
            // ProductCategory
            Model.ProductCategory model1 = new Model.ProductCategory();
            model1.ID   = Guid.NewGuid();
            model1.Name = "Shirt";
            listProductCategory.Add(model1);
            // Product

            Model.Product model2 = new Model.Product();
            model2.ID = "1";
            model2.ProductCategoryID = listProductCategory.Find(x => x.Name == "Shirt").ID;
            model2.Name   = "T-Shirt";
            model2.IsUsed = true;

            listProduct.Add(model2);

            model2    = new Model.Product();
            model2.ID = "2";
            model2.ProductCategoryID = listProductCategory.Find(x => x.Name == "Shirt").ID;
            model2.Name   = "Dress Shirt";
            model2.IsUsed = true;

            listProduct.Add(model2);

            // ProductPrice
            Model.ProductSellPrice model3 = new Model.ProductSellPrice();
            model3.ID        = Guid.NewGuid();
            model3.ProductID = listProduct.Find(x => x.Name == "T-Shirt").ID;
            model3.Price     = 12;

            listProductSellPrice.Add(model3);

            model3           = new Model.ProductSellPrice();
            model3.ID        = Guid.NewGuid();
            model3.ProductID = listProduct.Find(x => x.Name == "Dress Shirt").ID;
            model3.Price     = 20;
            listProductSellPrice.Add(model3);
            l_color.Add("Red");
            l_color.Add("Blue");
            l_size.Add("S");
            l_size.Add("M");
        }
Пример #20
0
        public string GetNewId(Model.ProductCategory productCategory)
        {
            // this.Validate(product);
            if (productCategory == null)
            {
                return(string.Empty);
            }
            string sequencekey = productCategory.Id;
            //SequenceManager.Increment(sequencekey);

            // SequenceManager.Increment(sequencekey);
            //  string str=
            // SequenceManager.IncrementVal(sequencekey,);

            int sequenceval = SequenceManager.GetCurrentVal(sequencekey) + 1;
            //return string.Format("{0}{1:d6}", sequencekey, sequenceval);
            string str = string.Format("{0}-{1:d6}", sequencekey, sequenceval);

            this.RecursiveId(ref str, sequencekey);
            return(str);
        }
Пример #21
0
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            if (flag == 1)
            {
                flag = 0;
                return;
            }
            else
            {
                if (treeList1.FocusedNode != null)
                {
                    Model.ProductCategory category = treeList1.FocusedNode.Tag as Model.ProductCategory;
                    if (category != null)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        this.bindingSource1.DataSource = this.productManager.Select(category);

                        this.gridControl1.RefreshDataSource();
                    }
                }
            }
        }
Пример #22
0
 private void listBoxControl1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (flag == 1)
     {
         flag = 0;
         return;
     }
     else
     {
         if (listBoxControl1.SelectedIndex >= 0)
         {
             Model.ProductCategory category = listBoxControl1.SelectedItem as Model.ProductCategory;
             if (category != null)
             {
                 Cursor.Current = Cursors.WaitCursor;
                 this.bindingSource1.DataSource = this.productManager.Select(category);
             }
         }
     }
     this.gridControl1.RefreshDataSource();
     Cursor.Current = Cursors.Default;
 }
Пример #23
0
 public ChooseProductForm(Model.ProductCategory productCategory)
     : this()
 {
     this._productCategory = productCategory;
 }
Пример #24
0
 //查询指定类型和客户的货品和公司货品
 public IList <Model.Product> Select(Model.Customer customer, Model.ProductCategory cate)
 {
     return(accessor.Select(customer, cate));
 }
Пример #25
0
 public IList <Model.Product> Select(Model.ProductCategory category)
 {
     return(accessor.Select(category));
 }
Пример #26
0
 public bool ExistsExcept(Model.ProductCategory e)
 {
     return(accessor.ExistsExcept(e));
 }
Пример #27
0
        public IList <Book.Model.MRSdetails> SelectbyCondition(string mpsstartId, string mpsendId, string customerstartId, string customerendId, DateTime startdate, DateTime enddate, int?sourceType, string id1, string id2, string cusxoid, Book.Model.Product product, int OrderColumn, int OrderType, Model.ProductCategory productCate)
        {
            StringBuilder str = new StringBuilder();

            str.Append(" select  c.ProductCategoryName , a.MRSHeaderId,b.ProductName,(ISNULL(b.ProduceMaterialDistributioned,0)+isnull( b.OtherMaterialDistributioned,0)) AS ProduceDistributioned , b.OrderOnWayQuantity, b.StocksQuantity ,b.CustomerProductName,a.ArrangeDesc,a.MPSheaderId,a.ProductUnit,a.MRSdetailssum,a.MRSdetailsQuantity,a.JiaoHuoDate ,(select  EmployeeName from employee where employee.employeeid=(select employee0id from mrsheader m where m.mrsheaderid=a.mrsheaderid  )) as Employee0Name,(select  CustomerInvoiceXOId  from invoicexo where invoiceid=(select invoicexoid from mpsheader where  mpsheader.mpsheaderid=(select mpsheaderid from mrsheader m where m.mrsheaderid=a.mrsheaderid  ))  ) as CustomerInvoiceXOId,");
            str.Append(" (select SupplierShortName from Supplier s where s.SupplierId=a.SupplierId) as SupplierId,");


            str.Append(" (select MRSstartdate from MRSHeader m where m.MRSHeaderId=a.MRSHeaderId) as MRSstartdate,");
            str.Append(" (select case  SourceType when '0' then '自製' when '1' then '外購' when '2' then '耗用' when '3' then '委外' when '4' then '自製(組裝)' when '5' then '自製(半成品加工)' when '6' then '委外(半成品加工)' end   from MRSHeader m where m.MRSHeaderId=a.MRSHeaderId) as SourceTypeName ,");

            str.Append(" (select  CustomerShortName from customer where customerid=(select xocustomerId from  invoicexo where invoiceid=(select invoicexoid from mpsheader where  mpsheader.mpsheaderid=(select mpsheaderid from mrsheader m where m.mrsheaderid=a.mrsheaderid  ))))  as CustomerName");
            str.Append(" from product b right join  mrsDetails a   on a.productid=b.productid left  join ProductCategory c  on c.ProductCategoryId=b.ProductCategoryId  ");


            str.Append(" where a.MRSHeaderId IN (SELECT MRSHeader.MRSHeaderId FROM MRSHeader WHERE  MRSstartdate between '" + startdate.ToString("yyyy-MM-dd") + "' and  '" + enddate.ToString("yyyy-MM-dd") + "' )");

            if (!string.IsNullOrEmpty(customerstartId) && !string.IsNullOrEmpty(customerendId))
            {
                str.Append(" AND a.MRSHeaderId IN (SELECT MRSHeader.MRSHeaderId FROM MRSHeader WHERE  CustomerId between '" + customerstartId + "' and '" + customerendId + "' )");
            }
            if (!string.IsNullOrEmpty(mpsstartId) && !string.IsNullOrEmpty(mpsendId))
            {
                str.Append(" AND a.MRSHeaderId IN (SELECT MRSHeader.MRSHeaderId FROM MRSHeader WHERE MPSheaderId between '" + mpsstartId + "' and '" + mpsendId + "' )");
            }

            if (sourceType != -1) //非全部
            {
                str.Append(" AND a.MRSHeaderId IN (SELECT MRSHeader.MRSHeaderId FROM MRSHeader WHERE SourceType = '" + sourceType.ToString() + "')");
            }
            if (!string.IsNullOrEmpty(id1) && !string.IsNullOrEmpty(id2))
            {
                str.Append(" AND a.MRSHeaderId BETWEEN '" + id1 + "' AND '" + id2 + "'");
            }
            if (!string.IsNullOrEmpty(cusxoid))
            {
                str.Append(" AND a.MRSHeaderId in (select MRSHeaderId from MRSHeader where MPSheaderId in (select MPSheaderId from MPSheader where InvoiceXOId in(select InvoiceId from InvoiceXO where CustomerInvoiceXOId like '%" + cusxoid + "%' )))");
            }
            if (product != null)
            {
                str.Append(" AND  productid='" + product.ProductId + "'");
            }
            if (productCate != null)
            {
                str.Append(" AND  productid in  (select productid from product where ProductCategoryId = '" + productCate.ProductCategoryId + "')");
            }


            str.Append(" ORDER BY ");
            switch (OrderColumn)
            {
            case 0:
                str.Append(" a.MRSHeaderId,a.Inumber ");             //头编号
                break;

            case 1:
                str.Append(" (SELECT ProductName FROM Product WHERE Product.ProductId=a.ProductId)");         //商品名称
                break;

            case 2:
                str.Append(" (SELECT CustomerInvoiceXOId FROM InvoiceXO WHERE InvoiceId =(SELECT InvoiceXOId FROM MPSheader WHERE MPSheader.MPSheaderId = MRSHeader.MPSheaderId))");
                break;

            case 3:
                str.Append(" (SELECT Supplier.Id FROM Supplier WHERE Supplier.SupplierId = a.SupplierId)");     //供应商
                break;

            case 4:
                str.Append(" (SELECT Id FROM ProductCategory WHERE ProductCategory.ProductCategoryId = (SELECT Product.ProductCategoryId FROM  Product WHERE Product.ProductId = a.ProductId))");
                break;
            }
            if (OrderType == 0)
            {
                str.Append(" ASC");
            }
            else
            {
                str.Append(" DESC");
            }
            return(this.DataReaderBind <Model.MRSdetails>(str.ToString(), null, CommandType.Text));


            //return sqlmapper.QueryForList<Model.MRSdetails>("MRSdetails.selectByCondition", str.ToString());
        }
Пример #28
0
 public Model.ProductCategory GetNext(Model.ProductCategory e)
 {
     return(accessor.GetNext(e));
 }
Пример #29
0
 public Model.ProductCategory GetPrev(Model.ProductCategory e)
 {
     return(accessor.GetPrev(e));
 }
Пример #30
0
 public bool HasRowsAfter(Model.ProductCategory e)
 {
     return(accessor.HasRowsAfter(e));
 }
Пример #31
0
 public bool HasRowsBefore(Model.ProductCategory e)
 {
     return(accessor.HasRowsBefore(e));
 }