コード例 #1
0
ファイル: GageController.cs プロジェクト: qqqer/AssetSystem
        public bool ArchiveLendSlip(LendSlip paras)
        {
            int    API   = 5;
            string token = HttpContext.Current.Request.Headers.Get("token");

            if (Models.UniversalModels.User.IsValidToken(token))
            {
                User CurrentUser = Models.UniversalModels.User.GetUserByToken(token);

                if (Models.UniversalModels.User.IsContainsCurrentAPIPermission(CurrentUser.UserID, API))
                {
                    Log log = new Log(API, CurrentUser);
                    log.Add(token + "|" + nameof(paras) + ":" + JsonConvert.SerializeObject(paras));

                    try
                    {
                        bool s = new GageServiceImpl().ArchiveLendSlip(paras);
                        return(s);
                    }
                    catch (Exception ex)
                    {
                        log.Add("Exception:" + ex.Message + "|" + ex.StackTrace);
                        return(false);
                    }
                }
            }
            throw new HttpResponseException(HttpStatusCode.Forbidden);
        }//5
コード例 #2
0
        public virtual bool AddLendSlip(LendSlip lendSlip, User CurrentUser)
        {
            using (SqlConnection conn = new SqlConnection(Common.SQLHelper.Asset_strConn))
            {
                conn.Open();
                SqlTransaction sqlTransaction = conn.BeginTransaction();
                try
                {
                    Asset asset = Asset.GetBy(lendSlip.AssetID);
                    if (asset == null)
                    {
                        throw new Exception("资产不存在");
                    }
                    if (asset.Status != "在库")
                    {
                        throw new Exception("资产未处于在库状态");
                    }

                    lendSlip.AssetName          = asset.AssetName;
                    lendSlip.AssetCategory      = asset.AssetCategory;
                    lendSlip.ApplicantName      = Personnel.GetBy(lendSlip.ApplicantID).Name;
                    lendSlip.LendDate           = DateTime.Now;
                    lendSlip.TransactorName     = CurrentUser.Name;
                    lendSlip.ReceiverDepartment = Personnel.GetBy(lendSlip.ApplicantID).Department;

                    asset.CurrentWhereSpot         = lendSlip.WhereUsing;// + lendSlip.ApplicantName;
                    asset.CurrentWhereOrganization = lendSlip.ReceiverDepartment;
                    asset.Status = asset.AddStatus("领用");

                    lendSlip.sqlTransaction = asset.sqlTransaction = sqlTransaction;
                    lendSlip.Add();
                    asset.Update();

                    sqlTransaction.Commit();
                    return(true);
                }
                catch
                {
                    sqlTransaction.Rollback();
                    throw;
                }
            }
        }
コード例 #3
0
        public virtual bool ArchiveLendSlip(LendSlip paras)
        {
            using (SqlConnection conn = new SqlConnection(Common.SQLHelper.Asset_strConn))
            {
                conn.Open();
                SqlTransaction sqlTransaction = conn.BeginTransaction();
                try
                {
                    LendSlip lendSlip = LendSlip.GetBy(paras.ID);


                    Asset asset = Asset.GetBy(lendSlip.AssetID);
                    if (asset == null)
                    {
                        throw new Exception("资产不存在");
                    }
                    if (!asset.Status.Contains("领用"))
                    {
                        throw new Exception("资产未被领用");
                    }


                    asset.RemoveStatus("领用");
                    asset.RefreshPosition();

                    paras.CopyTo(lendSlip, false);
                    lendSlip.ReturnDate = DateTime.Now;

                    asset.sqlTransaction = lendSlip.sqlTransaction = sqlTransaction;
                    asset.Update();
                    lendSlip.Update();

                    sqlTransaction.Commit();
                    return(true);
                }
                catch
                {
                    sqlTransaction.Rollback();
                    throw;
                }
            }
        }
コード例 #4
0
 public virtual IEnumerable <LendSlip> GetLendSlipsOf(string AssetID)
 {
     return(LendSlip.GetBy(AssetID));
 }
コード例 #5
0
 public virtual IEnumerable <LendSlip> GetAllLendSlips()
 {
     return(LendSlip.GetAll());
 }