Exemplo n.º 1
0
 /// <summary>
 /// 增加打印插件
 /// </summary>
 /// <param name="printername">插件名</param>
 /// <param name="depotID">仓库ID</param>
 /// <returns></returns>
 public ActionResult AddPrinter(string printername, int depotID)
 {
     DBModel.Common.ComResult res = new DBModel.Common.ComResult();
     try
     {
         if (!Regex.IsMatch(printername, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(printername))
         {
             res.Msg   = "插件名称不能有非法字符";
             res.State = 0;
             return(Json(res));
         }
         if (string.IsNullOrEmpty(printername))
         {
             res.Msg   = "插件名称不能为空";
             res.State = 0;
             return(Json(res));
         }
         base_print pro = new base_print();
         pro.Createtime = DateTime.Now;
         pro.del_flag   = 0;
         pro.DepotID    = depotID;
         pro.isonline   = 0;
         pro.p_name     = printername;
         int  isexit = 0;
         int  id     = 0;
         bool isok   = _service.AddPrinter(pro, out isexit, out id);
         if (1 == isexit)
         {
             res.Msg   = "此打印插件已存在且被删除是否恢复?";
             res.URL   = id.ToString();
             res.State = 2;
             return(Json(res));
         }
         if (2 == isexit)
         {
             res.Msg   = "已存在此打印插件";
             res.State = 0;
             return(Json(res));
         }
         if (isok)
         {
             res.Msg   = "添加成功";
             res.State = 1;
             res.URL   = "/Printer/Index";
             return(Json(res));
         }
         else
         {
             res.Msg   = "添加失败";
             res.State = 0;
             return(Json(res));
         }
     }
     catch (Exception ex)
     {
         res.Msg   = ex.ToString();
         res.State = 0;
         return(Json(res));
     }
 }