public void Delete(AscmLogisticsClassInfo ascmLogisticsClassInfo)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmLogisticsClassInfo>(ascmLogisticsClassInfo);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmLogisticsClassInfo)", ex);
         throw ex;
     }
 }
Пример #2
0
        public ContentResult LogisticsClassSave(AscmLogisticsClassInfo ascmLogisticsClassInfo_Model, int? id)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();

            try
            {
                string userName = string.Empty;
                if (User.Identity.IsAuthenticated)
                {
                    userName = User.Identity.Name;
                }

                AscmLogisticsClassInfo ascmLogisticsClassInfo = null;
                if (id.HasValue)
                {
                    ascmLogisticsClassInfo = AscmLogisticsClassInfoService.GetInstance().Get(id.Value);
                    ascmLogisticsClassInfo.modifyUser = userName;
                    ascmLogisticsClassInfo.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    ascmLogisticsClassInfo.logisticsName = ascmLogisticsClassInfo_Model.logisticsName;
                }
                else
                {
                    object obj = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmLogisticsClassInfo where logisticsName = '" + ascmLogisticsClassInfo_Model.logisticsName + "'");
                    if (obj == null)
                        throw new Exception("查询失败!");
                    int iCount = 0;
                    if (int.TryParse(obj.ToString(), out iCount) && iCount > 0)
                        throw new Exception("该物流组信息已存在!");

                    ascmLogisticsClassInfo = new AscmLogisticsClassInfo();
                    int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmLogisticsClassInfo");
                    ascmLogisticsClassInfo.id = ++maxId;
                    ascmLogisticsClassInfo.logisticsClass = ("Class" + ascmLogisticsClassInfo.id.ToString()).Trim().ToUpper();
                    ascmLogisticsClassInfo.logisticsName = ascmLogisticsClassInfo_Model.logisticsName;
                    ascmLogisticsClassInfo.createUser = userName;
                    ascmLogisticsClassInfo.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                    ascmLogisticsClassInfo.modifyUser = userName;
                    ascmLogisticsClassInfo.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                }

                if (ascmLogisticsClassInfo == null)
                    throw new Exception("保存物流组信息失败!");

                if (string.IsNullOrEmpty(ascmLogisticsClassInfo_Model.logisticsName))
                    throw new Exception("物流组名称不能为空!");

                if (ascmLogisticsClassInfo_Model.groupLeader == null || ascmLogisticsClassInfo_Model.monitorLeader == null)
                    throw new Exception("物流组长及物流班长不能为空!");

                ascmLogisticsClassInfo.groupLeader = ascmLogisticsClassInfo_Model.groupLeader;
                ascmLogisticsClassInfo.monitorLeader = ascmLogisticsClassInfo_Model.monitorLeader;

                if (id.HasValue)
                    AscmLogisticsClassInfoService.GetInstance().Update(ascmLogisticsClassInfo);
                else
                    AscmLogisticsClassInfoService.GetInstance().Save(ascmLogisticsClassInfo);

                jsonObjectResult.result = true;
                jsonObjectResult.message = "";
            }
            catch (Exception ex)
            {
                jsonObjectResult.result = false;
                jsonObjectResult.message = ex.Message;
            }

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