Exemplo n.º 1
0
        public CExpense(int docNo)
        {
            var query = from b100 in _db.Expenses
                        join u100 in _db.Users on b100.CreatedId equals u100.UserId
                        join d100 in _db.SiteLocations on u100.SiteLocationId equals d100.SiteLocationId
                        join s100 in _db.Sites on d100.SiteId equals s100.SiteId

                        where b100.ExpenseId == docNo
                        select new
            {
                b100,
                u100,
                s100
            };

            foreach (var q in query)
            {
                DocNo       = q.b100.ExpenseId;
                Site        = q.s100.Name;
                Location    = q.s100.City;
                Name        = new CUser().GetUserName(q.u100);
                Date        = q.b100.CreatedDate.ToString();
                StartDate   = q.b100.PeriodStart;
                EndDate     = q.b100.PeriodEnd;
                CashAdvance = q.b100.CashAdvance;
                break;
            }
        }
Exemplo n.º 2
0
        public CPurchaseOrder(int docNo)
        {
            var query = from b100 in _db.PurchaseOrders
                        join u100 in _db.Users on b100.CreatedId equals u100.UserId
                        join d100 in _db.SiteLocations on u100.SiteLocationId equals d100.SiteLocationId
                        join s100 in _db.Sites on d100.SiteId equals s100.SiteId

                        where b100.PurchaseOrderId == docNo
                        select new
            {
                b100,
                u100,
                s100
            };

            foreach (var q in query)
            {
                DocNo    = q.b100.PurchaseOrderId;
                Site     = q.s100.Name;
                Location = q.s100.City;
                Name     = new CUser().GetUserName(q.u100);
                Date     = q.b100.CreatedDate.ToString();
                break;
            }
        }
Exemplo n.º 3
0
        public CExpense GetNewDocument(int currentUserId)
        {
            var result = _db.Users.Join(_db.SiteLocations, a => a.SiteLocationId, b => b.SiteLocationId, (a, b) => new { a, b }).Join(_db.Sites, a => a.b.SiteId, b => b.SiteId, (a, b) => new { a, b }).FirstOrDefault(x => x.a.a.UserId == currentUserId);

            DocNo    = 0;
            Site     = result.b.Name;
            Location = result.b.City;
            Name     = new CUser().GetUserName(result.a.a);
            Date     = DateTime.Now.ToString();
            return(this);
        }
Exemplo n.º 4
0
        public CBusinessTrip GetNewDocument(int currentUserId)
        {
            //int maxValue = db.BusinessTrips.Max(x => x.BusinessTripId);
            //DocNo = maxValue + 1;
            DocNo     = 0;
            ShelfLife = 5;
            var result = _db.Users.Join(_db.SiteLocations, a => a.SiteLocationId, b => b.SiteLocationId, (a, b) => new { a, b }).Join(_db.Sites, a => a.b.SiteId, b => b.SiteId, (a, b) => new { a, b }).FirstOrDefault(x => x.a.a.UserId == currentUserId);

            Site     = result.b.Name;
            Location = result.b.City;
            Name1    = new CUser().GetUserName(result.a.a);
            Name2    = DateTime.Now.ToString();
            return(this);
        }
Exemplo n.º 5
0
        public bool SendMail(CConstValue.Approval approvalType, CConstValue.MailStatus mailStatus, int index, string indexNumber, int userId)
        {
            try
            {
                var      requestedUserId = 0;
                DateTime requestedDate   = DateTime.Now;

                var      approvedUserId = 0;
                var      approvedMemo   = string.Empty;
                DateTime approvedDate   = DateTime.Now;

                var approvingUserId = 0;
                var approvalStatus  = string.Empty;

                var currentApproval = new CApprovalHistory().GetCurrentApproval((int)approvalType, index);
                if (currentApproval != null)
                {
                    var approvalStepDict = new CDict().GetDictByTypeAndValue(217, (int)currentApproval.ApprovalStep);
                    approvalStatus = approvalStepDict?.Name;
                    approvedMemo   = currentApproval.ApprovalMemo;
                    approvedDate   = currentApproval.ApprovalDate.Value;
                }

                switch (mailStatus)
                {
                case CConstValue.MailStatus.ToApproveUser:
                    requestedUserId = userId;
                    approvingUserId = new CApproval().GetSupuervisor((int)approvalType, userId);
                    break;

                case CConstValue.MailStatus.ToApproveUserAndRequestUser:
                    var tempRequestedUser1 = new CApprovalHistory().GetApprovalByRequestedUser((int)approvalType, index);
                    if (tempRequestedUser1 != null)
                    {
                        requestedUserId = tempRequestedUser1.ApprovalUser;
                        requestedDate   = tempRequestedUser1.CreatedDate;
                    }
                    approvedUserId  = userId;
                    approvingUserId = new CApproval().GetSupuervisor((int)approvalType, userId);

                    break;

                case CConstValue.MailStatus.ToRequestUser:
                    var tempRequestedUser2 = new CApprovalHistory().GetApprovalByRequestedUser((int)approvalType, index);
                    if (tempRequestedUser2 != null)
                    {
                        requestedUserId = tempRequestedUser2.ApprovalUser;
                        requestedDate   = tempRequestedUser2.CreatedDate;
                    }
                    approvedUserId = userId;
                    break;
                }

                var cUser         = new CUser();
                var requestedUser = cUser.Get(requestedUserId);
                var approvedUser  = cUser.Get(approvedUserId);
                var approvingUser = cUser.Get(approvingUserId);

                if (indexNumber == string.Empty)
                {
                    indexNumber = index.ToString();
                }

                // todo : temp to change mail should be removed before lunching.
                if (requestedUser != null)
                {
                    requestedUser.Email = "*****@*****.**";
                }
                if (approvedUser != null)
                {
                    approvedUser.Email = "*****@*****.**";
                }
                if (approvingUser != null)
                {
                    approvingUser.Email = "*****@*****.**";
                }

                var bodyToApprovingUser = $@"Dear <u><i>{cUser.GetUserName(approvingUser)}</i></u>,
                                            <p></p><br /><br />
                                            A new request is waiting for your approval.
                                            <br /><br />
                                            Please check it out.
                                            <p></p><br /><br />                                            
                                            <b>{approvalType}</b>
                                            <br /><br />
                                            &nbsp;&nbsp;&nbsp;- No : <b>{indexNumber}</b>
                                            <br />
                                            &nbsp;&nbsp;&nbsp;- Status : <b>{approvalStatus}</b>
                                            <br />
                                            &nbsp;&nbsp;&nbsp;- Requested by : <b>{cUser.GetUserName(requestedUser)}</b>
                                            <br />
                                            &nbsp;&nbsp;&nbsp;- Requested Date : <b>{CGlobal.GetDateFormat(requestedDate)}</b>";

                var bodyToRequestedUser = $@"Dear <u><i>{cUser.GetUserName(requestedUser)}</i></u>,
                                            <p></p><br /><br />
                                            Your request has been updated.
                                            <br /><br />
                                            Please check it out.
                                            <p></p><br /><br />
                                            <b>{approvalType}</b>
                                            <br /><br />
                                            &nbsp;&nbsp;&nbsp;- No : <b>{indexNumber}</b>
                                            <br />
                                            &nbsp;&nbsp;&nbsp;- Status : <b>{approvalStatus}</b>
                                            <br />
                                            &nbsp;&nbsp;&nbsp;- Approved by : <b>{cUser.GetUserName(approvedUser)}</b>
                                            <br />
                                            &nbsp;&nbsp;&nbsp;- Approved Date : <b>{CGlobal.GetDateFormat(approvedDate)}</b>
                                            <br />
                                            &nbsp;&nbsp;&nbsp;- Approved Memo : <b>{approvedMemo}</b>";

                switch (mailStatus)
                {
                case CConstValue.MailStatus.ToApproveUser:
                    SendMailPost(approvalType.ToString(), approvingUser.Email, bodyToApprovingUser);
                    break;

                case CConstValue.MailStatus.ToApproveUserAndRequestUser:
                    SendMailPost(approvalType.ToString(), requestedUser.Email, bodyToRequestedUser);
                    SendMailPost(approvalType.ToString(), approvingUser.Email, bodyToApprovingUser);
                    break;

                case CConstValue.MailStatus.ToRequestUser:
                    SendMailPost(approvalType.ToString(), requestedUser.Email, bodyToRequestedUser);
                    break;
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        public List <CApprovalSupervisorModel> GetSupervisorChart(int menuId, int siteId)
        {
            var result = new List <CApprovalSupervisorModel>();

            var qry = _db.Approvals.Where(q => q.IsActive && q.ApproveType == menuId);

            foreach (var q in qry)
            {
                var n = new CApprovalSupervisorModel();

                var cT = new CUser();
                var t  = cT.Get(Convert.ToInt32(q.UserId));

                if (t == null)
                {
                    continue;
                }

                n.UserId         = q.UserId;
                n.UserName       = cT.GetUserName(t);
                n.Supervisor     = q.Supervisor;
                n.UserPositionId = t.UserPositionId;

                //switch (MenuId)
                //{
                //    case ConstValue.APPROVAL_BASIC:
                //        if (SiteId == 1)
                //        {
                //            if (n.Supervisor != null && n.Supervisor == n.UserId)
                //                n.Supervisor = null;
                //        }
                //        else
                //        {
                //            if (n.UserId == 577)
                //            {
                //                n.Supervisor = null;
                //                if (n.Supervisor != null && n.Supervisor == n.UserId)
                //                    n.Supervisor = null;
                //            }
                //            else if (n.UserId == 578)
                //            {
                //                n.Supervisor = 0;
                //            }

                //        }
                //        break;
                //    case ConstValue.APPROVAL_AGENCY:
                //        if (n.UserId == 577)
                //        {
                //            n.Supervisor = null;
                //            if (n.Supervisor != null && n.Supervisor == n.UserId)
                //                n.Supervisor = null;
                //        }
                //        else if (n.UserId == 578)
                //        {
                //            n.Supervisor = 0;
                //        }
                //        break;
                //    case ConstValue.APPROVAL_SCHOLASHIP:
                //        break;
                //    case ConstValue.APPROVAL_REFUND:
                //        break;
                //    case ConstValue.APPROVAL_BCT:
                //        break;
                //    case ConstValue.APPROVAL_BUSINESS_TRIP:
                //        break;
                //}

                result.Add(n);
            }
            return(result);
        }