Example #1
0
        public MessageModel UpdateSingleEntity(PlansBatchModel model)
        {
            Func <IEntityContext, string> operation = delegate(IEntityContext context)
            {
                var data = context.PlansBatch.FirstOrDefault(m => m.BatchID == model.BatchID);
                if (data == null)
                {
                    return("当前数据不存在或被更新,请刷新后再次操作!");
                }

                data.BlockID      = model.BlockID;
                data.SeedID       = model.SeedID;
                data.BatchNO      = model.BatchNO;
                data.BatchCode    = model.BatchCode;
                data.PlansTime    = model.PlansTime;
                data.PlansYear    = model.PlansYear;
                data.HarvestTime  = model.HarvestTime;
                data.PlansArea    = model.PlansArea;
                data.ChargePerson = model.ChargePerson;
                data.HarvestCount = model.HarvestCount;
                data.RealCount    = model.RealCount;
                data.People       = model.People;
                data.Remark       = model.Remark;
                data.IsLocked     = model.IsLocked;
                data.IsShow       = model.IsShow;
                data.ModifyID     = UserManagement.CurrentUser.UserID;
                data.ModifyName   = UserManagement.CurrentUser.UserName;
                data.ModifyTime   = DateTime.Now;
                context.UpdateAndSave(data);
                return(string.Empty);
            };

            return(base.DbOperation(operation));
        }
Example #2
0
        /// <summary>
        /// 种植
        /// </summary>
        /// <param name="Epc"></param>
        /// <param name="OrCode"></param>
        /// <returns></returns>
        public string GetPlants(string Epc, string OrCode)
        {
            IPlansBatchService plansBatchService = new PlansBatchService();
            PlansBatchModel    model             = plansBatchService.GetPlansBatchByEPCOrORCode(Epc, OrCode);

            if (model == null)
            {
                return("");
            }
            return(JsonConvert.SerializeObject(new
            {
                BlockCode = model.LandBlock == null ? string.Empty : model.LandBlock.BlockCode,
                BlockName = model.LandBlock == null ? string.Empty : model.LandBlock.BlockName,
                SoilType = model.LandBlock == null ? string.Empty : model.LandBlock.SoilType,
                SoilName = model.LandBlock == null ? string.Empty : model.LandBlock.SoilName,
                SoilSalinity = model.LandBlock == null ? string.Empty : model.LandBlock.SoilSalinity,
                SoilQuality = model.LandBlock == null ? string.Empty : model.LandBlock.SoilQuality,

                SeedCode = model.SeedBase == null ? string.Empty : model.SeedBase.SeedCode,
                SeedNO = model.SeedBase == null ? string.Empty : model.SeedBase.SeedNO,
                SeedName = model.SeedBase == null ? string.Empty : model.SeedBase.SeedName,
                BatchNO = model.SeedBase == null ? string.Empty : model.SeedBase.BatchNO,
                Place = model.SeedBase == null ? string.Empty : model.SeedBase.Place,
                Supplier = model.SeedBase == null ? string.Empty : model.SeedBase.Supplier,
                PurchPerson = model.SeedBase == null ? string.Empty : model.SeedBase.PurchPerson,
                BuyTime = model.SeedBase == null ? null : model.SeedBase.BuyTime,
                Units = model.SeedBase == null ? string.Empty : model.SeedBase.Units,

                BatchCode = model.BatchCode,
                PlansTime = model.PlansTime,
                PlansYear = model.PlansYear
            }));
        }
        public void DeleteRow(PlansBatchModel model)
        {
            var result = MessageBox.Show("是否删除", "提示", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                var message = iPlansBatchService.DeleteSinglePlansBatch(model.BatchID);
                if (message.Status == MessageStatus.Success)
                {
                    LoadData(string.Empty);
                }
            }
        }
Example #4
0
        public MessageModel InsertSingleEntity(PlansBatchModel model)
        {
            Func <IEntityContext, string> operation = delegate(IEntityContext context)
            {
                model.ModifyID   = UserManagement.CurrentUser.UserID;
                model.ModifyName = UserManagement.CurrentUser.UserName;
                model.ModifyTime = DateTime.Now;
                context.PlansBatch.Add(model);
                context.SaveChanges();
                return(string.Empty);
            };

            return(base.DbOperation(operation));
        }
        public void EditRow(PlansBatchModel model)
        {
            var vm = IoC.Get <PlansBatchEditViewModel>();

            vm.Model = model;
            vm.Mode  = Models.EditMode.UPDATE;
            var result = IoC.Get <IWindowManager>().ShowDialog(vm, null, new Dictionary <string, object> {
                { "Title", "编辑" }, { "ResizeMode", System.Windows.ResizeMode.NoResize },
                { "Width", 450 },
                { "Height", 600 }
            });

            if (result ?? false)
            {
                LoadData(string.Empty);
            }
        }
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public JsonResult SavePlanData(PlansBatchModel model)
        {
            var result = new ResultJson();

            try
            {
                CPRODUCTEPC96 pro96 = new CPRODUCTEPC96();
                //种植场号
                pro96.BusinessCode = "3";
                //批次号
                pro96.BatchNo = model.BatchNO;
                //生成日期
                pro96.TagDate = DateTime.Now.ToString("yyyy年MM月dd日");
                var maxId = _codeMaxService.GetMaxCode("PlansBatch");
                //序号
                pro96.SeqNo = maxId;
                //标签类型
                pro96.EpcType   = "3";
                model.BatchCode = pro96.PackEpc();

                var msg = new MessageModel();
                if (model.BatchID == 0)
                {
                    msg = _plansBatchService.InsertSinglePlansBatch(model);
                }
                else
                {
                    msg = _plansBatchService.UpdateSinglePlansBatch(model);
                }

                if (msg.Status == MessageStatus.Success)
                {
                    result.IsSuccess = true;
                }
            }
            catch (Exception)
            {
                throw;
            }


            return(Json(result));
        }
        private void AddPlansBatch()
        {
            PlansBatchModel data = new PlansBatchModel();

            data.BlockID      = 2;
            data.SeedID       = 2;
            data.BatchNO      = "test";
            data.BatchCode    = "test";
            data.PlansTime    = DateTime.Now;
            data.PlansYear    = "test";
            data.HarvestTime  = DateTime.Now;
            data.PlansArea    = 10;
            data.ChargePerson = "test";
            data.HarvestCount = 10;
            data.RealCount    = 10;
            data.People       = "test";
            data.Remark       = "test";
            data.IsLocked     = false;
            data.IsShow       = true;

            IPlansBatchService cs = new PlansBatchService();
            var result            = cs.InsertSinglePlansBatch(data);
        }
Example #8
0
 /// <summary>
 /// 编辑单条PlansBatch
 /// </summary>
 /// <param name="model">种植计划实体</param>
 /// <returns></returns>
 public MessageModel UpdateSinglePlansBatch(PlansBatchModel model)
 {
     return(plansBatchAccess.UpdateSingleEntity(model));
 }
Example #9
0
 /// <summary>
 /// 新增单条PlansBatch
 /// </summary>
 /// <param name="model">种植计划实体</param>
 /// <returns></returns>
 public MessageModel InsertSinglePlansBatch(PlansBatchModel model)
 {
     return(plansBatchAccess.InsertSingleEntity(model));
 }