Beispiel #1
0
        public bool DelFormWork(string checkCode, int AccountID, FormWork entity, ref string ErrMsg)
        {
            if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
                return false;
            if (entity == null)
            {
                ErrMsg = "模板信息为空";
                return false;
            }
            FormWork _tmp = entities.FormWorks.FirstOrDefault(p => p.ID == entity.ID);
            if (_tmp == null)
            {
                ErrMsg = "该模板不存在或已删除";
                return false;
            }

            try
            {
                entities.FormWorks.Remove(_tmp);
                if (entities.SaveChanges() <= 0)
                {
                    ErrMsg = "删除失败";
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return false;
            }
        }
Beispiel #2
0
        public bool AddFormWork(string checkCode, int AccountID, FormWork entity, ref string ErrMsg)
        {
            if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
                return false;
            if (entity == null)
            {
                ErrMsg = "模板信息为空";
                return false;
            }
            if (string.IsNullOrEmpty(entity.ProductModel))
            {
                ErrMsg = "产品型号不能为空";
                return false;
            }
            if (entity.BoxPCSQty <= 0)
            {
                ErrMsg = "请填写每箱数量";
                return false;
            }
            if (entity.BoxQty <= 0)
            {
                ErrMsg = "请填写每托箱数";
                return false;
            }
            if (entity.IDNumber <= 0)
            {
                ErrMsg = "请填写ID位数";
                return false;
            }
            if (string.IsNullOrEmpty(entity.IDKeyWords))
            {
                ErrMsg = "关键字不能为空,请根据ID位数限制输入关键字";
                return false;
            }

            entity.CreateDt = DateTime.Now;
            try
            {
                if (entities.FormWorks.Any(p => p.ProductModel == entity.ProductModel))
                {
                    ErrMsg = "型号不能重复";
                    return false;
                }
                entities.FormWorks.Add(entity);
                if (entities.SaveChanges() <= 0)
                {
                    ErrMsg = "添加失败";
                    return false;
                }
                return true;
            }
            catch (Exception ex)
            {
                ErrMsg = ex.Message;
                return false;
            }
        }
Beispiel #3
0
 public bool ModifyFormWork(string checkCode, int AccountID, FormWork entity, ref string ErrMsg)
 {
     if (!CheckingCheckCode(checkCode, AccountID, ref ErrMsg))
         return false;
     if (entity == null)
     {
         ErrMsg = "模板信息为空";
         return false;
     }
     if (string.IsNullOrEmpty(entity.ProductModel))
     {
         ErrMsg = "产品型号不能为空";
         return false;
     }
     if (entity.BoxPCSQty <= 0)
     {
         ErrMsg = "请填写每箱数量";
         return false;
     }
     if (entity.BoxQty <= 0)
     {
         ErrMsg = "请填写每托箱数";
         return false;
     }
     if (entity.IDNumber <= 0)
     {
         ErrMsg = "请填写ID位数";
         return false;
     }
     if (string.IsNullOrEmpty(entity.IDKeyWords))
     {
         ErrMsg = "关键字不能为空,请根据ID位数限制输入关键字";
         return false;
     }
     entity.ModifyDt = DateTime.Now;
     try
     {
         var entry = entities.Entry<FormWork>(entity);
         if (entry.State == EntityState.Detached)
         {
             entities.Set<FormWork>().Attach(entity);
             entry.State = EntityState.Modified;
         }
         if (entities.SaveChanges() <= 0)
         {
             ErrMsg = "修改失败";
             return false;
         }
         return true;
     }
     catch (Exception ex)
     {
         ErrMsg = ex.Message;
         return false;
     }
 }