コード例 #1
0
ファイル: ProductBLL.cs プロジェクト: CbrainSolutions/HMS
        public int GetNewProductId()
        {
            EntityProduct ldt = new EntityProduct();

            try
            {
                ldt = (from tbl in objData.tblProductMasters
                       where tbl.IsDelete == false
                       orderby tbl.ProductId descending
                       select new EntityProduct {
                    ProductId = tbl.ProductId
                }).FirstOrDefault();
                if (ldt == null)
                {
                    ldt           = new EntityProduct();
                    ldt.ProductId = 1;
                }
                else
                {
                    ldt.ProductId++;
                }
            }
            catch (Exception ex)
            {
                Commons.FileLog("ProductBLL - GetNewProductId()", ex);
            }
            return(ldt.ProductId);
        }
コード例 #2
0
        protected void ddlTablet_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                List <EntityPrescriptionDetails> lst = null;
                if (ddlTablet.SelectedIndex > 0)
                {
                    IssueMaterialBLL mobjDeptBLL = new IssueMaterialBLL();
                    EntityProduct    entProduct  = mobjDeptBLL.GetProductPrice(Convert.ToInt32(ddlTablet.SelectedValue));

                    List <tblStockDetail> lst1 = new CustomerTransactionBLL().GetProductTransByProductId(Convert.ToInt32(ddlTablet.SelectedValue));
                    if (lst1 != null)
                    {
                        lblBalQty.Text = Convert.ToString(Convert.ToInt32(lst1.Sum(p => p.InwardQty)) - Convert.ToInt32(lst1.Sum(p => p.OutwardQty)));
                    }
                    else
                    {
                        lblBalQty.Text = string.Empty;
                    }
                }
                else
                {
                    lst = new List <EntityPrescriptionDetails>();
                }
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.Message;
            }
        }
コード例 #3
0
        public IHttpActionResult InsertProduct(Product prod)
        {
            EntityProduct entity   = new EntityProduct();
            var           response = entity.DataInsertProduct(prod.name, prod.prov, prod.status, prod.value, prod.points, prod.stock);

            return(Ok(response));
        }
コード例 #4
0
        public string CargueProductExcel(string ruta)
        {
            EntityProduct entity = new EntityProduct();
            Archivo       arc    = new Archivo();

            string[][] datosArchivo = arc.LeerArchivo(ruta);
            string     response     = "0";

            foreach (var item in datosArchivo)
            {
                if (item != null)
                {
                    var data = new Product
                    {
                        name   = item[1],
                        prov   = Convert.ToInt32(item[2]),
                        status = Convert.ToInt32(item[3]),
                        value  = Convert.ToInt32(item[4]),
                        points = Convert.ToInt32(item[5]),
                        stock  = Convert.ToInt32(item[6]),
                    };
                    response = entity.DataInsertProduct(data.name, data.prov, data.status, data.value, data.points, data.stock);
                }
            }
            return(response);
        }
コード例 #5
0
        public IHttpActionResult ListProdUser(int flag)
        {
            var entity   = new EntityProduct();
            var dataList = new List <ProducUser>();

            dataList = entity.DataListProd(flag);
            return(Ok(dataList));
        }
コード例 #6
0
 public bool EntityProductDelete(EntityProduct entity_product)
 {
     return(ExecuteFaultHandledOperation(() =>
     {
         var entity_product_data = _ent_prod_es.Map(entity_product);
         _entity_product_repo.Delete(entity_product_data);
         return true;
     }));
 }
コード例 #7
0
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        internal static ModelProduct ToModel(this EntityProduct entity)
        {
            var model = new ModelProduct();

            model.Id          = entity.Id;
            model.Name        = entity.Name;
            model.Description = entity.Description;
            model.Price       = entity.Price;

            return(model);
        }
コード例 #8
0
        /// <summary>
        /// To the entity.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        internal static EntityProduct ToEntity(this ModelProduct model)
        {
            var entity = new EntityProduct();

            entity.Id          = model.Id;
            entity.Name        = model.Name;
            entity.Description = model.Description;
            entity.Price       = model.Price;

            return(entity);
        }
コード例 #9
0
 public EntityProductData Map(EntityProduct entity_product)
 {
     return(new EntityProductData()
     {
         ProductKey = entity_product.ProductKey,
         ProductTypeKey = (int)entity_product.ProductType,
         EntityProductSeq = entity_product.EntityProductSeq,
         EntityKey = entity_product.EntityProductEntityKey,
         EntityTypeKey = (int)entity_product.EntityProductEntityTypeKey,
         Comment = entity_product.Comment
     });
 }
コード例 #10
0
        // user/product/list
        public async Task <ActionResult> ProductLists(int?page, string searchQuery)
        {
            this.ApplicationDbContext = new ApplicationDbContext();
            this.UserManager          = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(this.ApplicationDbContext));
            string userId = User.Identity.GetUserId();
            var    user   = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            List <EntityProduct> lstProduct = new List <EntityProduct>();

            if (user != null)
            {
                userId = user.Id;
                var products = (from p in db.Products where p.F14 == userId select p);
                foreach (var item in products)
                {
                    var pr = new EntityProduct()
                    {
                        SanPhamId        = item.F1,
                        TenSp            = item.F2,
                        TinhTrangSp      = item.F5,
                        TheLoai          = item.F6,
                        GiaBan           = item.F3,
                        NgayDang         = item.F10,
                        TenNguoiBan      = item.AspNetUser.TenNguoiBan,
                        SoDienThoaiNgBan = item.AspNetUser.PhoneNumber,
                        AnhSanPham       = item.F11,
                    };
                    lstProduct.Add(pr);
                }



                if (lstProduct.Count > 0)
                {
                    if (!String.IsNullOrEmpty(searchQuery))
                    {
                        ViewBag.searchQuery = searchQuery.ToLower();
                        var word = searchQuery.Split(' ');
                        lstProduct = lstProduct.Where(s => word.Any(w => s.TenSp.Contains(w))).ToList();
                    }

                    lstProduct.OrderByDescending(x => x.NgayDang).ToList();

                    // Phan trang o day ne
                    int pageSize          = 10;
                    int pageNumber        = (page ?? 1);
                    var onePageOfProducts = lstProduct.ToPagedList(pageNumber, pageSize);
                    ViewBag.ProductLists = onePageOfProducts;
                }
            }

            return(View());
        }
コード例 #11
0
        public int EntityProductSave(EntityProduct entity_product)
        {
            if (entity_product == null)
            {
                throw new ArgumentNullException(nameof(entity_product));
            }

            return(ExecuteFaultHandledOperation(() =>
            {
                var prod_data = _ent_prod_es.Map(entity_product);
                return _entity_product_repo.Insert(prod_data);
            }));
        }
コード例 #12
0
ファイル: Mapper.cs プロジェクト: Naizar/Connectonew
 internal static Product Map(EntityProduct entity)
 {
     return(new Product
     {
         ProductId = entity.ProductId,
         ProductGuid = entity.ProductGuid,
         Name = entity.Name,
         StockInHand = entity.StockInHand,
         Quantity = entity.Quantity,
         Reorderlevel = entity.Reorderlevel,
         ProductTypeId = entity.ProductTypeId,
         VendorId = entity.VendorId
     });
 }
        public void entity_product_insert_new()
        {
            EntityProduct newObject = new EntityProduct();

            Mock <IBusinessEngineFactory> mockBusinessEngineFactory = new Mock <IBusinessEngineFactory>();

            mockBusinessEngineFactory.Setup(mock => mock.GetBusinessEngine <IEntityProductBusinessEngine>().EntityProductSave(newObject)).Returns(123);

            EntityProductService service = new EntityProductService(mockBusinessEngineFactory.Object);

            int update_ret_val = service.CreateEntityProduct(newObject);

            Assert.IsTrue(update_ret_val == 123);
        }
コード例 #14
0
        protected void BtnAddNewProduct_Click(object sender, EventArgs e)
        {
            EntityProduct entProduct = new EntityProduct();
            int           ID         = mobjProductBLL.GetNewProductId();

            txtProductId.Text   = Convert.ToString(ID);
            txtProductName.Text = string.Empty;
            txtUOM.Text         = string.Empty;
            txtSubUOM.Text      = string.Empty;
            txtPrice.Text       = string.Empty;

            BtnSave.Visible   = true;
            btnUpdate.Visible = false;
            MultiView1.SetActiveView(View2);
        }
コード例 #15
0
        protected void BtnEdit_Click(object sender, EventArgs e)
        {
            int lintCnt = 0;

            try
            {
                EntityProduct entProduct = new EntityProduct();

                entProduct.ProductId = Convert.ToInt32(txtProductId.Text);
                if (string.IsNullOrEmpty(txtProductName.Text))
                {
                    lblMsg.Text = "Please Enter Product Name";
                    txtProductName.Focus();
                    return;
                }
                else
                {
                    entProduct.ProductName = txtProductName.Text;
                }
                entProduct.UOM    = txtUOM.Text;
                entProduct.SubUOM = txtSubUOM.Text;
                entProduct.Price  = Convert.ToDecimal(txtPrice.Text);
                if (!Commons.IsRecordExists("tblProductMaster", "ProductName", Convert.ToString(entProduct.ProductName)))
                {
                    lintCnt = mobjProductBLL.UpdateProduct(entProduct);

                    if (lintCnt > 0)
                    {
                        GetProduct();
                        lblMessage.Text = "Record Updated Successfully";
                        //this.programmaticModalPopup.Hide();
                    }
                    else
                    {
                        lblMessage.Text = "Record Not Updated";
                    }
                }
                else
                {
                    lblMessage.Text = "Record Already Exist";
                }
            }
            catch (Exception ex)
            {
                Commons.FileLog("frmProductMaster -  BtnEdit_Click(object sender, EventArgs e)", ex);
            }
            MultiView1.SetActiveView(View1);
        }
コード例 #16
0
        public async Task <ActionResult> GianHang(int?page, string username)
        {
            if (!string.IsNullOrWhiteSpace(username))
            {
                this.ApplicationDbContext = new ApplicationDbContext();
                this.UserManager          = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(this.ApplicationDbContext));
                var user = await UserManager.FindByNameAsync(username);

                List <EntityProduct> lstProduct = new List <EntityProduct>();
                if (user != null)
                {
                    ViewBag.TenGianHang = user.TenNguoiBan;
                    var products = (from p in db.Products where p.F14 == user.Id select p);
                    foreach (var item in products)
                    {
                        var pr = new EntityProduct()
                        {
                            SanPhamId        = item.F1,
                            TenSp            = item.F2,
                            TinhTrangSp      = item.F5,
                            TheLoai          = item.F6,
                            GiaBan           = item.F3,
                            NgayDang         = item.F10,
                            TenNguoiBan      = item.AspNetUser.TenNguoiBan,
                            SoDienThoaiNgBan = item.AspNetUser.PhoneNumber,
                            AnhSanPham       = item.F11,
                            DiaDiem          = item.Local.F2,
                            SlugCat          = Configs.unicodeToNoMark(item.Category.Category2.F2),
                            slugTenSp        = Configs.unicodeToNoMark(item.F2 != null ? item.F2 : "no-title"),
                            SubCatId         = item.F15
                        };
                        lstProduct.Add(pr);
                    }

                    if (lstProduct.Count > 0)
                    {
                        lstProduct = lstProduct.OrderByDescending(x => x.NgayDang).ToList();
                        // Phan trang o day ne
                        int pageSize          = 10;
                        int pageNumber        = (page ?? 1);
                        var onePageOfProducts = lstProduct.ToPagedList(pageNumber, pageSize);
                        ViewBag.ProductLists = onePageOfProducts;
                    }
                }
            }

            return(View());
        }
コード例 #17
0
ファイル: ProductBLL.cs プロジェクト: CbrainSolutions/HMS
        public int DeleteProduct(EntityProduct entProduct)
        {
            int cnt = 0;

            try
            {
                List <SqlParameter> lstParam = new List <SqlParameter>();
                Commons.ADDParameter(ref lstParam, "@ProductId", DbType.String, entProduct.ProductId);
                cnt = mobjDataAcces.ExecuteQuery("sp_DeleteProduct", lstParam);
            }
            catch (Exception ex)
            {
                Commons.FileLog("ProductBLL - DeleteProduct(EntityProduct entProduct)", ex);
            }
            return(cnt);
        }
コード例 #18
0
        public EntityProduct GetProductPrice(int Prod_ID)
        {
            EntityProduct lstPro = new EntityProduct();

            try
            {
                lstPro = (from tbl in objData.tblProductMasters
                          where tbl.ProductId.Equals(Prod_ID)
                          select new EntityProduct {
                    Price = tbl.Price
                }).FirstOrDefault();
            }
            catch (Exception)
            {
                throw;
            }
            return(lstPro);
        }
コード例 #19
0
        private void DoSave()
        {
            ExecuteFaultHandledOperation(() =>
            {
                var product = SelectedProduct as ProductWrapper;
                IProductService product_service = service_factory.CreateClient <IProductService>();
                IEntityProductService entity_product_service = service_factory.CreateClient <IEntityProductService>();
                using (TransactionScope scope = new TransactionScope()) // TransactionScopeAsyncFlowOption.Enabled
                {
                    using (product_service)
                    {
                        //*** Make sure the attributes are set before the save happens!!
                        int ret_val = product_service.CreateProduct(product.Model);
                        // We need to create a relationship in the entity product table too, or adding new products is a waste of time.
                        if (product.ProductKey == 0)
                        {
                            EntityProduct ent_prod = new EntityProduct()
                            {
                                EntityProductEntityKey     = CurrentCompanyKey,
                                EntityProductEntityTypeKey = QIQOEntityType.Company,
                                ProductKey       = ret_val,
                                EntityProductSeq = 1,
                                ProductType      = product.ProductType,
                                Comment          = string.Format($"New product {product.ProductName} (Key: {ret_val.ToString()}) entry for company {CurrentCompanyName}")
                            };

                            using (entity_product_service)
                            {
                                int ep_ret = entity_product_service.CreateEntityProduct(ent_prod);
                            }
                            product.ProductKey = ret_val;
                        }

                        product.AcceptChanges();
                        //Products.Add(product);
                        AddNewProductToCache(product);
                        SelectedProduct = null;
                        RaisePropertyChanged("Products");
                    }
                    scope.Complete();
                }
                event_aggregator.GetEvent <ProductNewProductCompleteEvent>().Publish(ViewNames.ProductHomeView);
            });
        }
コード例 #20
0
 protected void ddlProduct_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlProduct.SelectedIndex > 0)
     {
         Session["Prod_ID"] = ddlProduct.SelectedIndex;
         EntityProduct entProduct = mobjDeptBLL.GetProductPrice(Convert.ToInt32(Session["Prod_ID"]));
         txtItemCharge.Text = Convert.ToString(entProduct.Price);
         txtQuantity.Text   = Convert.ToString(1);
         List <tblStockDetail> lst1 = new CustomerTransactionBLL().GetProductTransByProductId(Convert.ToInt32(ddlProduct.SelectedValue));
         if (lst1 != null)
         {
             lblBalQty.Text = Convert.ToString(Convert.ToInt32(lst1.Sum(p => p.InwardQty)) - Convert.ToInt32(lst1.Sum(p => p.OutwardQty)));
         }
         else
         {
             lblBalQty.Text = string.Empty;
         }
     }
 }
コード例 #21
0
        public List <EntityProduct> GetEntityProductsByEntity(int entity_key, QIQOEntityType entity_type)
        {
            return(ExecuteFaultHandledOperation(() =>
            {
                IEntityProductRepository entity_product_repo = _data_repository_factory.GetDataRepository <IEntityProductRepository>();
                IProductRepository product_repo = _data_repository_factory.GetDataRepository <IProductRepository>();
                List <EntityProduct> entity_products = new List <EntityProduct>();

                IEnumerable <EntityProductData> entity_products_data = entity_product_repo.GetAll(entity_key, (int)entity_type);

                foreach (EntityProductData entity_product_data in entity_products_data)
                {
                    ProductData product_data = product_repo.GetByID(entity_product_data.ProductKey);
                    EntityProduct entity_product = Map(entity_product_data, product_data);
                    entity_products.Add(entity_product);
                }
                return entity_products;
            }));
        }
コード例 #22
0
ファイル: ProductBLL.cs プロジェクト: CbrainSolutions/HMS
 public int InsertProduct(EntityProduct entProduct)
 {
     try
     {
         tblProductMaster obj = new tblProductMaster()
         {
             ProductName = entProduct.ProductName,
             UOM         = entProduct.UOM,
             SubUOM      = entProduct.SubUOM,
             Price       = Convert.ToDecimal(entProduct.Price)
         };
         objData.tblProductMasters.InsertOnSubmit(obj);
         objData.SubmitChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #23
0
        public EntityProduct GetProductPrice(int Prod_ID)
        {
            EntityProduct lstPro = null;

            try
            {
                lstPro = (from tbl in objData.tblStockDetails
                          where tbl.ProductId.Equals(Prod_ID) &&
                          tbl.IsDelete == false &&
                          tbl.TransactionType.Equals("PInvoice")
                          orderby tbl.StockId descending
                          select new EntityProduct {
                    Price = Convert.ToDecimal(tbl.InwardPrice)
                }).FirstOrDefault();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(lstPro);
        }
コード例 #24
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            int           lintcnt    = 0;
            EntityProduct entProduct = new EntityProduct();

            if (string.IsNullOrEmpty(txtProductName.Text.Trim()))
            {
                lblMsg.Text = "Enter Product Description";
                txtProductName.Focus();
                return;
            }
            else
            {
                entProduct.ProductId   = Convert.ToInt32(txtProductId.Text);
                entProduct.ProductName = txtProductName.Text.Trim();
                entProduct.UOM         = txtUOM.Text.Trim();
                entProduct.SubUOM      = txtSubUOM.Text.Trim();
                entProduct.Price       = Convert.ToDecimal(txtPrice.Text);
                if (!Commons.IsRecordExists("tblProductMaster", "ProductName", Convert.ToString(entProduct.ProductName)))
                {
                    lintcnt = mobjProductBLL.InsertProduct(entProduct);

                    if (lintcnt > 0)
                    {
                        GetProduct();
                        lblMessage.Text = "Record Inserted Successfully";
                        //this.programmaticModalPopup.Hide();
                    }
                    else
                    {
                        lblMessage.Text = "Record Not Inserted";
                    }
                }
                else
                {
                    lblMessage.Text = "Record Already Exist";
                }
            }
            MultiView1.SetActiveView(View1);
        }
コード例 #25
0
        public EntityProduct Insert(Material model)
        {
            var objRepository = new RepositoryProduct();

            EntityProduct data = new EntityProduct()
            {
                Model               = model.IDMaterial,
                ProductName         = model.DescripcionRefaccion,
                SaleOrganization    = model.OrganizacionVentas,
                DistributionChannel = model.CanalDistribucion,
                Center              = model.Centro,
                MaterialGroup1      = model.GrupoMaterial1,
                MaterialGroup4      = model.GrupoMaterial4,
                ProductType         = model.TipoProducto,
                BarCode             = "",
                Status              = true,
                CreateDate          = DateTime.Now,
                ModifyDate          = DateTime.UtcNow
            };

            data = objRepository.Insert(data);
            return(data);
        }
コード例 #26
0
        public EntityProduct Update(Material model, EntityProduct prod)
        {
            var objRepository = new RepositoryProduct();

            EntityProduct data = new EntityProduct()
            {
                PK_ProductID        = prod.PK_ProductID,
                Model               = model.IDMaterial,
                ProductName         = model.DescripcionRefaccion,
                SaleOrganization    = model.OrganizacionVentas,
                DistributionChannel = model.CanalDistribucion,
                Center              = model.Centro,
                MaterialGroup1      = model.GrupoMaterial1,
                MaterialGroup4      = model.GrupoMaterial4,
                ProductType         = model.TipoProducto,
                BarCode             = prod.BarCode,
                Status              = prod.Status,
                CreateDate          = prod.CreateDate,
                ModifyDate          = DateTime.UtcNow
            };

            data = objRepository.Update(data);
            return(data);
        }
コード例 #27
0
 public Task <bool> DeleteEntityProductAsync(EntityProduct product)
 {
     return(channel.DeleteEntityProductAsync(product));
 }
コード例 #28
0
 public bool DeleteEntityProduct(EntityProduct product)
 {
     return(channel.DeleteEntityProduct(product));
 }
コード例 #29
0
 public Task <int> CreateEntityProductAsync(EntityProduct product)
 {
     return(channel.CreateEntityProductAsync(product));
 }
コード例 #30
0
 public int CreateEntityProduct(EntityProduct product)
 {
     return(channel.CreateEntityProduct(product));
 }