public void Delete(AscmUnloadingPoint ascmUnloadingPoint)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmUnloadingPoint>(ascmUnloadingPoint);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmUnloadingPoint)", ex);
         throw ex;
     }
 }
Beispiel #2
0
        public static void AscmUnloadingPointUpdate(AscmUnloadingPoint point)
        {
            try
            {
                String ConnectionString = " Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.16.9.191)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=md_ascm)));User Id=ascm;Password=AScm1240#;";
                OracleConnection conn = new OracleConnection(ConnectionString);
                conn.Open();
                string modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                string sql = "update ascm_unloading_point set status = '"+ point.status + "', modifytime = '" + modifyTime + "' where id = " + point.id;
                OracleCommand cmd = new OracleCommand(sql, conn);
                cmd.ExecuteNonQuery();
                conn.Close();

            }
            catch (Exception e)
            {
            }
        }
Beispiel #3
0
        public ContentResult UnloadingPointSave(AscmUnloadingPoint ascmUnloadingPoint_Model, int? id)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();
            try
            {
                string userName = string.Empty;
                if (User.Identity.IsAuthenticated)
                {
                    userName = User.Identity.Name;
                }
                if (ascmUnloadingPoint_Model.name == null || ascmUnloadingPoint_Model.name.Trim() == "")
                    throw new Exception("卸货点名称不能为空");
                string name = ascmUnloadingPoint_Model.name.Trim();

                AscmWarehouse ascmWarehouse = AscmWarehouseService.GetInstance().Get(ascmUnloadingPoint_Model.warehouseId);
                if (ascmWarehouse == null)
                    throw new Exception("仓库不能为空");

                AscmUnloadingPoint ascmUnloadingPoint = null;
                if (id.HasValue)
                {
                    ascmUnloadingPoint = AscmUnloadingPointService.GetInstance().Get(id.Value);
                    if (ascmUnloadingPoint == null)
                        throw new Exception("保存卸货点失败!");
                }
                else
                {
                    ascmUnloadingPoint = new AscmUnloadingPoint();
                    int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmUnloadingPoint");
                    ascmUnloadingPoint.id = ++maxId;
                    ascmUnloadingPoint.createUser = userName;
                    ascmUnloadingPoint.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                }
                object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmUnloadingPoint where id<>" + ascmUnloadingPoint.id + " and warehouseId='" + ascmWarehouse.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("仓库【" + ascmWarehouse.id + "】已存在卸货点名称");

                ascmUnloadingPoint.name = name;
                ascmUnloadingPoint.ascmWarehouse = ascmWarehouse;
                ascmUnloadingPoint.warehouseId = ascmWarehouse.id;
                ascmUnloadingPoint.controllerId = ascmUnloadingPoint_Model.controllerId;
                ascmUnloadingPoint.controllerAddress = ascmUnloadingPoint_Model.controllerAddress;
                if (!string.IsNullOrEmpty(ascmUnloadingPoint_Model.direction))
                    ascmUnloadingPoint.direction = ascmUnloadingPoint_Model.direction.Trim();
                if (!string.IsNullOrEmpty(ascmUnloadingPoint_Model.location))
                    ascmUnloadingPoint.location = ascmUnloadingPoint_Model.location.Trim();
                ascmUnloadingPoint.status = ascmUnloadingPoint_Model.status;
                ascmUnloadingPoint.ip = ascmUnloadingPoint_Model.ip;
                ascmUnloadingPoint.enabled = ascmUnloadingPoint_Model.enabled;
                if (!string.IsNullOrEmpty(ascmUnloadingPoint_Model.description))
                    ascmUnloadingPoint.description = ascmUnloadingPoint_Model.description.Trim();
                if (!string.IsNullOrEmpty(ascmUnloadingPoint_Model.memo))
                    ascmUnloadingPoint.memo = ascmUnloadingPoint_Model.memo.Trim();
                ascmUnloadingPoint.modifyUser = userName;
                ascmUnloadingPoint.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                if (id.HasValue)
                    AscmUnloadingPointService.GetInstance().Update(ascmUnloadingPoint);
                else
                    AscmUnloadingPointService.GetInstance().Save(ascmUnloadingPoint);

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