/// <summary>
        /// 更新资产信息
        /// </summary>
        /// <param name="assetsId">资产Id</param>
        public void AddDicByUpdateAssets(Guid assetsId)
        {
            Models.ys_BorrowOrderDetail mlast = GetLastOneByAssetsId(assetsId);

            string sqlText = @"UPDATE [AssetsSys].[dbo].[ys_Assets]
   SET [DepartmentId] = @DepartmentId
      ,[UserId] = @UserId
      ,[StatusId] = @StatusId
 WHERE [Id] = @Id";

            if (mlast != null)
            {
                SqlParameter   s1      = new SqlParameter("@Id", assetsId);
                SqlParameter   s2      = new SqlParameter("@DepartmentId", mlast.OldDepartmentId);
                SqlParameter   s3      = new SqlParameter("@UserId", mlast.OldUserId);
                SqlParameter   s5      = new SqlParameter("@StatusId", mlast.OldStatusId);
                SqlParameter[] cmdPara = new SqlParameter[] { s1, s2, s3, s5 };

                sqlDic.Add(cmdPara, sqlText);
            }
            else
            {
                throw new Exception("没有找到资产ID为:" + assetsId + " 借用记录");
            }
        }
 /// <summary>
 /// 保存领用单信息
 /// </summary>
 private void sbtnSave_Click(object sender, EventArgs e)
 {
     //检查用户输入是否合法、部门、人员、资产信息
     if (cbUser.EditValue != null && selectList.Count > 0)
     {
         model.Id                 = Guid.NewGuid();
         model.BorrowNo           = manager.GetNewBorrowNo();
         model.BorrowUserId       = clsPublic.GetObjGUID(cbUser.EditValue);
         model.BorrowUserName     = cbUser.Text;
         model.BorrowDepartmentId = userList.FirstOrDefault(a => a.Id == model.BorrowUserId).DepartmentId;
         model.OperatorId         = clsSession._UserId;
         model.OperatorName       = clsSession._FullName;
         model.Description        = tDescription.Text;
         model.Borrowday          = tBorrowday.DateTime;
         model.Planday            = tPlenday.DateTime;
         model.Detail             = new List <Models.ys_BorrowOrderDetail>();
         //循环获取资产数据集
         foreach (Models.ys_Assets m in selectList)
         {
             Models.ys_BorrowOrderDetail d = new Models.ys_BorrowOrderDetail();
             d.AssetsId          = m.Id;
             d.BorrowId          = model.Id;
             d.OldDepartmentId   = m.DepartmentId;
             d.OldDepartmentName = m.DepartmentName == null?"":m.DepartmentName;
             d.OldLocation       = m.Location;
             d.OldStatusId       = m.StatusId;
             d.OldStatusName     = m.StatusName;
             d.OldUserId         = m.UserId;
             d.OldUserName       = m.UserName == null ? "" : m.UserName;
             d.Id = Guid.NewGuid();
             model.Detail.Add(d);
         }
         //生成新的领用单
         if (manager.AddNew(model))
         {
             clsPublic.ShowMessage("保存成功!", Text);
             base.DialogResult = DialogResult.OK;
         }
         else
         {
             clsPublic.ShowMessage("保存失败!", Text);
         }
     }
     else
     {
         clsPublic.ShowMessage("借用人员、或借用的资产信息不能为空!", Text);
     }
 }
        /// <summary>
        /// 订单明细信息
        /// </summary>
        /// <param name="model">明细实体</param>
        public void AddDicByOrderDetail(Models.ys_BorrowOrderDetail model)
        {
            string sqlText = @"INSERT INTO [AssetsSys].[dbo].[ys_BorrowOrderDetail]
           ([Id]
           ,[BorrowId]
           ,[AssetsId]
           ,[OldUserName]
           ,[OldUserId]
           ,[OldDepartmentName]
           ,[OldDepartmentId]
           ,[OldLocation]
           ,[OldStatusId]
           ,[OldStatusName]
           ,[CreateTime]
           ,[IsRemoved])
     VALUES
           (@Id
           ,@BorrowId
           ,@AssetsId
           ,@OldUserName
           ,@OldUserId
           ,@OldDepartmentName
           ,@OldDepartmentId
           ,@OldLocation
           ,@OldStatusId
           ,@OldStatusName
           ,@CreateTime
           ,@IsRemoved)";

            SqlParameter s1  = new SqlParameter("@Id", model.Id);
            SqlParameter s2  = new SqlParameter("@BorrowId", model.BorrowId);
            SqlParameter s3  = new SqlParameter("@AssetsId", model.AssetsId);
            SqlParameter s4  = new SqlParameter("@OldUserName", model.OldUserName);
            SqlParameter s5  = new SqlParameter("@OldUserId", model.OldUserId);
            SqlParameter s6  = new SqlParameter("@OldDepartmentName", model.OldDepartmentName);
            SqlParameter s7  = new SqlParameter("@OldDepartmentId", model.OldDepartmentId);
            SqlParameter s8  = new SqlParameter("@OldLocation", model.OldLocation);
            SqlParameter s9  = new SqlParameter("@OldStatusId", model.OldStatusId);
            SqlParameter s12 = new SqlParameter("@OldStatusName", model.OldStatusName);
            SqlParameter s10 = new SqlParameter("@IsRemoved", model.IsRemoved);
            SqlParameter s11 = new SqlParameter("@CreateTime", model.CreateTime);

            SqlParameter[] cmdPara = new SqlParameter[] { s1, s2, s3, s4, s5, s6, s7, s8, s9, s12, s10, s11 };
            sqlDic.Add(cmdPara, sqlText);
        }