public void Delete(AscmUnloadingPointController ascmUnloadingPointController)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmUnloadingPointController>(ascmUnloadingPointController);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmUnloadingPointController)", ex);
         throw ex;
     }
 }
示例#2
0
        public ContentResult UnloadingPointControllerSave(AscmUnloadingPointController ascmUnloadingPointController_Model, int? id)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();
            try
            {
                string userName = string.Empty;
                if (User.Identity.IsAuthenticated)
                {
                    userName = User.Identity.Name;
                }
                if (ascmUnloadingPointController_Model.name == null || ascmUnloadingPointController_Model.name.Trim() == "")
                    throw new Exception("控制器名称不能为空");
                string name = ascmUnloadingPointController_Model.name.Trim();

                AscmUnloadingPointController ascmUnloadingPointController = null;
                if (id.HasValue)
                {
                    ascmUnloadingPointController = AscmUnloadingPointControllerService.GetInstance().Get(id.Value);
                    if (ascmUnloadingPointController == null)
                        throw new Exception("获取卸货点控制器失败!");
                }
                else
                {
                    ascmUnloadingPointController = new AscmUnloadingPointController();
                    int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmUnloadingPointController");
                    ascmUnloadingPointController.id = ++maxId;
                    ascmUnloadingPointController.createUser = userName;
                    ascmUnloadingPointController.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                }
                object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmUnloadingPointController where id<>" + ascmUnloadingPointController.id + " and name='" + name + "'");
                if (object1 == null)
                    throw new Exception("查询异常!");
                int count = 0;
                if (int.TryParse(object1.ToString(), out count) && count > 0)
                    throw new Exception("控制器名称【" + name + "】已存在");

                ascmUnloadingPointController.name = name;
                if (!string.IsNullOrEmpty(ascmUnloadingPointController_Model.ip))
                    ascmUnloadingPointController.ip = ascmUnloadingPointController_Model.ip.Trim();
                ascmUnloadingPointController.port = ascmUnloadingPointController_Model.port;
                ascmUnloadingPointController.modifyUser = userName;
                ascmUnloadingPointController.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                if (id.HasValue)
                    AscmUnloadingPointControllerService.GetInstance().Update(ascmUnloadingPointController);
                else
                    AscmUnloadingPointControllerService.GetInstance().Save(ascmUnloadingPointController);

                jsonObjectResult.result = true;
                jsonObjectResult.id = ascmUnloadingPointController.id.ToString();
                jsonObjectResult.message = "";
            }
            catch (Exception ex)
            {
                jsonObjectResult.message = ex.Message;
            }
            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }
 public void Update(AscmUnloadingPointController ascmUnloadingPointController)
 {
     try
     {
         using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
         {
             try
             {
                 YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmUnloadingPointController>(ascmUnloadingPointController);
                 tx.Commit();//正确执行提交
             }
             catch (Exception ex)
             {
                 tx.Rollback();//回滚
                 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmUnloadingPointController)", ex);
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Save AscmUnloadingPointController)", ex);
         throw ex;
     }
 }