Ejemplo n.º 1
0
        public ActionResult GetCommodityView()
        {
            CommodityModel model       = new CommodityModel();
            var            CommodityId = Request.QueryString["commodityid"];

            try
            {
                CommodityClient = new CommodityServiceClient();
                CommodityDto cmdto = CommodityClient.GetById(CommodityId != null ? Convert.ToInt32(CommodityId) : 0);
                model.CommodityId = cmdto.CommodityId;
                model.CommoditiesInCommodityClass = cmdto.CommoditiesInCommodityClass;
                model.Name               = cmdto.Name;
                model.BotanicalName      = cmdto.BotanicalName;
                model.IsActive           = cmdto.IsActive;
                model.Image              = (((!String.IsNullOrEmpty(cmdto.Image)) ? Constants.IMAGEUPLOADPATHCOMMODITY + cmdto.Image : Constants.BLANKIMAGEPATH)).Replace("~/", "../../");
                model.CommodityClassList = GetCommodityClassList();
            }
            catch (Exception ex)
            {
                return(View("ErrorPage"));
            }
            finally
            {
                if (CommodityClient != null)
                {
                    CommodityClient.Close();
                }
            }
            return(View("CommodityView", model));
        }
Ejemplo n.º 2
0
        public ActionResult BoothDetail(int id)
        {
            var        _booth = db.Booths.FirstOrDefault(x => x.BoothId == id);
            BoothModel _model = new BoothModel();

            if (_booth != null)
            {
                _model.Id           = _booth.BoothId;
                _model.Name         = _booth.BoothName;
                _model.Location     = _booth.BoothLocation;
                _model.Operator     = _booth.Operator;
                _model.Introduction = _booth.BoothIntroduction;
                _model.Commoditys   = new List <CommodityModel>();
                var _commodities = db.Commoditys.Where(x => x.BoothId == _booth.BoothId).ToList();
                foreach (var _commodity in _commodities)
                {
                    CommodityModel model = new CommodityModel();
                    model.Id             = _commodity.CommodityId;
                    model.Name           = _commodity.CommodityName;
                    model.Price          = _commodity.CommodityPrice;
                    model.Classification = _commodity.CommodityClassification;
                    _model.Commoditys.Add(model);
                }
            }
            return(View("Details", _model));
        }
Ejemplo n.º 3
0
        public async Task <IEnumerable <CommodityModel> > GetCommoditiesAsync()
        {
            List <CommodityModel> commodities = new List <CommodityModel>();

            //string sql = "select * from CommodityRef order by commod_name";
            string sql = "select * from Commod_LU order by Descript";

            SqlCommand command = new SqlCommand(sql);

            command.Connection = _connection;

            _connection.Open();

            var reader = await command.ExecuteReaderAsync(CommandBehavior.CloseConnection);

            DataTable table = new DataTable();

            table.Load(reader);

            foreach (DataRow row in table.Rows)
            {
                CommodityModel commodity = new CommodityModel
                {
                    IsChecked     = true,
                    Commodity     = row["COMMOD"].ToString(),
                    CommodityName = row["Descript"].ToString()
                };

                commodities.Add(commodity);
            }

            return(commodities);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到文件名
        /// </summary>
        /// <returns></returns>
        public virtual ActionResult DetailInfo(IList <CommodityParamModel> ps)
        {
            var model = new CommodityModel();

            if (ps != null && ps.Count > 0)
            {
                var id    = ps.Select(it => it.Id.Convert <long>()).ToArray();
                var query = new QueryInfo();
                query.Query <CommodityEntity>().Where(it => id.Contains(it.Id) && it.Site.Id == SiteId & it.Status == CommodityStatusType.Normal)
                .Select(it => new object[] { it.Id, it.Name, it.FileName, it.Password, it.Price,
                                             it.IsShowPrice, it.Description, it.CommodityImages.
                                             Select(s => new object[] { s.FileName, s.Sequence }) });
                model.Commodities = this.GetEntities <CommodityEntity>(query);
                if (model.Commodities != null)
                {
                    for (int i = 0; i < model.Commodities.Count;)
                    {
                        var p = ps.FirstOrDefault(it => it.Id.Convert <long>() == model.Commodities[i].Id);
                        if (p == null || !string.IsNullOrEmpty(model.Commodities[i].Password) && model.Commodities[i].Password != p.Id)
                        {
                            model.Commodities.RemoveAt(i);
                            continue;
                        }
                        i++;
                    }
                }
            }
            return(View(GetViewPath("~/Views/Commodity/_DetailInfo.cshtml"), model));
        }
Ejemplo n.º 5
0
 public CommodityModel GetCommodity(int id)
 {
     try
     {
         var check = tRSEntities4.CommodityMasters.Where(x => x.id == id && x.IsActive == true).FirstOrDefault();
         if (check != null)
         {
             CommodityModel commodity = new CommodityModel();
             commodity.id            = check.id;
             commodity.name          = check.name;
             commodity.commodityType = check.commodityType;
             commodity.IsPerishable  = check.IsPerishable;
             commodity.IsRestricted  = check.IsRestricted;
             check.IsActive          = (bool)commodity.IsActive;
             return(commodity);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 6
0
 public bool SaveCommodity(CommodityModel model)
 {
     try
     {
         CommodityMaster db = new CommodityMaster()
         {
             IsActive      = true,
             name          = model.name,
             commodityType = model.commodityType,
             IsRestricted  = model.IsRestricted,
             IsPerishable  = model.IsPerishable,
         };
         if (!CheckIfNameExists(model.name))
         {
             tRSEntities4.CommodityMasters.Add(db);
             tRSEntities4.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 7
0
 public List <CommodityModel> GetCommodities()
 {
     try
     {
         List <CommodityModel> models = new List <CommodityModel>();
         var data = tRSEntities4.CommodityMasters.Where(x => x.IsActive == true).ToList();
         foreach (var item in data)
         {
             CommodityModel db = new CommodityModel
             {
                 id                = item.id,
                 name              = item.name,
                 commodityType     = item.commodityType,
                 IsRestricted      = item.IsRestricted,
                 IsPerishable      = item.IsPerishable,
                 IsActive          = (bool)item.IsActive,
                 commodityTypename = tRSEntities4.CommodityTypeMasters.Where(x => x.id == item.commodityType).Select(x => x.Name).FirstOrDefault(),
             };
             models.Add(db);
         }
         return(models);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 8
0
        private void RecipeToDb(List <CommodityShadow> commodityList, string recipeName, string recipeDescription,
                                RecipeCategory recipeCategory, Recipe recipe = null)
        {
            var rcModel = new RCModel(_dbPath);
            var recipeCommodityModel = new RecipeCommodityModel(_dbPath);
            var recipeModel          = new RecipeModel(_dbPath);
            var commodityModel       = new CommodityModel(_dbPath);

            if (recipe == null)
            {
                recipe = recipeModel.CreateRecipe(recipeName, recipeDescription);
            }

            rcModel.CreateRC(recipe, recipeCategory);

            foreach (var commodityShadow in commodityList)
            {
                if (commodityShadow.Commodity != null)
                {
                    recipeCommodityModel.CreateRecipeCommodity(recipe, commodityShadow.Commodity, commodityShadow.Value,
                                                               commodityShadow.Unit.ToString());
                }
                else
                {
                    var commodity = commodityModel.CreateCommodity(commodityShadow.Name);
                    recipeCommodityModel.CreateRecipeCommodity(recipe, commodity, commodityShadow.Value,
                                                               commodityShadow.Unit.ToString());
                }
            }
        }
Ejemplo n.º 9
0
        public string SetShoppingCount(string token, int shpId, int spCount)
        {
            string key      = string.Concat(token, "SetShopping");
            var    uComList = CacheHelp.Get <List <CommodityModel> >(key, DateTimeOffset.Now.AddMonths(3), () => null);

            if (uComList == null)
            {
                uComList = new List <CommodityModel>();
            }
            var um = uComList.Find(o => o.CommodityId == shpId);

            if (um == null)
            {
                CommodityModel cm = GetComInfo(shpId);
                if (cm != null)
                {
                    cm.SpCount = spCount;
                    uComList.Add(cm);
                }
            }
            else
            {
                um.SpCount = spCount;
            }
            var         state = CacheHelp.Set(key, DateTimeOffset.Now.AddMonths(3), uComList);
            ReturnModel re    = new ReturnModel();

            if (state)
            {
                re.state  = true;
                re.rcount = uComList.Count;
            }
            return(JsonUtil.Serialize(re));
        }
Ejemplo n.º 10
0
 public AddUpdateCommdityFrm(MaintainType type, CommodityModel commodity)
 {
     InitializeComponent();
     this.commdodityModel = commodity;
     this.maintainType    = type;
     this.previousImg     = this.commdodityModel.CommodityImg;
     InitControls();
 }
Ejemplo n.º 11
0
        public ActionResult CommodityListIndex()
        {
            CommodityModel model = new CommodityModel();

            FormMode            = string.Empty;
            model.CommodityList = GetCommodityList();
            return(View("CommodityList", model));
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 得到文件名
        /// </summary>
        /// <returns></returns>
        public virtual ActionResult Detail(IList <CommodityParamModel> ps)
        {
            var model = new CommodityModel
            {
                Params = ps
            };

            return(View(GetViewPath("~/Views/Commodity/Detail.cshtml"), model));
        }
Ejemplo n.º 13
0
        public IActionResult Modified(CommodityModel data)
        {
            data.ImageData = _cache.Get(data.FileName).Object2Bytes();
            _server.AddCommodity(data);
            ResponseModel response = new ResponseModel();

            response.statusCode = "200";
            response.message    = "success";
            return(Json(response));
        }
Ejemplo n.º 14
0
        public void AddCommodity(CommodityModel data)
        {
            Commodity commodityData = new Commodity();

            commodityData.Category = data.Category;
            commodityData.Image    = data.ImageData;
            commodityData.Name     = data.Name;
            commodityData.Url      = data.Url;
            dbConn.Insert(commodityData);
        }
Ejemplo n.º 15
0
 public IActionResult Post([FromBody] CommodityModel newCommodity)
 {
     try
     {
         productService.AddProduct(newCommodity);
         return(Ok());
     }
     catch
     {
         throw new Exception("No se pudo agregar el producto.");
     }
 }
Ejemplo n.º 16
0
        public CommodityModel GetCommodity(int id)
        {
            var            data          = dbConn.QueryFirstOrDefault <Commodity>("select * from Commodity where ID=@ID", new { ID = id });
            CommodityModel commodityData = new CommodityModel();

            commodityData.ID        = id;
            commodityData.Category  = data.Category;
            commodityData.ImageData = data.Image;
            commodityData.Name      = data.Name;
            commodityData.Url       = data.Url;
            return(commodityData);
        }
Ejemplo n.º 17
0
        public ScrapeVM(string dbPath)
        {
            _commodityModel       = new CommodityModel(dbPath);
            _recipeModel          = new RecipeModel(dbPath);
            _rcModel              = new RCModel(dbPath);
            _recipeCommodityModel = new RecipeCommodityModel(dbPath);

            var recipeCategoryVm = new RecipeCategoryVM(dbPath);

            _scrape = new Scrape(this);
            _scrape.SetContentCategoryDropdown(recipeCategoryVm.GetRecipeCategories());
            _scrape.ShowDialog();
        }
Ejemplo n.º 18
0
        private void btnAd_Click(object sender, EventArgs e)
        {
            CommodityModel newCommodityModel = new CommodityModel();

            using (AddUpdateCommdityFrm NewCommodityFrm = new AddUpdateCommdityFrm(MaintainType.New, newCommodityModel))
            {
                var dialogResult = NewCommodityFrm.ShowDialog();
                if (dialogResult == DialogResult.OK)
                {
                    this.InitControls();
                }
            }
        }
        //POST
        public void AddProduct(CommodityModel newProduct)
        {
            var newProductRegister = new Products()
            {
                ProductName     = newProduct.Name,
                QuantityPerUnit = newProduct.Quantity,
                UnitPrice       = newProduct.Price,
                UnitsInStock    = newProduct.Stock
            };

            dbContext.Products.Add(newProductRegister);
            dbContext.SaveChanges();
        }
        public ActionResult Create(CommodityModel commodity)
        {
            if (ModelState.IsValid)
            {
                var repo = new CommodityRepository();

                var saved = repo.SaveNewCommodity(commodity);
                if (saved)
                {
                    return(RedirectToAction("index", "Home"));
                }
            }
            return(View(commodity));
        }
 public CommodityModelResponse(CommodityModel model)
 {
     id             = model.ID;
     date           = model.Date.ToUniversalTime().ToString("o");
     contract       = model.Contract;
     price          = model.Price;
     position       = model.Position;
     newTradeAction = model.NewTradeAction;
     pnlDaily       = model.PnlDaily;
     this.model     = model.Model;
     commodity      = model.Commodity;
     pnlYtd         = model.PnlYtd;
     pnlLtd         = model.PnlLtd;
     mddYtd         = model.MddYtd;
 }
Ejemplo n.º 22
0
        public void DeleteAllContent()
        {
            // All Model are initialized
            var commodiytModel       = new CommodityModel(_dbPath);
            var rcModel              = new RCModel(_dbPath);
            var recipeCategoryModel  = new RecipeCategoryModel(_dbPath);
            var recipeCommodityModel = new RecipeCommodityModel(_dbPath);
            var recipeModel          = new RecipeModel(_dbPath);

            // All data is wiped
            rcModel.DeleteAllRC();
            recipeCommodityModel.DeleteAllRecipeCommodities();
            recipeCategoryModel.DeleteRecipeCategory();
            recipeModel.DeleteRecipes();
            commodiytModel.DeleteCommodity();
        }
Ejemplo n.º 23
0
        public virtual ActionResult Modify(CommodityModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var dataImages = GetCommodityImages(model.Id.Convert <long>());
            var dataTags   = GetCommodityTags(model.Id.Convert <long>());
            var entity     = model.CreateEntity(SaveType.Modify, dataImages, dataTags);
            var result     = new Dictionary <string, object>();
            var rev        = this.SaveEntity(entity);
            var mess       = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
Ejemplo n.º 24
0
        public List <CommodityModel> GetCommoditys()
        {
            var datas = dbConn.Query <Commodity>("select * from Commodity");
            List <CommodityModel> commoditys = new List <CommodityModel>();

            foreach (var item in datas)
            {
                CommodityModel commodity = new CommodityModel();
                commodity.ID        = item.ID;
                commodity.Category  = item.Category;
                commodity.ImageData = item.Image;
                commodity.Name      = item.Name;
                commodity.Url       = item.Url;
                commoditys.Add(commodity);
            }
            return(commoditys);
        }
Ejemplo n.º 25
0
        public BusinessModel GetMarketPrice(CommodityModel obj)
        {
            IList <CommodityModel> List             = new List <CommodityModel>();
            BusinessModel          objBusinessModel = new BusinessModel();
            var baseAddress = "https://data.gov.in/node/86943/datastore/export/json";

            using (HttpClient client = InitializeURL(baseAddress))
            {
                HttpResponseMessage response = client.GetAsync(baseAddress).Result;
                if (response.IsSuccessStatusCode)
                {
                    var data = response.Content.ReadAsStringAsync().Result;
                    List = JsonConvert.DeserializeObject <IList <CommodityModel> >(data);
                }
            }
            objBusinessModel.commodityModels = List.Where(x => (obj.commodity == "" || obj.commodity == null || x.commodity == obj.commodity) && (obj.state == "" || obj.state == null || x.state == obj.state) && (obj.district == "" || obj.district == null || x.district == obj.district) && (obj.market == "" || obj.market == null || x.market == obj.market)).ToList();
            return(objBusinessModel);
        }
Ejemplo n.º 26
0
        public CommodityViewModel(CommodityModel model)
        {
            this.Id = model.Id;
            this.No = model.No;
            this.ChName = model.ChName;

            this.EnName = model.EnName;
            this.ProductCode = model.ProductCode;
            this.Type = model.Type;

            this.Unit = model.Unit;
            this.TariffRate = model.TariffRate;
            this.VatRate = model.VatRate;

            this.RefundRate = model.RefundRate;
            this.CustomsNo = model.CustomsNo;
            this.Remark = model.Remark;
        }
 public bool SaveNewCommodity(CommodityModel commodity)
 {
     if (commodity != null)
     {
         using (var context = new ShukRoutingContext())
         {
             Commodity Commodity = new Commodity()
             {
                 CommodityID   = commodity.CommodityID,
                 CommodityName = commodity.CommodityName
             };
             context.Commodities.Add(Commodity);
             context.SaveChanges();
         }
         return(true);
     }
     return(false);
 }
Ejemplo n.º 28
0
        public ActionResult AddCommodityIndex()
        {
            CommodityModel model       = new CommodityModel();
            string         mode        = Request.QueryString["mode"] != null ? Request.QueryString["mode"].ToString() : string.Empty;
            var            CommodityId = Request.QueryString["commodityid"] != null ? Request.QueryString["commodityid"] : null;

            try
            {
                if (mode == "edit")
                {
                    FormMode        = mode;
                    CommodityClient = new CommodityServiceClient();
                    CommodityDto cmdto = CommodityClient.GetById(CommodityId != null ? Convert.ToInt32(CommodityId) : 0);
                    Id = cmdto.CommodityId;
                    model.CommoditiesInCommodityClass = cmdto.CommoditiesInCommodityClass;
                    model.CommodityClassId            = cmdto.CommoditiesInCommodityClass.CommodityClassId;
                    model.Name               = cmdto.Name;
                    model.BotanicalName      = cmdto.BotanicalName;
                    model.IsActive           = cmdto.IsActive;
                    model.Image              = (((!String.IsNullOrEmpty(cmdto.Image)) ? Constants.IMAGEUPLOADPATHCOMMODITY + (Session["UploadedImageFileName"] = cmdto.Image).ToString() : Constants.BLANKIMAGEPATH)).Replace("~/", "../../");
                    model.CommodityClassList = GetCommodityClassList();
                }
                else
                {
                    model.Image = Constants.BLANKIMAGEPATH.Replace("~/", "../../");
                    model.CommodityClassList = GetCommodityClassList();
                }
            }
            catch (Exception ex)
            {
                return(View("ErrorPage"));
            }
            finally
            {
                if (CommodityClient != null)
                {
                    CommodityClient.Close();
                }
            }
            return(View("AddCommodity", model));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 得到文件名
        /// </summary>
        /// <returns></returns>
        public virtual ActionResult Detail(long id, string password)
        {
            var model  = new CommodityModel();
            var entity = GetCommodity(id);

            if (entity != null && (string.IsNullOrEmpty(entity.Password) || entity.Password == password))
            {
                model.FileNames = new List <string>
                {
                    entity.FullFileName
                };
                var query = new QueryInfo();
                query.Query <CommodityImageEntity>().Where(it => it.Commodity.Id == id && it.Site.Id == SiteId)
                .Select(it => new object[] { it.FileName });
                var entities = this.GetEntities <CommodityImageEntity>(query);
                if (entities != null)
                {
                    model.FileNames.AddList(entities.Select(it => it.FullFileName).ToArray());
                }
            }
            return(View(GetViewPath("~/Views/Commodity/Detail.cshtml"), model));
        }
Ejemplo n.º 30
0
 public bool UpdateCommodity(CommodityModel model)
 {
     try
     {
         var check = tRSEntities4.CommodityMasters.Where(x => x.id == model.id && x.IsActive == true).FirstOrDefault();
         if (check != null)
         {
             check.name          = model.name;
             check.commodityType = model.commodityType;
             check.IsPerishable  = model.IsPerishable;
             check.IsRestricted  = model.IsRestricted;
             //check.isActive = model.isActive;
             tRSEntities4.SaveChanges();
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 31
0
        public virtual ActionResult Add(CommodityModel model)
        {
            if (model == null)
            {
                return(null);
            }
            var entity = model.CreateEntity(SaveType.Add, null, null);

            entity.Sequence = GetSequence();
            var result = new Dictionary <string, object>();

            entity.Site = new SiteEntity {
                Id = SiteId
            };
            var rev  = this.SaveEntity(entity);
            var mess = rev ? "" : entity.Errors?.FirstOrDefault()?.Message;

            result.Add("Status", rev);
            result.Add("Id", entity.Id);
            result.Add("Sequence", entity.Sequence);
            result.Add("Message", mess);
            return(this.Jsonp(result));
        }
Ejemplo n.º 32
0
        public string Add(CommodityViewModel model)
        {
#if DEBUG
            SysConfig.CurrentUser = UserModel.SingleOrDefault("3");
#endif
            if (ModelState.IsValid)
            {
                CommodityModel commodity = new CommodityModel();
                commodity.No = CommonMethod.GetLatestSerialNo(SysConfig.SerialNo.CommodityNo);    //商品编号
                commodity.ChName = model.ChName;                                                  //中文名称

                commodity.EnName = model.EnName;                                                  //英文名称
                commodity.ProductCode = model.ProductCode;                                        //商品货号
                commodity.Type = model.Type;                                                      //商品类别

                commodity.Unit = model.Unit;                                                      //商品单位
                commodity.TariffRate = model.TariffRate;                                          //关税率
                commodity.VatRate = model.VatRate;                                                //增值税率

                commodity.RefundRate = model.RefundRate;                                          //退税率
                commodity.CustomsNo = model.CustomsNo;                                            //海关编码
                commodity.Remark = model.Remark;                                                  //备注

                commodity.BelongsMan = CommonMethod.GetBelongsMan(                                //业务员
                    SysConfig.CurrentUser.Departmentid.ToString());
                commodity.BelongsDepartment = CommonMethod.GetBelongsDepartment(                  //业务部门
                    SysConfig.CurrentUser.Departmentid.ToString());

                commodity.ApprovalStatus = "4";                                                   //默认生效

                commodity.DelFlag = 0;                                                            //有效状态
                commodity.CreateMan = SysConfig.CurrentUser.Id;                                   //制单人
                commodity.CreateTime = DateTime.Now;                                              //制单时间

                int result = commodity.Insert().ToInt();

                if (result > 0)
                {
                    //更新商品最大序列号
                    CommonMethod.UpdateSerialNo(SysConfig.SerialNo.CommodityNo);

                    //记录操作日志
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Insert", "Sys_Commodity");
                    CommonMethod.Log(SysConfig.CurrentUser.Id, "Update", "Sys_SerialNo");

                    return "1";
                }
            }
            return "0";
        }