Ejemplo n.º 1
0
        public string ApprovedClaim(Guid claimId, Guid userId, string type)
        {
            using (var context = new VnrHrmDataContext())
            {
                var message = string.Empty;
                var status = string.Empty;
                var UserLogin = string.Empty;
                var objApprovedClaim = new List<object>();
                objApprovedClaim.AddRange(new object[6]);
                objApprovedClaim[4] = 1;
                objApprovedClaim[5] = int.MaxValue - 1;
                var lstApprovedClaim = GetData<FIN_ApproverECLAIMEntity>(objApprovedClaim, ConstantSql.hrm_fin_sp_get_ApproverECLAIM, UserLogin, ref status).ToList();

                var approvedType1 = FinApproverType.FIN_Claim_Profile.ToString();
                var approvedType2 = FinApproverType.FIN_Claim_Manufacture.ToString();

                var approvedEntity = lstApprovedClaim.Where(s => s.ApprovedID != null && s.ApprovedID.Value == userId && (s.ApprovedType == approvedType1 || s.ApprovedType == approvedType2)).FirstOrDefault();
                var claimEntity = GetData<FIN_ClaimEntity>(claimId, ConstantSql.hrm_hr_sp_get_ClaimById, UserLogin, ref status).FirstOrDefault();

                var objHistory = new List<object>();
                objHistory.AddRange(new object[10]);
                objHistory[8] = 1;
                objHistory[9] = int.MaxValue - 1;
                var lstHistory = GetData<FIN_HistoryApproveECLAIMEntity>(objHistory, ConstantSql.hrm_hr_sp_get_HistoryApprovedClaim, UserLogin, ref status).ToList();

                //var obTravelRequestItem = new List<object>();
                //obTravelRequestItem.Add(claimId);
                //var lstTravelRequestItem = GetData<FIN_TravelRequestItemEntity>(obTravelRequestItem, ConstantSql.hrm_hr_sp_get_TravelRequestItemByTravelRequestID, ref status).Where(s => s.Description2 != null && s.Description2 == "E_REJECTED").ToList();

                if (approvedEntity != null)
                {
                    if (claimEntity != null)
                    {
                        if (claimEntity.CashAdvanceID != null)
                        {
                            var cashAdvanceEntity = GetData<Fin_CashAdvanceEntity>(claimEntity.CashAdvanceID.Value, ConstantSql.hrm_hr_sp_get_CashAdvanceById, UserLogin, ref status).FirstOrDefault();
                            var lstHistoryCash = lstHistory.Where(s => s.CashAdvanceID != null && s.CashAdvanceID.Value == claimEntity.CashAdvanceID.Value && s.Status == "E_APPROVED" && s.UserApproveClaimID != null && s.UserApproveClaimID.Value == userId).ToList();
                            if (cashAdvanceEntity != null)
                            {
                                if (cashAdvanceEntity.TravelRequestID != null)
                                {
                                    var travelRequestEntity = GetData<FIN_TravelRequestEntity>(cashAdvanceEntity.TravelRequestID.Value, ConstantSql.hrm_hr_sp_get_TravelRequestById, UserLogin, ref status).FirstOrDefault();
                                    var lstHistoryTravel = lstHistory.Where(s => s.TravelRequestID != null && s.TravelRequestID.Value == cashAdvanceEntity.TravelRequestID.Value && s.Status == "E_APPROVED" && s.UserApproveClaimID != null && s.UserApproveClaimID.Value == userId).ToList();

                                    if (travelRequestEntity != null)
                                    {
                                        if (lstHistoryTravel.Count == 0)
                                        {
                                            var travelAddentity = new FIN_HistoryApproveECLAIMEntity();
                                            travelAddentity.TravelRequestID = cashAdvanceEntity.TravelRequestID;
                                            travelAddentity.UserApproveClaimID = (Guid?)approvedEntity.ID;
                                            travelAddentity.DateApproved = DateTime.Now;
                                            travelAddentity.Status = type;
                                            message = Add(travelAddentity);
                                        }
                                       
                                    }
                                }

                                if (lstHistoryCash.Count == 0)
                                {
                                    var cashAddEntity = new FIN_HistoryApproveECLAIMEntity();
                                    cashAddEntity.TravelRequestID = cashAdvanceEntity.TravelRequestID;
                                    cashAddEntity.CashAdvanceID = claimEntity.CashAdvanceID;
                                    cashAddEntity.UserApproveClaimID = (Guid?)approvedEntity.ID;
                                    cashAddEntity.DateApproved = DateTime.Now;
                                    cashAddEntity.Status = type;
                                    message = Add(cashAddEntity);
                                }
                                
                            }

                        }
                        var entity = new FIN_HistoryApproveECLAIMEntity();
                        entity.ClaimID = (Guid?)claimId;
                        entity.TravelRequestID = claimEntity.TravelRequestID;
                        entity.CashAdvanceID = claimEntity.CashAdvanceID;
                        entity.UserApproveClaimID = (Guid?)approvedEntity.ID;
                        entity.DateApproved = DateTime.Now;
                        entity.Status = type;
                        message = Add(entity);
                    }

                }
                else
                {
                    message = "Bạn Không Có Quyền Duyệt!";
                }

                return message;
            }
        }
Ejemplo n.º 2
0
        public string ApprovedCashAdvance(Guid cashAdvanceId, Guid userId, string type)
        {
            using (var context = new VnrHrmDataContext())
            {
                var message = string.Empty;
                var status = string.Empty;
                var UserLogin = string.Empty;
                var services = new BaseService();
                var objApprovedClaim = new List<object>();
                objApprovedClaim.AddRange(new object[6]);
                objApprovedClaim[4] = 1;
                objApprovedClaim[5] = int.MaxValue - 1;
                var lstApprovedClaim = GetData<FIN_ApproverECLAIMEntity>(objApprovedClaim, ConstantSql.hrm_fin_sp_get_ApproverECLAIM, UserLogin, ref status).ToList();

                var approvedType = FinApproverType.Fin_CashAdvance.ToString();

                var approvedEntity = lstApprovedClaim.Where(s => s.ApprovedID != null && s.ApprovedID.Value == userId && s.ApprovedType == approvedType).FirstOrDefault();

                var cashAdvanceEntity = GetData<Fin_CashAdvanceEntity>(cashAdvanceId, ConstantSql.hrm_hr_sp_get_CashAdvanceById, UserLogin, ref status).FirstOrDefault();

                var objHistory = new List<object>();
                objHistory.AddRange(new object[10]);
                objHistory[8] = 1;
                objHistory[9] = int.MaxValue - 1;
                var lstHistory = GetData<FIN_HistoryApproveECLAIMEntity>(objHistory, ConstantSql.hrm_hr_sp_get_HistoryApprovedClaim, UserLogin, ref status).ToList();

                if (approvedEntity != null)
                {
                    if (cashAdvanceEntity.TravelRequestID != null)
                    {
                        var travelEntity = GetData<FIN_TravelRequestEntity>(cashAdvanceEntity.TravelRequestID.Value, ConstantSql.hrm_hr_sp_get_TravelRequestById, UserLogin, ref status).FirstOrDefault();
                        var lstHistoryTravel = lstHistory.Where(s => s.TravelRequestID != null && s.TravelRequestID.Value == cashAdvanceEntity.TravelRequestID.Value && s.Status == "E_APPROVED" && s.UserApproveClaimID != null && s.UserApproveClaimID.Value == userId).ToList();
                        if (travelEntity != null)
                        {
                            if (lstHistoryTravel.Count == 0)
                            {
                                var entityAdd = new FIN_HistoryApproveECLAIMEntity();
                                entityAdd.TravelRequestID = cashAdvanceEntity.TravelRequestID;
                                entityAdd.UserApproveClaimID = (Guid?)approvedEntity.ID;
                                entityAdd.DateApproved = DateTime.Now;
                                entityAdd.Status = type;
                                message = Add(entityAdd);
                            }
                        }
                    }

                    var entity = new FIN_HistoryApproveECLAIMEntity();
                    entity.CashAdvanceID = (Guid?)cashAdvanceId;
                    if (cashAdvanceEntity != null)
                    {
                        entity.TravelRequestID = cashAdvanceEntity.TravelRequestID;
                    }
                    entity.UserApproveClaimID = (Guid?)approvedEntity.ID;
                    entity.DateApproved = DateTime.Now;
                    entity.Status = type;
                    message = Add(entity);
                }
                else
                {
                    message = "Bạn Không Có Quyền Duyệt!";
                }


                return message;
            }
        }
Ejemplo n.º 3
0
        public string ApprovedTravelRequest(Guid travelRequestId, Guid userId, string type) {
            using (var context = new VnrHrmDataContext())
            {
                var message = string.Empty;
                var status = string.Empty;
                var UserLogin = string.Empty;
                var objApprovedClaim = new List<object>();
                objApprovedClaim.AddRange(new object[6]);
                objApprovedClaim[4] = 1;
                objApprovedClaim[5] = int.MaxValue - 1;
                var lstApprovedClaim = GetData<FIN_ApproverECLAIMEntity>(objApprovedClaim, ConstantSql.hrm_fin_sp_get_ApproverECLAIM, UserLogin, ref status).ToList();

                var approvedType1 = FinApproverType.FIN_TravelRequest_Domestic.ToString();
                var approvedType2 = FinApproverType.FIN_TravelRequest_External.ToString();

                var approvedEntity = lstApprovedClaim.Where(s => s.ApprovedID != null && s.ApprovedID.Value == userId && (s.ApprovedType == approvedType1 || s.ApprovedType == approvedType2)).FirstOrDefault();


                //var obTravelRequestItem = new List<object>();
                //obTravelRequestItem.Add(travelRequestId);
                //var lstTravelRequestItem = GetData<FIN_TravelRequestItemEntity>(obTravelRequestItem, ConstantSql.hrm_hr_sp_get_TravelRequestItemByTravelRequestID, ref status).Where(s => s.Description2 != null && s.Description2 == "E_REJECTED").ToList();

                if (approvedEntity != null)
                {
                           
                        var entity = new FIN_HistoryApproveECLAIMEntity();
                        entity.TravelRequestID = (Guid?)travelRequestId;
                        entity.UserApproveClaimID = (Guid?)approvedEntity.ID;
                        entity.DateApproved = DateTime.Now;
                        entity.Status = type;
                        message = Add(entity);
                    

                }
                else 
                {
                    message = "Bạn Không Có Quyền Duyệt!";
                }


                return message;
            }
        }