コード例 #1
0
        /// <summary>
        /// 新增单位
        /// </summary>
        /// <returns></returns>
        public ActionResult Add()
        {
            string        MeasureName = WebUtil.GetFormValue <string>("MeasureName");
            string        CompanyID   = WebUtil.GetFormValue <string>("CompanyID");
            MeasureEntity entity      = new MeasureEntity();

            entity.MeasureName = MeasureName;
            entity.CompanyID   = CompanyID;
            entity.SN          = ConvertHelper.NewGuid();
            entity.MeasureNum  = new TNumProvider(CompanyID).GetSwiftNum(typeof(MeasureEntity), 5);
            MeasureProvider provider = new MeasureProvider(CompanyID);
            int             line     = provider.AddMeasure(entity);
            DataResult      result   = new DataResult();

            if (line > 0)
            {
                result.Code    = (int)EResponseCode.Success;
                result.Message = "单位新增成功";
            }
            else
            {
                result.Code    = (int)EResponseCode.Exception;
                result.Message = "单位新增失败";
            }
            return(Content(JsonHelper.SerializeObject(result)));
        }
コード例 #2
0
 public ActionResult Create(string Num, string Name)
 {
     if (Num.IsEmpty())
     {
         MeasureEntity entity = new MeasureEntity();
         entity.MeasureNum  = SequenceProvider.GetSequence(typeof(MeasureEntity));
         entity.MeasureName = Name;
         entity.SN          = SequenceProvider.GetSequence(typeof(MeasureEntity));
         MeasureProvider provider = new MeasureProvider();
         int             line     = provider.AddMeasure(entity);
         if (line > 0)
         {
             this.ReturnJson.AddProperty("Key", "1000");
             this.ReturnJson.AddProperty("Value", "添加成功");
         }
         else
         {
             this.ReturnJson.AddProperty("Key", "1001");
             this.ReturnJson.AddProperty("Value", "添加失败");
         }
     }
     else
     {
         MeasureProvider provider = new MeasureProvider();
         int             line     = provider.EditMeasure(Num, Name);
         if (line > 0)
         {
             this.ReturnJson.AddProperty("Key", "1000");
             this.ReturnJson.AddProperty("Value", "编辑成功");
         }
         else
         {
             this.ReturnJson.AddProperty("Key", "1001");
             this.ReturnJson.AddProperty("Value", "编辑失败");
         }
     }
     return(Content(this.ReturnJson.ToString()));
 }