コード例 #1
0
        private bool ValidateControls()
        {
            try
            {
                var period = int.Parse(ddlPaymentPeriod.SelectedValue);

                if (period < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Please Select a Period.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (period == 3)
                {
                    if (string.IsNullOrEmpty(txtPaymentStart.Text.Trim()) && string.IsNullOrEmpty(txtPaymentEndDate.Text.Trim()))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }

                    if (string.IsNullOrEmpty(txtPaymentStart.Text.Trim()) || string.IsNullOrEmpty(txtPaymentStart.Text.Trim()))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }

                    if (!string.IsNullOrEmpty(txtPaymentStart.Text.Trim()))
                    {
                        if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtPaymentStart.Text.Trim())))
                        {
                            ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                            return(false);
                        }
                    }


                    if (!string.IsNullOrEmpty(DateMap.ReverseToServerDate(txtPaymentEndDate.Text.Trim())))
                    {
                        if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtPaymentEndDate.Text.Trim())))
                        {
                            ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                            return(false);
                        }
                    }

                    if (!DateMap.IsEarlyDate(DateMap.ReverseToServerDate(txtPaymentStart.Text.Trim()), DateMap.ReverseToServerDate(txtPaymentEndDate.Text.Trim())))
                    {
                        ConfirmAlertBox1.ShowMessage("The 'From' date should not be LATER than the 'To' date.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                }

                return(true);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #2
0
        public long AddExpenseTransactionPaymentHistory(xPlug.BusinessObject.ExpenseTransactionPaymentHistory expenseTransactionPaymentHistory)
        {
            try
            {
                //Re-Map Object to Entity Object
                var myEntityObj = ExpenseTransactionPaymentHistoryMapper.Map <xPlug.BusinessObject.ExpenseTransactionPaymentHistory, ExpenseTransactionPaymentHistory>(expenseTransactionPaymentHistory);
                if (myEntityObj == null)
                {
                    return(-2);
                }
                using (var db = new ExpenseManagerDBEntities())
                {
                    db.AddToExpenseTransactionPaymentHistories(myEntityObj);
                    db.SaveChanges();
                    expenseTransactionPaymentHistory.ExpenseTransactionPaymentHistoryId = myEntityObj.ExpenseTransactionPaymentHistoryId;
                    var paymentVoucher = new BusinessObject.PaymentVoucherNumber
                    {
                        TransactionId          = expenseTransactionPaymentHistory.ExpenseTransactionPaymentHistoryId,
                        TransactionTotalAmount = expenseTransactionPaymentHistory.ExpenseTransaction.TotalApprovedAmount,
                        PaymentDate            = expenseTransactionPaymentHistory.PaymentDate,
                        DateSubmitted          = DateMap.GetLocalDate()
                    };
                    var pcvEntityObj = PaymentVoucherNumberMapper.Map <BusinessObject.PaymentVoucherNumber, PaymentVoucherNumber>(paymentVoucher);
                    db.AddToPaymentVoucherNumbers(pcvEntityObj);
                    db.SaveChanges();

                    return(expenseTransactionPaymentHistory.ExpenseTransactionPaymentHistoryId);
                }
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(0);
            }
        }
コード例 #3
0
        private static bool ValidateVouchersByDateArguments(string startDate, string endDate)
        {
            try
            {
                if (!string.IsNullOrEmpty(startDate.Trim()))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(startDate.Trim())))
                    {
                        return(false);
                    }
                }


                if (!string.IsNullOrEmpty(endDate.Trim()))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(endDate.Trim())))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
コード例 #4
0
        private bool GetAccountsHeadsCostsByDateRange()
        {
            try
            {
                dgCostItems.DataSource = new List <ExpenseTransaction>();
                dgCostItems.DataBind();
                var accountHeadId = int.Parse(ddlAccountsHeads.SelectedValue);
                if (accountHeadId < 1)
                {
                    ErrorDisplay1.ShowError("Please select an Expense Item.");
                    return(false);
                }

                var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                var startDate       = DateTime.Parse(startDateString);
                var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                var endDate         = DateTime.Parse(endDateString);
                if (endDate < startDate || startDate > endDate)
                {
                    ErrorDisplay1.ShowError("The 'From' date must not be LATER than the 'To' date.");
                    return(false);
                }

                var transactionItems =
                    ServiceProvider.Instance()
                    .GetTransactionItemServices()
                    .GetAccountsHeadsCostsByDateRange(accountHeadId, startDateString, endDateString);

                if (!transactionItems.Any())
                {
                    ErrorDisplay1.ShowError("No Record found!");
                    return(false);
                }

                //dgCostItems.DataSource = transactionItems;
                //dgCostItems.DataBind();

                Session["_accountsHeadeadCosts"] = null;
                Session["_accountsHeadeadCosts"] = transactionItems;
                lblGrandTotal.InnerText          = "N" + NumberMap.GroupToDigits(transactionItems[0].GrandTotalApprovedPrice.ToString(CultureInfo.InvariantCulture));
                headTitle.InnerText = ddlAccountsHeads.SelectedItem.Text;
                Limit = int.Parse(ddlLimit.SelectedValue);
                FillRepeater <TransactionItem>(dgCostItems, "_accountsHeadeadCosts", Navigation.None, Limit, LoadMethod);
                return(true);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
コード例 #5
0
        public string GetVoidedTransactionPaymentsByDateRange(string startDate, string endDate, string dept)
        {
            if (!ValidateVouchersByDateArguments(startDate, endDate))
            {
                return(null);
            }

            if (string.IsNullOrEmpty(startDate) || string.IsNullOrEmpty(endDate))
            {
                return(null);
            }

            try
            {
                var start  = DateTime.Parse(DateMap.ReverseToServerDate(startDate.Trim()));
                var end    = DateTime.Parse(DateMap.ReverseToServerDate(endDate.Trim()));
                var id     = 0;
                var deptId = 0;
                var result = int.TryParse(dept, out deptId);
                if (result)
                {
                    id = deptId;
                }
                if (end < start || start > end)
                {
                    return(null);
                }

                var historyObjeList =
                    ServiceProvider.Instance()
                    .GetExpenseTransactionPaymentHistoryServices()
                    .GetVoidedTransactionPaymentsByDateRange(start, end, id);

                if (historyObjeList == null || !historyObjeList.Any())
                {
                    return(null);
                }

                var jsSerializer = new JavaScriptSerializer {
                    MaxJsonLength = Int32.MaxValue
                };
                return(jsSerializer.Serialize(historyObjeList));
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #6
0
        private bool UpdateTransaction()
        {
            try
            {
                if (Session["_transaction"] == null)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var transaction = Session["_transaction"] as ExpenseTransaction;

                if (transaction == null || transaction.ExpenseTransactionId < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Session has expired.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                transaction.ApproverComment     = txtApproverComment.Text.Trim();
                transaction.DateApproved        = DateMap.GetLocalDate();
                transaction.TimeApproved        = DateMap.GetLocalTime();
                transaction.ApproverId          = int.Parse(new PortalServiceManager().GetUserIdByUsername(HttpContext.Current.User.Identity.Name).ToString(CultureInfo.InvariantCulture));
                transaction.TotalApprovedAmount = 0;

                if (radReject.Checked)
                {
                    transaction.Status = 2;
                }

                if (radVoid.Checked)
                {
                    transaction.Status = 3;
                }

                if (!ServiceProvider.Instance().GetExpenseTransactionServices().UpdateExpenseTransaction(transaction))
                {
                    ConfirmAlertBox1.ShowMessage("The process could not be completed. Please try again.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                return(true);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("The required process failed. Please try again.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #7
0
        private bool AddTransactionPaymentHistory(long transactionPaymentId)
        {
            try
            {
                if (Session["_staffExpenseTransactionPayment"] == null)
                {
                    ErrorDisplay1.ShowError("Expense Transaction list is empty or session has expired.");
                    return(false);
                }

                var expenseTransactionPayment = Session["_staffExpenseTransactionPayment"] as StaffExpenseTransactionPayment;

                if (expenseTransactionPayment == null || expenseTransactionPayment.StaffExpenseTransactionId < 1)
                {
                    ErrorDisplay1.ShowError("Expense Transaction list is empty or session has expired.");
                    return(false);
                }

                var newOrModifiedTransactioPaymentHistory = new StaffExpenseTransactionPaymentHistory
                {
                    StaffExpenseTransactionId        = expenseTransactionPayment.StaffExpenseTransactionId,
                    StaffExpenseTransactionPaymentId = transactionPaymentId,
                    PaymentDate = DateMap.GetLocalDate(),
                    PaymentTime = DateMap.GetLocalTime(),
                    Status      = 1,
                    AmountPaid  = double.Parse(txtAmountPaid.Value.Trim()),
                    PaidById    = new PortalServiceManager().GetUserIdByUsername(HttpContext.Current.User.Identity.Name),
                    Comment     = txtPaymentComment.Text.Trim(),
                };

                var k = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentHistoryServices().AddStaffExpenseTransactionPaymentHistory(newOrModifiedTransactioPaymentHistory);

                if (k < 1)
                {
                    ErrorDisplay1.ShowError("The Transaction Payment Information could not be Updated");
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                return(false);
            }
        }
コード例 #8
0
        private long UpdateTransactionPayment()
        {
            ErrorDisplay1.ClearError();
            try
            {
                if (Session["_staffExpenseTransactionPayment"] == null)
                {
                    ErrorDisplay1.ShowError("Expense Transaction Payment list is empty or session has expired.");
                    return(0);
                }

                var expenseTransactionPayment = Session["_staffExpenseTransactionPayment"] as StaffExpenseTransactionPayment;

                if (expenseTransactionPayment == null || expenseTransactionPayment.StaffExpenseTransactionId < 1)
                {
                    ErrorDisplayCompletePayment.ShowError("Invalid record selection.");
                    mpeSelectDateRangePopup.Show();
                    return(0);
                }

                expenseTransactionPayment.Balance                   = expenseTransactionPayment.Balance - double.Parse(txtAmountPaid.Value.Trim());
                expenseTransactionPayment.TotalAmountPayable        = double.Parse(txtApprovedTotalAmount.Text.Trim());
                expenseTransactionPayment.StaffExpenseTransactionId = expenseTransactionPayment.StaffExpenseTransactionId;
                expenseTransactionPayment.LastPaymentDate           = DateMap.GetLocalDate();
                expenseTransactionPayment.LastPaymentTime           = DateMap.GetLocalTime();
                expenseTransactionPayment.Status     = 1;
                expenseTransactionPayment.AmountPaid = double.Parse(txtAmountPaid.Value.Trim()) + expenseTransactionPayment.AmountPaid;

                var k = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().UpdateStaffExpenseTransactionPayment(expenseTransactionPayment);

                if (k < 1)
                {
                    ErrorDisplay1.ShowError("The Transaction information could not be updated");
                    return(0);
                }

                ErrorDisplay1.ShowSuccess("Expense Transaction Information was successfully updated");
                return(k);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                return(0);
            }
        }
コード例 #9
0
        public bool GetApprovedTransactionPaymentVouchersByDateRange(string startDate, string endDate)
        {
            if (!ValidateVouchersByDateArguments(startDate, endDate))
            {
                return(false);
            }

            try
            {
                var start = DateTime.Parse(DateMap.ReverseToServerDate(startDate.Trim()));
                var end   = DateTime.Parse(DateMap.ReverseToServerDate(endDate.Trim()));
                var dept  = int.Parse(ddlDepartmentVoucher.SelectedValue);
                if (dept < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Please select a Department!", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (end < start || start > end)
                {
                    ConfirmAlertBox1.ShowMessage("The START date must be earlier than the END DATE!", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                var paymenthistoryObjList =
                    ServiceProvider.Instance()
                    .GetExpenseTransactionPaymentHistoryServices()
                    .GetApprovedTransactionPaymentsByDateRange(start, end, dept);

                if (paymenthistoryObjList == null || !paymenthistoryObjList.Any())
                {
                    ConfirmAlertBox1.ShowMessage("No record found!", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                dgVouchers.DataSource = paymenthistoryObjList;
                dgVouchers.DataBind();
                return(true);
            }
            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again or contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
コード例 #10
0
        private bool ValidateControls()
        {
            try
            {
                if (string.IsNullOrEmpty(txtStart.Text.Trim()) && string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    ErrorDisplay1.ShowError("Please enter at least a date.");
                    return(false);
                }

                if (!string.IsNullOrEmpty(txtStart.Text.Trim()))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtStart.Text.Trim())))
                    {
                        ErrorDisplay1.ShowError("Please enter a valid date.");
                        return(false);
                    }
                }


                if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtEndDate.Text.Trim())))
                    {
                        ErrorDisplay1.ShowError("Please enter a valid date.");
                        return(false);
                    }
                }

                if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    if (!DateMap.IsEarlyDate(DateMap.ReverseToServerDate(txtStart.Text.Trim()), DateMap.ReverseToServerDate(txtEndDate.Text.Trim())))
                    {
                        ErrorDisplay1.ShowError("The 'From' date should not be LATER than the 'To' date.");
                        return(false);
                    }
                }
                return(true);
            }
            catch
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                return(false);
            }
        }
コード例 #11
0
        private bool ValidateVouchersByDateArguments(string startDate, string endDate)
        {
            try
            {
                if (string.IsNullOrEmpty(startDate) && string.IsNullOrEmpty(endDate))
                {
                    ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (string.IsNullOrEmpty(startDate) || string.IsNullOrEmpty(startDate))
                {
                    ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (!string.IsNullOrEmpty(startDate))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(startDate)))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                }


                if (!string.IsNullOrEmpty(DateMap.ReverseToServerDate(endDate)))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(endDate)))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                }

                return(true);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #12
0
        private bool ValidateDateControls()
        {
            try
            {
                if (string.IsNullOrEmpty(txtStart.Text.Trim()) && string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (string.IsNullOrEmpty(txtStart.Text.Trim()) || string.IsNullOrEmpty(txtStart.Text.Trim()))
                {
                    ConfirmAlertBox1.ShowMessage("Please enter a date range.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }

                if (!string.IsNullOrEmpty(txtStart.Text.Trim()))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtStart.Text.Trim())))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                }


                if (!string.IsNullOrEmpty(DateMap.ReverseToServerDate(txtEndDate.Text.Trim())))
                {
                    if (!DateMap.IsDate(DateMap.ReverseToServerDate(txtEndDate.Text.Trim())))
                    {
                        ConfirmAlertBox1.ShowMessage("Please enter a valid date.", ConfirmAlertBox.PopupMessageType.Error);
                        return(false);
                    }
                }

                return(true);
            }
            catch
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #13
0
        private void GetTransactionsByDate()
        {
            try
            {
                dgUserInitiatedTransactions.DataSource = new List <ExpenseTransaction>();
                dgUserInitiatedTransactions.DataBind();

                if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                    var startDate       = DateTime.Parse(startDateString);
                    var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                    var endDate         = DateTime.Parse(endDateString);
                    if (endDate < startDate || startDate > endDate)
                    {
                        ConfirmAlertBox1.ShowMessage("The 'From' date must not be LATER than the 'TO' date.", ConfirmAlertBox.PopupMessageType.Error);
                        dgUserInitiatedTransactions.DataSource = new List <ExpenseTransaction>();
                        dgUserInitiatedTransactions.DataBind();
                        return;
                    }

                    var expTransactionsByDate = ServiceProvider.Instance().GetExpenseTransactionServices().GetPendingTransactionsByDateRange(startDate, endDate);
                    if (!expTransactionsByDate.Any())
                    {
                        ConfirmAlertBox1.ShowMessage("No record found.", ConfirmAlertBox.PopupMessageType.Error);
                        return;
                    }

                    Session["_expTransactionListToApprove"] = null;
                    Session["_expTransactionListToApprove"] = expTransactionsByDate;

                    Limit = int.Parse(ddlLimit.SelectedValue);
                    FillRepeater <ExpenseTransaction>(dgUserInitiatedTransactions, "_expTransactionListToApprove", Navigation.None, Limit, LoadMethod);
                    SetTransactionsStyle();
                }
            }
            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
            }
        }
コード例 #14
0
        public string GetVoidedTransactionPaymentVouchersByDateRange(string startDate, string endDate)
        {
            if (!ValidateVouchersByDateArguments(startDate, endDate))
            {
                return(null);
            }

            if (string.IsNullOrEmpty(startDate) || string.IsNullOrEmpty(endDate))
            {
                return(null);
            }

            try
            {
                var start = DateTime.Parse(DateMap.ReverseToServerDate(startDate.Trim()));
                var end   = DateTime.Parse(DateMap.ReverseToServerDate(endDate.Trim()));

                if (end < start || start > end)
                {
                    return(null);
                }

                var dictObjeList =
                    ServiceProvider.Instance()
                    .GetExpenseTransactionPaymentHistoryServices()
                    .GetVoidedTransactionPaymentVoucherObjectsByDateRange(start, end);
                var allpaymentsByDateCollections = new List <List <DictObject> >();
                if (dictObjeList == null || !dictObjeList.Any())
                {
                    return(null);
                }

                try
                {
                    var zerosLimit = ConfigurationManager.AppSettings["ZerosLimit"];

                    foreach (var dictObject in dictObjeList)
                    {
                        var user = new PortalServiceManager().GetPortalUserById(dictObject.RequestedById);
                        dictObject.ReceivedBy  = dictObject.ReceivedBy;
                        dictObject.RequestedBy = user.FirstName + " " + user.LastName;
                        var approver = new PortalServiceManager().GetPortalUserById(dictObject.ApproverId);
                        dictObject.Approver = approver.FirstName + " " + approver.LastName;

                        if (string.IsNullOrWhiteSpace(zerosLimit))
                        {
                            dictObject.PcvNo = dictObject.PcvId.ToString(CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            var zerosPrefix = int.Parse(zerosLimit);

                            dictObject.PcvNo =
                                new xPlug.BusinessObject.CustomizedASPBusinessObject.PCVHelper.PcvHelper().PcvGenerator(
                                    dictObject.PcvId, zerosPrefix);
                        }
                    }
                }
                catch (Exception)
                {
                    return(null);
                }

                foreach (var payment in dictObjeList)
                {
                    if (
                        !allpaymentsByDateCollections.Exists(
                            m1 =>
                            m1.All(m2 => m2.DepartmentId == payment.DepartmentId && m2.DatePaid == payment.DatePaid)))
                    {
                        var newVoucherList =
                            dictObjeList.FindAll(
                                m =>
                                m.DepartmentId == payment.DepartmentId && m.DatePaid == payment.DatePaid);

                        if (newVoucherList.Any())
                        {
                            allpaymentsByDateCollections.Add(newVoucherList);
                        }
                    }
                }

                var jsSerializer = new JavaScriptSerializer {
                    MaxJsonLength = Int32.MaxValue
                };
                return(jsSerializer.Serialize(allpaymentsByDateCollections));
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #15
0
        private bool GetTransactionPaymentsByDate()
        {
            ErrorDisplay1.ClearError();
            try
            {
                string date;
                var    transactionPaymentsByDate = new List <StaffExpenseTransactionPayment>();
                dgAllTransactionPayments.DataSource = new List <StaffExpenseTransactionPayment>();
                dgAllTransactionPayments.DataBind();
                lblFilterReport.InnerHtml = "Data list is empty.";

                if (btnRefresh.CommandArgument == "2")
                {
                    if (Session["_uncompletedPaymentsList"] == null)
                    {
                        ErrorDisplay1.ShowError("Uncompleted Transaction Payment list is empty or session has expired.");
                        return(false);
                    }

                    var uncompletedExpTransactionPayments = (List <StaffExpenseTransactionPayment>)Session["_uncompletedPaymentsList"];

                    if (!uncompletedExpTransactionPayments.Any())
                    {
                        ErrorDisplay1.ShowError("Uncompleted Transaction Payment list list is empty or session has expired.");
                        return(false);
                    }

                    transactionPaymentsByDate = new List <StaffExpenseTransactionPayment>();

                    if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                    {
                        var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                        var startDate       = DateTime.Parse(startDateString);
                        var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                        var endDate         = DateTime.Parse(endDateString);

                        transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByDateRange(uncompletedExpTransactionPayments, startDate, endDate);
                    }

                    else
                    {
                        if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()) && string.IsNullOrEmpty(txtStart.Text.Trim()))
                        {
                            date = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                            transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByLastPaymentDate(uncompletedExpTransactionPayments, date);
                        }

                        if (string.IsNullOrEmpty(txtEndDate.Text.Trim()) && !string.IsNullOrEmpty(txtStart.Text.Trim()))
                        {
                            date = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                            transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByLastPaymentDate(uncompletedExpTransactionPayments, date);
                        }
                    }

                    if (!transactionPaymentsByDate.Any())
                    {
                        ErrorDisplay1.ShowError("No record found.");
                        return(false);
                    }
                }

                if (btnRefresh.CommandArgument == "1")
                {
                    if (Session["_completedPaymentsList"] == null)
                    {
                        ErrorDisplay1.ShowError("Uncompleted Transaction Payment list list is empty or session has expired.");
                        return(false);
                    }

                    var completedPaymentsList = (List <StaffExpenseTransactionPayment>)Session["_completedPaymentsList"];

                    if (!completedPaymentsList.Any())
                    {
                        ErrorDisplay1.ShowError("Completed Transaction Payment list is empty or session has expired.");
                        return(false);
                    }

                    transactionPaymentsByDate = new List <StaffExpenseTransactionPayment>();

                    if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                    {
                        var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                        var startDate       = DateTime.Parse(startDateString);
                        var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                        var endDate         = DateTime.Parse(endDateString);
                        transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByDateRange(completedPaymentsList, startDate, endDate);
                    }

                    else
                    {
                        if (string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                        {
                            date = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                            transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByLastPaymentDate(completedPaymentsList, date);
                        }

                        if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                        {
                            date = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                            transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByLastPaymentDate(completedPaymentsList, date);
                        }
                    }
                }

                if (btnRefresh.CommandArgument == "0")
                {
                    var allExpensePaymentsList = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().GetStaffExpenseTransactionPayments();

                    if (!allExpensePaymentsList.Any())
                    {
                        ErrorDisplay1.ShowError("Transaction Payment list is empty or session has expired.");
                        return(false);
                    }


                    if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                    {
                        var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                        var startDate       = DateTime.Parse(startDateString);
                        var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                        var endDate         = DateTime.Parse(endDateString);

                        transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByDateRange(startDate, endDate);
                    }

                    else
                    {
                        if (string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                        {
                            date = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                            transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByLastPaymentDate(date);
                        }

                        if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                        {
                            date = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                            transactionPaymentsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionPaymentServices().FilterStaffExpenseTransactionPaymentsByLastPaymentDate(date);
                        }
                    }
                }

                if (!transactionPaymentsByDate.Any())
                {
                    ErrorDisplay1.ShowError("No record found.");
                    return(false);
                }

                dgAllTransactionPayments.DataSource = transactionPaymentsByDate;
                dgAllTransactionPayments.DataBind();
                SetApprovedTransactionStyle();
                SetApprovedTransactionStyle();
                Session["_expensePaymentsList"] = transactionPaymentsByDate;
                var itemCount = transactionPaymentsByDate.Count;
                lblFilterReport.InnerHtml = itemCount + " " + " item(s) found!";
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
        private bool GetTransactionsByDate()
        {
            ErrorDisplay1.ClearError();
            try
            {
                dgApprovedTransactions.DataSource = new List <StaffExpenseApproval>();
                dgApprovedTransactions.DataBind();

                var approvedTransactionsByDate = new List <StaffExpenseApproval>();

                if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                {
                    var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                    var startDate       = DateTime.Parse(startDateString);
                    var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                    var endDate         = DateTime.Parse(endDateString);
                    approvedTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseApprovalServices().GetStaffExpenseApprovalsDateRange(startDate, endDate);
                }

                else
                {
                    if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()) && string.IsNullOrEmpty(txtStart.Text.Trim()))
                    {
                        approvedTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseApprovalServices().GetStaffExpenseApprovalsDate(DateMap.ReverseToServerDate(txtEndDate.Text.Trim()));
                    }

                    if (string.IsNullOrEmpty(txtEndDate.Text.Trim()) && !string.IsNullOrEmpty(txtStart.Text.Trim()))
                    {
                        approvedTransactionsByDate =
                            ServiceProvider.Instance().GetStaffExpenseApprovalServices().GetStaffExpenseApprovalsDate(DateMap.ReverseToServerDate(txtStart.Text.Trim()));
                    }


                    if (!approvedTransactionsByDate.Any())
                    {
                        ErrorDisplay1.ShowError("No record found.");
                        return(false);
                    }
                }

                if (Session["_userList"] == null)
                {
                    ErrorDisplay1.ShowError("Transaction Approver list is empty or session has expired.");
                    return(false);
                }

                var userList = Session["_userList"] as List <portaluser>;

                if (userList == null || !userList.Any())
                {
                    ErrorDisplay1.ShowError("Transaction Approver list is empty or session has expired.");
                    return(false);
                }

                foreach (var expenseTransaction in approvedTransactionsByDate)
                {
                    expenseTransaction.ApprovedBy = userList.Find(m => m.UserId == expenseTransaction.ApprovedById).FirstName + " " + userList.Find(m => m.UserId == expenseTransaction.ApprovedById).LastName;
                }

                dgApprovedTransactions.DataSource = approvedTransactionsByDate;
                dgApprovedTransactions.DataBind();
                SetApprovedTransactionStyle();
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
コード例 #17
0
        private void GetCurrentTransactionPayments()
        {
            try
            {
                dgAllTransactionPayments.DataSource = new List <ExpenseTransactionPayment>();
                dgAllTransactionPayments.DataBind();

                var transactionPaymentsByDate = ServiceProvider.Instance().GetExpenseTransactionPaymentServices().GetCurrentTransactionPayments(DateMap.GetLocalDate());

                if (!transactionPaymentsByDate.Any())
                {
                    return;
                }

                Session["_expTransactionPaymentReportList"] = null;
                Session["_expTransactionPaymentReportList"] = transactionPaymentsByDate;

                Limit = int.Parse(ddlLimit.SelectedValue);
                FillRepeater <ExpenseTransactionPayment>(dgAllTransactionPayments, "_expTransactionPaymentReportList", Navigation.None, Limit, LoadMethod);
                LoadTransactionPaymentFooter();
                SetTransactionStyle();
            }
            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
            }
        }
コード例 #18
0
        private void LoadTransactions()
        {
            var dictObjeList = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().GetMyGenericVoucherObjectsByDateRange(DateTime.Parse(DateMap.GetLocalDate()), DateTime.Parse(DateMap.GetLocalDate()));

            if (dictObjeList == null || !dictObjeList.Any())
            {
                dgUserInitiatedTransactions.DataSource = new List <DictObject>();
                dgUserInitiatedTransactions.DataBind();
                return;
            }

            Session["_expPaymentVoucherList"] = null;
            Session["_expPaymentVoucherList"] = dictObjeList;

            Limit = int.Parse(ddlLimit.SelectedValue);
            FillRepeater <ExpenseTransaction>(dgUserInitiatedTransactions, "_expPaymentVoucherList", Navigation.None, Limit, LoadMethod);
            SetTransactionsStyle();
        }
コード例 #19
0
        private IEnumerable <ExpenseTransactionPayment> GetTransactionPaymentsByDate()
        {
            try
            {
                var status = int.Parse(ddlPaymentFilterOption.SelectedValue);

                if (status < 0)
                {
                    ConfirmAlertBox1.ShowMessage("Please select a Status!", ConfirmAlertBox.PopupMessageType.Error);
                    return(null);
                }

                var deptmnt = int.Parse(ddlPaymentDepartment.SelectedValue);

                if (deptmnt < 1)
                {
                    ConfirmAlertBox1.ShowMessage("Please select a Department!", ConfirmAlertBox.PopupMessageType.Error);
                    return(null);
                }

                var period = int.Parse(ddlPaymentPeriod.SelectedValue);

                if (period < 1)
                {
                    return(null);
                }

                List <ExpenseTransactionPayment> transactionList;


                if (period == 1)
                {
                    if (int.Parse(ddlPaymentYear.SelectedValue) < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("Please select a Year!", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }

                    var yrVal = ddlPaymentYear.SelectedItem.Text;

                    if (int.Parse(ddlMonth.SelectedValue) < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("Please select a Month!", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }
                    string monthVal;
                    var    month = int.Parse(ddlMonth.SelectedValue);

                    if (month < 10)
                    {
                        monthVal = "0" + month.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        monthVal = month.ToString(CultureInfo.InvariantCulture);
                    }

                    transactionList =
                        ServiceProvider.Instance()
                        .GetExpenseTransactionPaymentServices()
                        .GetMonthlyTransactionPayments(status, deptmnt, yrVal, monthVal);

                    if (transactionList == null || !transactionList.Any())
                    {
                        ConfirmAlertBox1.ShowMessage("No Record Found!", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }

                    return(transactionList);
                }

                if (period == 2)
                {
                    if (int.Parse(ddlPaymentYear.SelectedValue) < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("Please select a Year!", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }

                    var yrVal = ddlPaymentYear.SelectedItem.Text;

                    string monthVal;

                    if (int.Parse(ddlMonth.SelectedValue) < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("Please select a Month!", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }

                    if (int.Parse(ddlPaymentWeekly.SelectedValue) < 1)
                    {
                        ConfirmAlertBox1.ShowMessage("Please select a Week!", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }
                    var month = int.Parse(ddlMonth.SelectedValue);

                    if (month < 10)
                    {
                        monthVal = "0" + month.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        monthVal = month.ToString(CultureInfo.InvariantCulture);
                    }

                    int weeklyVal = int.Parse(ddlPaymentWeekly.SelectedValue);

                    transactionList =
                        ServiceProvider.Instance()
                        .GetExpenseTransactionPaymentServices()
                        .GetWeeklyTransactionPayments(status, deptmnt, yrVal, monthVal, weeklyVal);

                    if (transactionList == null || !transactionList.Any())
                    {
                        ConfirmAlertBox1.ShowMessage("No Record Found!", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }

                    return(transactionList);
                }

                if (period == 3)
                {
                    var startDateString = DateMap.ReverseToServerDate(txtPaymentStart.Text.Trim());
                    var startDate       = DateTime.Parse(startDateString);
                    var endDateString   = DateMap.ReverseToServerDate(txtPaymentEndDate.Text.Trim());
                    var endDate         = DateTime.Parse(endDateString);
                    if (endDate < startDate || startDate > endDate)
                    {
                        ConfirmAlertBox1.ShowMessage("The 'From' date must not be LATER than the 'To' date.", ConfirmAlertBox.PopupMessageType.Error);
                        return(null);
                    }

                    transactionList = ServiceProvider.Instance().GetExpenseTransactionPaymentServices().GetTransactionPaymentsByDateRange(startDateString, endDateString, deptmnt, status);

                    if (!transactionList.Any())
                    {
                        ConfirmAlertBox1.ShowMessage("No record found!", ConfirmAlertBox.PopupMessageType.Error);
                        return(new List <ExpenseTransactionPayment>());
                    }

                    return(transactionList);
                }

                return(new List <ExpenseTransactionPayment>());
            }
            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again or contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(new List <ExpenseTransactionPayment>());
            }
        }
コード例 #20
0
        public SettingRegRespObj AddCompany(RegCompanyObj regObj)
        {
            var response = new SettingRegRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage()
                }
            };

            try
            {
                if (regObj.Equals(null))
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to proceed with your request";
                    response.Status.Message.TechnicalMessage = "Registration Object is empty / invalid";
                    return(response);
                }

                if (!EntityValidatorHelper.Validate(regObj, out var valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }

                    else
                    {
                        errorDetail.AppendLine(
                            "Validation error occurred! Please check all supplied parameters and try again");
                    }
                    response.Status.Message.FriendlyMessage  = errorDetail.ToString();
                    response.Status.Message.TechnicalMessage = errorDetail.ToString();
                    response.Status.IsSuccessful             = false;
                    return(response);
                }

                if (!HelperMethods.IsUserValid(regObj.AdminUserId, regObj.SysPathCode,
                                               HelperMethods.getSeniorAccountant(), ref response.Status.Message))
                {
                    return(response);
                }

                if (IsCompanyDuplicate(regObj.Name, 1, ref response))
                {
                    return(response);
                }

                var company = new Company
                {
                    Name = regObj.Name,
                    BusinessDescription = regObj.BusinessDescription,
                    Address             = regObj.Address,
                    CompanyType         = (CompanyType)regObj.CompanyType,
                    Email             = regObj.Email,
                    RegisteredBy      = regObj.AdminUserId,
                    TimeStampRegister = DateMap.CurrentTimeStamp(),
                    Status            = (ItemStatus)regObj.Status
                };

                var added = _repository.Add(company);

                _uoWork.SaveChanges();

                if (added.CompanyId < 1)
                {
                    response.Status.Message.FriendlyMessage =
                        "Error Occurred! Unable to complete your request. Please try again later";
                    response.Status.Message.TechnicalMessage = "Unable to save to database";
                    return(response);
                }
                resetCache();
                response.Status.IsSuccessful = true;
                response.SettingId           = added.CompanyId;
            }
            catch (DbEntityValidationException ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            return(response);
        }
コード例 #21
0
        private bool AddBeneficiary()
        {
            try
            {
                var newBeneficiary = new Beneficiary
                {
                    FullName       = txtFullName.Text.Trim(),
                    CompanyName    = txtCompanyName.Text.Trim(),
                    GSMNO1         = txtPhone1.Text,
                    GSMNO2         = txtPhone2.Text,
                    Email          = txtEmail.Text,
                    Sex            = int.Parse(ddlSex.SelectedValue),
                    Status         = chkBeneficiary.Checked ? 1 : 0,
                    DateRegistered = DateMap.GetLocalDate(),
                    TimeRegistered = DateMap.GetLocalTime()
                };

                var k = ServiceProvider.Instance().GetBeneficiaryServices().AddBeneficiaryCheckDuplicate(newBeneficiary);
                if (k < 1)
                {
                    if (k == -3)
                    {
                        ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                        ConfirmAlertBox1.ShowMessage("The Beneficiary information already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }

                    if (k == -4)
                    {
                        ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                        ConfirmAlertBox1.ShowMessage("Another Beneficiary with similar email already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                    if (k == -5)
                    {
                        ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                        ConfirmAlertBox1.ShowMessage("Another Beneficiary with similar phone number already exists.", ConfirmAlertBox.PopupMessageType.Error);
                        mpeSelectDateRangePopup.Show();
                        return(false);
                    }
                    //if (k == -6)
                    //{
                    //    ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                    //    ConfirmAlertBox1.ShowMessage("Another Beneficiary with similar second phone number already exists.", ConfirmAlertBox.PopupMessageType.Error);
                    //    mpeSelectDateRangePopup.Show();
                    //    return false;
                    //}

                    ConfirmAlertBox1.Attributes.CssStyle.Add("z-index", "20000001");
                    ConfirmAlertBox1.ShowMessage("The Beneficiary Information could not be Added.", ConfirmAlertBox.PopupMessageType.Error);
                    mpeSelectDateRangePopup.Show();
                    return(false);
                }
                ClearControls();
                return(true);
            }


            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please contact the Administrator.", ConfirmAlertBox.PopupMessageType.Error);
                return(false);
            }
        }
コード例 #22
0
        private void LoadTransactions()
        {
            dgUserInitiatedTransactions.DataSource = new List <ExpenseTransaction>();
            dgUserInitiatedTransactions.DataBind();
            var expTransactionList = ServiceProvider.Instance().GetExpenseTransactionServices().GetApprovedTransactionsByDate(DateMap.GetLocalDate());

            if (expTransactionList == null || !expTransactionList.Any())
            {
                return;
            }

            dgUserInitiatedTransactions.DataSource = expTransactionList;
            dgUserInitiatedTransactions.DataBind();
            SetTransactionsStyle();
        }
コード例 #23
0
        public SettingRegRespObj AddBulkStaffMemo(RegBulkStaffMemoObj regObj)
        {
            var response = new SettingRegRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage()
                }
            };

            try
            {
                if (regObj?.StaffMemoItem == null || !regObj.StaffMemoItem.Any())
                {
                    response.Status.Message.FriendlyMessage  = "Empty Request Item! Please try again later";
                    response.Status.Message.TechnicalMessage = "Registration Object is empty / invalid";
                    return(response);
                }

                foreach (var reqitem in regObj.StaffMemoItem)
                {
                    if (!EntityValidatorHelper.Validate(reqitem, out var valItemResults))
                    {
                        var errorDetail = new StringBuilder();
                        if (!valItemResults.IsNullOrEmpty())
                        {
                            errorDetail.AppendLine("Following error occurred:");
                            valItemResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                        }
                        else
                        {
                            errorDetail.AppendLine(
                                "Validation error occurred! Please check all supplied parameters and try again");
                        }
                        response.Status.Message.FriendlyMessage  = errorDetail.ToString();
                        response.Status.Message.TechnicalMessage = errorDetail.ToString();
                        response.Status.IsSuccessful             = false;
                        return(response);
                    }
                }

                if (!HelperMethods.IsUserValid(regObj.AdminUserId, regObj.SysPathCode,
                                               HelperMethods.getStaffRoles(), ref response.Status.Message))
                {
                    return(response);
                }

                var staffMemoList = new List <StaffMemo>();
                var workflowList  = new List <WorkflowSetup>();
                var results       = staffMemoList.GroupBy(e => e.StaffMemoId, (key, g) => new
                {
                    StaffMemoId    = key,
                    StaffMemoItems = g.ToList()
                }).ToList();

                if (!results.Any())
                {
                    response.Status.Message.FriendlyMessage  = "Invalid Expense Item list";
                    response.Status.Message.TechnicalMessage = "Invalid Expense Item list";
                    response.Status.IsSuccessful             = false;
                    return(response);
                }

                foreach (var reqItem in results)
                {
                    if (reqItem.StaffMemoItems.Count > 1)
                    {
                        response.Status.Message.FriendlyMessage =
                            $"Duplicate Staff Memo Item {getStaffMemo(reqItem.StaffMemoItems[0].StaffId).MemoType.ToString()}";
                        response.Status.Message.TechnicalMessage =
                            $"Duplicate Staff Memo Item {getStaffMemo(reqItem.StaffMemoItems[0].StaffId).MemoType.ToString()}";
                        response.Status.IsSuccessful = false;
                        return(response);
                    }
                    staffMemoList.Add(new StaffMemo
                    {
                        StaffId           = reqItem.StaffMemoItems[0].StaffId,
                        Title             = reqItem.StaffMemoItems[0].Title,
                        MemoType          = reqItem.StaffMemoItems[0].MemoType,
                        MemoDetail        = reqItem.StaffMemoItems[0].MemoDetail,
                        IsReplied         = false,
                        RegisterBy        = regObj.AdminUserId,
                        ApprovedBy        = 0,
                        Status            = ApprovalStatus.Approved,
                        TimeStampRegister = DateMap.CurrentTimeStamp()
                    });
                    workFlowSourceId = staffMemoList[0].StaffMemoId;
                    workflowList.Add(new WorkflowSetup
                    {
                        Description           = reqItem.StaffMemoItems[0].Title,
                        InitiatorId           = regObj.AdminUserId,
                        InitiatorType         = WorkflowInitiatorType.HR,
                        Item                  = WorkflowItem.Staff_Memo,
                        WorkflowOrderId       = regObj.StaffMemoItem[0].WorkflowOrderId,
                        WorkflowSourceId      = workFlowSourceId,
                        LastTimeStampModified = DateMap.CurrentTimeStamp(),
                        StaffId               = reqItem.StaffMemoItems[0].StaffId,
                        TimeStampInitiated    = DateMap.CurrentTimeStamp(),
                        Status                = WorkflowStatus.Initiated
                    });
                }

                using (var db = _uoWork.BeginTransaction())
                {
                    try
                    {
                        var added = _staffMemoRepository.AddRange(staffMemoList);
                        _uoWork.SaveChanges();
                        if (added == null || !added.Any())
                        {
                            db.Rollback();
                            response.Status.Message.FriendlyMessage =
                                "Error Occurred! Unable to complete your request. Please try again later";
                            response.Status.Message.TechnicalMessage = "Unable to save to database";
                            return(response);
                        }


                        var retVal = _workflowSetupRepository.AddRange(workflowList);
                        _uoWork.SaveChanges();
                        if (retVal == null || !retVal.Any())
                        {
                            db.Rollback();
                            response.Status.Message.FriendlyMessage =
                                "Error Occurred! Unable to complete your request. Please try again later";
                            response.Status.Message.TechnicalMessage = "Unable to save to database";
                            return(response);
                        }
                        response.Status.IsSuccessful     = true;
                        workflowList[0].WorkflowSourceId = staffMemoList[0].StaffMemoId;
                        db.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                        response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                        response.Status.IsSuccessful             = false;
                        return(response);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                        response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                        response.Status.IsSuccessful             = false;
                        return(response);
                    }
                    return(response);
                }
            }
            catch (DbEntityValidationException ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
        }
コード例 #24
0
        public UserInformation RemoteLoginUser(string username, string password, string hostServer)
        {
            var userInformation = new UserInformation
            {
                UserInfo = new User()
            };

            #region Null Validation

            if (username.IsNullOrEmpty() || password.IsNullOrEmpty() || hostServer.IsNullOrEmpty())
            {
                _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Login Failed! Reason: All the inputs are required";
                userInformation.Status          = _status;
                return(userInformation);
            }
            #endregion

            var stationInfo = new StationInfo
            {
                //Address = "",
                APIAccessKey        = "",
                HostServerAddress   = hostServer,
                StationKey          = "",
                StationName         = "",
                TimeStampRegistered = DateMap.CurrentTimeStamp(),
                Status = true,
            };

            #region Super Admin User Profile

            var superUserProfileInfo = new UserProfile
            {
                DateLastModified   = DateTime.Now.ToString("yyyy/MM/dd"),
                Email              = "*****@*****.**",
                FirstName          = "SuperAdmin",
                MobileNumber       = "2348036975694",
                ModifiedBy         = 1,
                OtherNames         = "",
                ProfileNumber      = "0001",
                ResidentialAddress = "EpayPlus Limited",
                Sex              = 1,
                Status           = 1,
                Surname          = "Epay",
                TimeLastModified = DateTime.Now.ToString("hh:mm:ss tt")
            };

            var superUserInfo = new User
            {
                Email = "*****@*****.**",
                FailedPasswordAttemptCount = 0,
                IsApproved              = true,
                IsLockedOut             = false,
                Password                = "******",
                RegisteredDateTimeStamp = DateTime.Now.ToString("yyyy/MM/dd - hh:mm:ss tt"),
                RoleId   = 1,
                UserName = "******",
                LastLockedOutTimeStamp       = "",
                LastLoginTimeStamp           = "",
                LastPasswordChangedTimeStamp = ""
            };

            #endregion


            using (var db = _uoWork.BeginTransaction())
            {
                try
                {
                    #region Remotely Connect & Login

                    #region Access Parameter - Authorize Access

                    var networkInterface = InternetHelp.GetMainNetworkInterface();
                    var loginParameter   = new RemoteLoginParameter
                    {
                        DeviceIP = InternetHelp.GetIpAddress(networkInterface),
                        DeviceId = InternetHelp.GetMACAddress(),
                        UserName = username,
                        Password = password
                    };
                    #endregion

                    string msg;
                    var    remoteLoginRespObj = new RemoteMessanger(RemoteProcessType.RemoteLogin, hostServer).RemoteLogin(loginParameter, out msg);
                    if (remoteLoginRespObj == null)
                    {
                        _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Process Failed! " + (string.IsNullOrEmpty(msg) ? "Unable to register Station Information" : msg);
                        userInformation.Status          = _status;
                        return(userInformation);
                    }
                    if (!remoteLoginRespObj.ResponseStatus.IsSuccessful || string.IsNullOrEmpty(remoteLoginRespObj.APIAccessKey) || remoteLoginRespObj.APIAccessKey.Length != 10)
                    {
                        _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = string.IsNullOrEmpty(remoteLoginRespObj.ResponseStatus.Message.FriendlyMessage) ? "Unable to complete your request! Please try again later" : remoteLoginRespObj.ResponseStatus.Message.FriendlyMessage;
                        userInformation.Status          = _status;
                        return(userInformation);
                    }

                    #endregion

                    #region Station Info

                    stationInfo.RemoteStationId = remoteLoginRespObj.ClientStationId;
                    stationInfo.APIAccessKey    = remoteLoginRespObj.APIAccessKey;
                    stationInfo.StationName     = remoteLoginRespObj.StationName;
                    stationInfo.StationKey      = remoteLoginRespObj.StationId;
                    stationInfo.Status          = Convert.ToBoolean(remoteLoginRespObj.StationStatus);
                    var addStationInfo = _stationInfoRepository.Add(stationInfo);
                    _uoWork.SaveChanges();

                    stationInfo.StationInfoId = addStationInfo.StationInfoId;
                    if (stationInfo.StationInfoId < 1)
                    {
                        db.Rollback();
                        _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Process Failed! Unable to register Station Information";
                        userInformation.Status          = _status;
                        return(userInformation);
                    }

                    #endregion

                    #region Company

                    var companyInfo = new CompanyInfo
                    {
                        StationName       = remoteLoginRespObj.StationName,
                        StationKey        = remoteLoginRespObj.StationId,
                        HostServerAddress = hostServer,
                        //Address = "",
                        Status = Convert.ToBoolean(remoteLoginRespObj.StationStatus),
                    };

                    var addCompanyInfo = _companyRepository.Add(companyInfo);
                    _uoWork.SaveChanges();
                    if (addCompanyInfo.CompanyInfoId < 1)
                    {
                        db.Rollback();
                        _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Unable to save Station's profile to the database";
                        userInformation.Status          = _status;
                        return(userInformation);
                    }
                    #endregion

                    #region User Profile

                    var staffRegistration = new UserProfile
                    {
                        StationInfoId      = stationInfo.StationInfoId,
                        Surname            = remoteLoginRespObj.Surname,
                        FirstName          = remoteLoginRespObj.FirstName,
                        OtherNames         = remoteLoginRespObj.Othernames,
                        ResidentialAddress = remoteLoginRespObj.ResidentialAddress,
                        MobileNumber       = remoteLoginRespObj.MobileNumber,
                        Email               = remoteLoginRespObj.Email,
                        ProfileNumber       = remoteLoginRespObj.EnrollerRegId,
                        UserProfileRemoteId = remoteLoginRespObj.EnrollerId,
                        Sex              = remoteLoginRespObj.Sex,
                        Status           = remoteLoginRespObj.EnrollerStatus,
                        TimeLastModified = DateTime.Now.ToString("hh:mm:ss tt"),
                        DateLastModified = DateTime.Now.ToString("yyyy/MM/dd"),
                        ModifiedBy       = 1
                    };

                    var userProfile = _userProfileRepository.Add(staffRegistration);
                    _uoWork.SaveChanges();
                    if (userProfile.UserProfileId < 1)
                    {
                        db.Rollback();
                        _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Error Occurred! Unable to add new user record";
                        userInformation.Status          = _status;
                        return(userInformation);
                    }

                    #endregion

                    #region User

                    var user = new User
                    {
                        UserName    = username,
                        Password    = password,
                        Email       = remoteLoginRespObj.Email,
                        RoleId      = 2,
                        IsApproved  = true,
                        IsLockedOut = false,
                        FailedPasswordAttemptCount   = 0,
                        LastLockedOutTimeStamp       = "",
                        LastLoginTimeStamp           = "",
                        LastPasswordChangedTimeStamp = "",
                        RegisteredDateTimeStamp      = DateTime.Now.ToString("yyyy/MM/dd - hh:mm:ss tt")
                    };

                    var thisUser = new UserRepository().GetUser(user.UserName);
                    if (thisUser != null)
                    {
                        if (thisUser.UserProfileId > 0)
                        {
                            db.Rollback();
                            _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Duplicate Error! This username already exist in local database";
                            userInformation.Status          = _status;
                            return(userInformation);
                        }
                    }

                    user.UserCode         = Crypto.HashPassword(user.Password);
                    user.Salt             = EncryptionHelper.GenerateSalt(30, 50);
                    user.Password         = Crypto.GenerateSalt(16);
                    user.IsFirstTimeLogin = true;
                    user.UserProfileId    = userProfile.UserProfileId;

                    var addUser = _repository.Add(user);
                    _uoWork.SaveChanges();
                    if (addUser.UserId < 1)
                    {
                        db.Rollback();
                        _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Error Occurred! Unable to add new user account";
                        userInformation.Status          = _status;
                        return(userInformation);
                    }

                    #endregion


                    #region Default Admin Profiles

                    var check = new UserRepository().GetUser("useradmin");
                    if (check == null || check.UserProfileId < 1)
                    {
                        superUserInfo.UserCode         = Crypto.HashPassword(superUserInfo.Password);
                        superUserInfo.Salt             = EncryptionHelper.GenerateSalt(30, 50);
                        superUserInfo.Password         = Crypto.GenerateSalt(16);
                        superUserInfo.IsFirstTimeLogin = false;
                        var processSuperProfile = _userProfileRepository.Add(superUserProfileInfo);
                        _uoWork.SaveChanges();
                        if (processSuperProfile.UserProfileId < 1)
                        {
                            db.Rollback();
                            _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Error Occurred! Unable to add new user account";
                            userInformation.Status          = _status;
                            return(userInformation);
                        }

                        superUserInfo.UserProfileId = processSuperProfile.UserProfileId;
                        var processSuperUser = _repository.Add(superUserInfo);
                        _uoWork.SaveChanges();
                        if (processSuperUser.UserId < 1)
                        {
                            db.Rollback();
                            _status.Message.FriendlyMessage = _status.Message.TechnicalMessage = "Error Occurred! Unable to add new user account";
                            userInformation.Status          = _status;
                            return(userInformation);
                        }
                    }

                    #endregion

                    db.Commit();
                    user.UserProfile            = userProfile;
                    _status.IsSuccessful        = true;
                    userInformation.Status      = _status;
                    userInformation.UserInfo    = user;
                    userInformation.StationInfo = stationInfo;
                    return(userInformation);
                }
                catch (DbEntityValidationException ex)
                {
                    ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                    _status.Message.FriendlyMessage  = "Login Failed! Reason: " + ex.Message;
                    _status.Message.TechnicalMessage = "Error: " + ex.Message;
                    userInformation.Status           = _status;
                    return(userInformation);
                }
                catch (Exception ex)
                {
                    db.Rollback();
                    ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                    _status.Message.FriendlyMessage  = "Login Failed! Reason: " + ex.Message;
                    _status.Message.TechnicalMessage = "Error: " + ex.Message;
                    userInformation.Status           = _status;
                    return(userInformation);
                }
            }
        }
コード例 #25
0
        public SettingRegRespObj ApproveStaffMemo(ApprovaStaffMemoObj regObj)
        {
            var response = new SettingRegRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage()
                }
            };

            try
            {
                if (regObj.Equals(null))
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to proceed with your request";
                    response.Status.Message.TechnicalMessage = "Registration Object is empty / invalid";
                    return(response);
                }

                if (!EntityValidatorHelper.Validate(regObj, out var valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }

                    else
                    {
                        errorDetail.AppendLine(
                            "Validation error occurred! Please check all supplied parameters and try again");
                    }
                    response.Status.Message.FriendlyMessage  = errorDetail.ToString();
                    response.Status.Message.TechnicalMessage = errorDetail.ToString();
                    response.Status.IsSuccessful             = false;
                    return(response);
                }


                if (!HelperMethods.IsUserValid(regObj.AdminUserId, regObj.SysPathCode,
                                               HelperMethods.getAdminRoles(), ref response.Status.Message))
                {
                    return(response);
                }


                //var searchObj = new StaffMemoSearchObj
                //{
                //    AdminUserId = 0,
                //    StaffMemoId = 0,
                //    StaffId = regObj.AdminUserId,
                //    Status = 0,
                //    SysPathCode = ""
                //};

                //retrieve previous contacts and validate with the new one
                var staffMemos = getStaffMemos(regObj.StaffId);

                if (staffMemos == null || !staffMemos.Any())
                {
                    response.Status.Message.FriendlyMessage  = "No Staff Memo Information found";
                    response.Status.Message.TechnicalMessage = "No Staff Memo Information found";
                    return(response);
                }
                var thisMemoFind         = staffMemos.Find(m => m.StaffMemoId == regObj.StaffMemoId);
                var staffWorkflowlog     = GetWorkflowLog(thisMemoFind.StaffId);
                var thisStaffWorkFlowLog = staffWorkflowlog.Find(m => m.StaffId == thisMemoFind.StaffId);
                if (thisMemoFind.StaffMemoId < 1)
                {
                    response.Status.Message.FriendlyMessage  = "This Staff Memo Information not found";
                    response.Status.Message.TechnicalMessage = "This Staff Memo Request Information not found";
                    return(response);
                }
                if (thisStaffWorkFlowLog.StaffId < 1)
                {
                    response.Status.Message.FriendlyMessage  = "This Staff Work flow Log  Information not found";
                    response.Status.Message.TechnicalMessage = "This Staff Work flow Log Information not found";
                    return(response);
                }


                thisMemoFind.MemoType   = (MemoType)regObj.MemoType;
                thisMemoFind.ApprovedBy = regObj.ApprovedBy;
                thisMemoFind.Status     = (ApprovalStatus)regObj.Status;

                thisStaffWorkFlowLog.WorkflowOrderItemId = regObj.WorkflowOrderItemId;
                thisStaffWorkFlowLog.ApprovalType        = WorkflowApprovalType.HR_Head;
                thisStaffWorkFlowLog.ProcessorId         = regObj.AdminUserId;
                thisStaffWorkFlowLog.Comment             = regObj.MemoDetail;
                thisStaffWorkFlowLog.LogTimeStamp        = DateMap.CurrentTimeStamp();
                thisStaffWorkFlowLog.Status = (ApprovalStatus)regObj.Status;

                using (var db = _uoWork.BeginTransaction())
                {
                    try
                    {
                        var added = _staffMemoRepository.Update(thisMemoFind);
                        _uoWork.SaveChanges();
                        if (added.StaffMemoId < 1)
                        {
                            db.Rollback();
                            response.Status.Message.FriendlyMessage =
                                "Error Occurred! Unable to complete your request. Please try again later";
                            response.Status.Message.TechnicalMessage = "Unable to save to database";
                            return(response);
                        }


                        var retVal = _workflowLogRepository.Update(thisStaffWorkFlowLog);
                        _uoWork.SaveChanges();
                        if (retVal.WorkflowLogId < 1)
                        {
                            db.Rollback();
                            response.Status.Message.FriendlyMessage =
                                "Error Occurred! Unable to complete your request. Please try again later";
                            response.Status.Message.TechnicalMessage = "Unable to save to database";
                            return(response);
                        }
                        response.Status.IsSuccessful       = true;
                        response.SettingId                 = added.StaffMemoId;
                        thisStaffWorkFlowLog.WorkflowLogId = thisStaffWorkFlowLog.WorkflowLogId;
                        db.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        db.Rollback();
                        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                        response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                        response.Status.IsSuccessful             = false;
                        return(response);
                    }
                    catch (Exception ex)
                    {
                        db.Rollback();
                        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                        response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                        response.Status.IsSuccessful             = false;
                        return(response);
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            return(response);
        }
コード例 #26
0
        public SettingRegRespObj AddStaffMemo(RegStaffMemoObj regObj)
        {
            var response = new SettingRegRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage()
                }
            };

            try
            {
                if (regObj.Equals(null))
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to proceed with your request";
                    response.Status.Message.TechnicalMessage = "Registration Object is empty / invalid";
                    return(response);
                }

                if (!EntityValidatorHelper.Validate(regObj, out var valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }

                    else
                    {
                        errorDetail.AppendLine(
                            "Validation error occurred! Please check all supplied parameters and try again");
                    }
                    response.Status.Message.FriendlyMessage  = errorDetail.ToString();
                    response.Status.Message.TechnicalMessage = errorDetail.ToString();
                    response.Status.IsSuccessful             = false;
                    return(response);
                }

                if (!HelperMethods.IsUserValid(regObj.AdminUserId, regObj.SysPathCode,
                                               HelperMethods.getStaffRoles(), ref response.Status.Message))
                {
                    return(response);
                }

                var staffMemo = new StaffMemo
                {
                    StaffId           = regObj.StaffId,
                    Title             = regObj.Title,
                    MemoType          = (MemoType)regObj.MemoType,
                    MemoDetail        = regObj.MemoDetail,
                    IsReplied         = false,
                    RegisterBy        = regObj.AdminUserId,
                    ApprovedBy        = 0,
                    Status            = ApprovalStatus.Registered,
                    TimeStampRegister = DateMap.CurrentTimeStamp()
                };



                using (var db = _uoWork.BeginTransaction())
                {
                    try
                    {
                        var added = _staffMemoRepository.Add(staffMemo);
                        _uoWork.SaveChanges();
                        if (added.StaffMemoId < 1)
                        {
                            db.Rollback();
                            response.Status.Message.FriendlyMessage =
                                "Error Occurred! Unable to complete your request. Please try again later";
                            response.Status.Message.TechnicalMessage = "Unable to save to database";
                            return(response);
                        }
                        workFlowSourceId = added.StaffMemoId;
                        var workflow = new WorkflowSetup
                        {
                            Description           = regObj.Title,
                            InitiatorId           = regObj.AdminUserId,
                            InitiatorType         = WorkflowInitiatorType.HR,
                            Item                  = WorkflowItem.Staff_Memo,
                            WorkflowOrderId       = regObj.WorkflowOrderId,
                            WorkflowSourceId      = workFlowSourceId,
                            LastTimeStampModified = DateMap.CurrentTimeStamp(),
                            StaffId               = regObj.StaffId,
                            TimeStampInitiated    = DateMap.CurrentTimeStamp(),
                            Status                = WorkflowStatus.Initiated
                        };

                        var retVal = _workflowSetupRepository.Add(workflow);
                        _uoWork.SaveChanges();
                        if (retVal.WorkflowSetupId < 1)
                        {
                            db.Rollback();
                            response.Status.Message.FriendlyMessage =
                                "Error Occurred! Unable to complete your request. Please try again later";
                            response.Status.Message.TechnicalMessage = "Unable to save to database";
                            return(response);
                        }
                        response.Status.IsSuccessful = true;
                        response.SettingId           = added.StaffMemoId;
                        workflow.WorkflowSourceId    = added.StaffMemoId;
                        db.Commit();
                    }
                    catch (DbEntityValidationException ex)
                    {
                        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                        response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                        response.Status.IsSuccessful             = false;
                        return(response);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                        response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                        response.Status.IsSuccessful             = false;
                        return(response);
                    }
                    return(response);
                }
            }
            catch (DbEntityValidationException ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
        }
        private bool GetTransactionsByDate()
        {
            ErrorDisplay1.ClearError();
            try
            {
                var expTransactionsByDate = new List <StaffExpenseTransaction>();

                dgExpenseTransaction.DataSource = new List <StaffExpenseTransaction>();
                dgExpenseTransaction.DataBind();

                if (int.Parse(ddlDepartment.SelectedValue) < 1 && int.Parse(ddlPortalUser.SelectedValue) < 1)
                {
                    if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                    {
                        var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                        var startDate       = DateTime.Parse(startDateString);
                        var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                        var endDate         = DateTime.Parse(endDateString);
                        if (endDate < startDate || startDate > endDate)
                        {
                            ErrorDisplay1.ShowError("The 'From' date must not be LATER than the 'To' date.");
                            dgExpenseTransaction.DataSource = new List <StaffExpenseTransaction>();
                            dgExpenseTransaction.DataBind();
                            return(false);
                        }

                        expTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionServices().GetExpenseTransactionsByDateRange(startDate, endDate);
                    }

                    else
                    {
                        if (!string.IsNullOrEmpty(txtEndDate.Text.Trim()) && string.IsNullOrEmpty(txtStart.Text.Trim()))
                        {
                            expTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionServices().GetExpenseTransactionsByDate(DateMap.ReverseToServerDate(txtEndDate.Text.Trim()));
                        }

                        if (string.IsNullOrEmpty(txtEndDate.Text.Trim()) && !string.IsNullOrEmpty(txtStart.Text.Trim()))
                        {
                            expTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionServices().GetExpenseTransactionsByDate(DateMap.ReverseToServerDate(txtStart.Text.Trim()));
                        }
                    }
                }

                var portalUserId = int.Parse(ddlPortalUser.SelectedValue);
                var departmentId = int.Parse(ddlDepartment.SelectedValue);

                if (departmentId > 0 || portalUserId > 0)
                {
                    if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                    {
                        var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                        var startDate       = DateTime.Parse(startDateString);
                        var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                        var endDate         = DateTime.Parse(endDateString);

                        if (endDate < startDate || startDate > endDate)
                        {
                            ErrorDisplay1.ShowError("The 'From' date must not be soon than the 'To' date.");
                            dgExpenseTransaction.DataSource = new List <StaffExpenseTransaction>();
                            dgExpenseTransaction.DataBind();
                            return(false);
                        }

                        expTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionServices().GetExpenseTransactionsByDateRange(startDate, endDate);
                    }

                    else
                    {
                        if (string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                        {
                            expTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionServices().GetExpenseTransactionsByDate(DateMap.ReverseToServerDate(txtEndDate.Text.Trim()));
                        }

                        if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                        {
                            var date = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                            expTransactionsByDate = ServiceProvider.Instance().GetStaffExpenseTransactionServices().GetExpenseTransactionsByDate(date);
                        }
                    }
                }

                var accountsHead = ServiceProvider.Instance().GetAccountsHeadServices().GetAccountsHeads();

                if (accountsHead == null || !accountsHead.Any())
                {
                    ErrorDisplay1.ShowError("Expense Transaction list is empty.");
                    dgExpenseTransaction.DataSource = new List <ExpenseTransaction>();
                    dgExpenseTransaction.DataBind();
                    return(false);
                }
                Parallel.ForEach(expTransactionsByDate, item =>
                {
                    item.AccountsHead = accountsHead.Find(m => m.AccountsHeadId == item.ExpenseItem.AccountsHeadId).Title;
                });

                if (!expTransactionsByDate.Any())
                {
                    ErrorDisplay1.ShowError("No record found.");
                    return(false);
                }

                dgExpenseTransaction.DataSource = expTransactionsByDate;
                dgExpenseTransaction.DataBind();
                SetApprovedTransactionStyle();
                Session["_expTransactions"] = expTransactionsByDate;
                return(true);
            }
            catch (Exception ex)
            {
                ErrorDisplay1.ShowError("An unknown error was encountered. Please try again soon or contact the Admin.");
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
コード例 #28
0
        private void SaveData()
        {
            try
            {
                var memUser = Membership.GetUser(txtUserName.Text.Trim());

                if (memUser != null)
                {
                    if (memUser.UserName.Length > 1)
                    {
                        ErrorDisplay2.ShowError("User Already Exist!");
                        mpeDisplayJobDetails.Show();
                        return;
                    }
                }

                var memUser2 = Membership.CreateUser(txtUserName.Text.Trim(), txtPassword.Text.Trim(), txtEmail.Text.Trim());

                if (memUser2.UserName == "")
                {
                    ErrorDisplay2.ShowError("Process Failed! User Information was not registered");
                    mpeDisplayJobDetails.Show();
                    return;
                }

                memUser2.IsApproved = chkActive.Checked;
                Membership.UpdateUser(memUser2);
                var userId = new PortalServiceManager().GetUserIdByUsername(txtUserName.Text.Trim());
                if (userId < 1)
                {
                    Membership.DeleteUser(txtUserName.Text.Trim());
                    ErrorDisplay2.ShowError("Process Failed! Please try again soon");
                    mpeDisplayJobDetails.Show();
                    return;
                }

                var mUser = new portaluser
                {
                    DateRegistered = DateMap.GetLocalDate(),
                    Designation    = txtDesignation.Text.Trim(),
                    FirstName      = txtFirstName.Text.Trim(),
                    LastName       = txtLastName.Text.Trim(),
                    MobileNumber   = txtMobileNumber.Text.Trim(),
                    SexId          = int.Parse(ddlSex.SelectedValue),
                    TimeRegistered = DateTime.Now.ToString("hh:mm:ss"),
                    UserName       = txtUserName.Text.Trim(),
                    UserId         = userId,
                    Status         = chkActive.Checked
                };

                var k = (new PortalServiceManager()).AddPortalUser(mUser);

                if (k < 1)
                {
                    Membership.DeleteUser(txtUserName.Text.Trim());
                    ErrorDisplay2.ShowError("User Information Was Not Saved!");
                    mpeDisplayJobDetails.Show();
                    return;
                }

                //Add Roles
                string[] mRoles = Roles.GetRolesForUser(txtUserName.Text.Trim());

                if (mRoles != null)
                {
                    if (mRoles.Length > 0)
                    {
                        Roles.RemoveUserFromRoles(txtUserName.Text.Trim(), mRoles);
                    }
                }

                try
                {
                    foreach (ListItem item in chkRoles.Items)
                    {
                        if (item.Selected)
                        {
                            Roles.AddUserToRole(txtUserName.Text.Trim(), item.Value.Trim());
                        }
                    }
                }
                catch (Exception)
                {
                    Membership.DeleteUser(txtUserName.Text.Trim());
                    (new PortalServiceManager()).DeletePortalUser(k);
                    ErrorDisplay2.ShowError("Process Failed! Please try again soon");
                    return;
                }

                BindUsersList();

                ErrorDisplay2.ClearControls(tbUserInfo);
                ErrorDisplay1.ClearError();
                ErrorDisplay1.ShowSuccess("User Information Was Saved");
                mpeDisplayJobDetails.Hide();
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                ErrorDisplay2.ShowError(ex.Message);
                mpeDisplayJobDetails.Show();
            }
        }
コード例 #29
0
        private bool GetTransactionsByDate()
        {
            try
            {
                dgUserInitiatedTransactions.DataSource = new List <DictObject>();
                dgUserInitiatedTransactions.DataBind();

                var expTransactionsByDate = new List <DictObject>();
                var status          = int.Parse(ddlFilterOption.SelectedValue);
                var startDateString = DateMap.ReverseToServerDate(txtStart.Text.Trim());
                var startDate       = DateTime.Parse(startDateString);
                var endDateString   = DateMap.ReverseToServerDate(txtEndDate.Text.Trim());
                var endDate         = DateTime.Parse(endDateString);
                if (endDate < startDate || startDate > endDate)
                {
                    ConfirmAlertBox1.ShowMessage("The 'From' date must not be LATER than the 'To' date.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }


                if (status > 0)
                {
                    if (status == 0)
                    {
                        expTransactionsByDate = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().GetMyGenericVoucherObjectsByDateRange(startDate, endDate);
                    }

                    if (status == 1)
                    {
                        expTransactionsByDate = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().GetMyGenericVoucherObjectsByDateRange(startDate, endDate);
                    }

                    if (status == 2)
                    {
                        expTransactionsByDate = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().GetMyGenericVoucherObjectsByDateRange(startDate, endDate);
                    }

                    if (status == 3)
                    {
                        expTransactionsByDate = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().GetMyGenericVoucherObjectsByDateRange(startDate, endDate);
                    }

                    if (status == 4)
                    {
                        expTransactionsByDate = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().GetMyGenericVoucherObjectsByDateRange(startDate, endDate);
                    }
                }

                if (status < 1)
                {
                    if (!string.IsNullOrEmpty(txtStart.Text.Trim()) && !string.IsNullOrEmpty(txtEndDate.Text.Trim()))
                    {
                        expTransactionsByDate = ServiceProvider.Instance().GetExpenseTransactionPaymentHistoryServices().GetMyGenericVoucherObjectsByDateRange(startDate, endDate);
                    }
                }

                if (!expTransactionsByDate.Any())
                {
                    ConfirmAlertBox1.ShowMessage("No record found.", ConfirmAlertBox.PopupMessageType.Error);
                    return(false);
                }
                Session["_expPaymentVoucherList"] = null;
                Session["_expPaymentVoucherList"] = expTransactionsByDate;

                Limit = int.Parse(ddlLimit.SelectedValue);
                FillRepeater <ExpenseTransaction>(dgUserInitiatedTransactions, "_expPaymentVoucherList", Navigation.None, Limit, LoadMethod);
                SetTransactionsStyle();
                return(true);
            }
            catch (Exception ex)
            {
                ConfirmAlertBox1.ShowMessage("An unknown error was encountered. Please try again soon or contact the Admin.", ConfirmAlertBox.PopupMessageType.Error);
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                return(false);
            }
        }
コード例 #30
0
        public CardDeliveryRegRespObj AddCardDelivery(RegCardDeliveryObj regObj)
        {
            var response = new CardDeliveryRegRespObj
            {
                Status = new APIResponseStatus
                {
                    IsSuccessful = false,
                    Message      = new APIResponseMessage()
                }
            };

            try
            {
                if (regObj.Equals(null))
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to proceed with your request";
                    response.Status.Message.TechnicalMessage = "Registration Object is empty / invalid";
                    return(response);
                }

                if (!EntityValidatorHelper.Validate(regObj, out var valResults))
                {
                    var errorDetail = new StringBuilder();
                    if (!valResults.IsNullOrEmpty())
                    {
                        errorDetail.AppendLine("Following error occurred:");
                        valResults.ForEachx(m => errorDetail.AppendLine(m.ErrorMessage));
                    }
                    else
                    {
                        errorDetail.AppendLine("Validation error occurred! Please check all supplied parameters and try again");
                    }
                    response.Status.Message.FriendlyMessage  = errorDetail.ToString();
                    response.Status.Message.TechnicalMessage = errorDetail.ToString();
                    response.Status.IsSuccessful             = false;
                    return(response);
                }

                if (!HelperMethods.IsUserValid(regObj.AdminUserId, regObj.SysPathCode, HelperMethods.getRequesterRoles(), ref response.Status.Message))
                {
                    return(response);
                }

                var associatedCard = GetCardInfo(regObj.CardId);
                if (associatedCard == null)
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! No Card  Information Found";
                    response.Status.Message.TechnicalMessage = "Error Occurred! No Card  Information Found";
                    return(response);
                }

                var associatedCardItem = GetCardItemInfo(regObj.CardItemId);
                if (associatedCardItem == null)
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! No Card Item  Information Found";
                    response.Status.Message.TechnicalMessage = "Error Occurred! No Card Item Information Found";
                    return(response);
                }

                if (associatedCard.Status != CardStatus.Registered)
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! This Card Item Is Not Available For Delivery";
                    response.Status.Message.TechnicalMessage = "Error Occurred! This Card Item Is Not Available For Delivery";
                    return(response);
                }

                //check validity of start/stop batch number

                if ((int.Parse(regObj.StopBatchNumber) - int.Parse(regObj.StartBatchNumber) + 1) !=
                    associatedCard.QuantityPerBatch)
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! Incorrect StopBatchNumber/StartBatchNumber Data";
                    response.Status.Message.TechnicalMessage = "Error Occurred! Incorrect StopBatchNumber/StartBatchNumber Data";
                    return(response);
                }

                if (regObj.BatchId != associatedCardItem.BatchId)
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! Incorrect BatchId";
                    response.Status.Message.TechnicalMessage = "Error Occurred! Incorrect BatchId";
                    return(response);
                }
                if (regObj.DeliveredQuantity < 1)
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! You Cannot Register An empty delivery ";
                    response.Status.Message.TechnicalMessage = "Error Occurred! Incorrect quantity Delivered Data";
                    return(response);
                }

                if (regObj.DeliveredQuantity + associatedCardItem.DeliveredQuantity > associatedCardItem.BatchQuantity)
                {
                    if (associatedCardItem.BatchQuantity - (associatedCardItem.DeliveredQuantity) > 0)
                    {
                        response.Status.Message.FriendlyMessage = $"Incorrect Quantity Delivered,{associatedCardItem.BatchQuantity - (associatedCardItem.DeliveredQuantity)} is only available for delivery";
                    }
                    else if (associatedCardItem.BatchQuantity - (associatedCardItem.DeliveredQuantity) == 0)
                    {
                        response.Status.Message.FriendlyMessage = $"This Delivery is Complete";
                    }

                    response.Status.Message.TechnicalMessage = "Error Occurred! Incorrect Quantity Delivered";
                    return(response);
                }

                if (DateTime.Parse(regObj.TimeStampDelivered) > DateTime.Now)
                {
                    response.Status.Message.FriendlyMessage  = "Error Occurred! You Cannot Register A delivery before DeliveryDate";
                    response.Status.Message.TechnicalMessage = "Error Occurred! Incorrect Delivery Date Data";
                    return(response);
                }

                using (var db = _uoWork.BeginTransaction())
                {
                    var newCardDelivery = new CardDelivery
                    {
                        CardId             = regObj.CardId,
                        CardItemId         = regObj.CardItemId,
                        CardTypeId         = regObj.CardTypeId,
                        BatchId            = associatedCardItem.BatchId,
                        Status             = CardStatus.Registered,
                        ApprovedBy         = 0,
                        ApproverComment    = regObj.ApproverComment,
                        TimeStampApproved  = "",
                        DefectiveQuantity  = regObj.DefectiveQuantity,
                        TimeStampDelivered = regObj.TimeStampDelivered,
                        MissingQuantity    = regObj.MissingQuantity,
                        DeliveredQuantity  = regObj.DeliveredQuantity,
                        StartBatchNumber   = associatedCardItem.BatchId + "" + "000",
                        StopBatchNumber    = associatedCardItem.BatchId + "" + "999",
                        ReceivedBy         = regObj.AdminUserId,
                        TimeStampRegisered = DateMap.CurrentTimeStamp(),
                    };

                    var deliveryAdded = _repository.Add(newCardDelivery);
                    _uoWork.SaveChanges();
                    if (deliveryAdded.CardDeliveryId < 1)
                    {
                        db.Rollback();
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to complete your request. Please try again later";
                        response.Status.Message.TechnicalMessage = "Unable to save to database";
                        return(response);
                    }
                    associatedCardItem.MissingQuantity     += regObj.MissingQuantity;
                    associatedCardItem.DefectiveQuantity   += regObj.DefectiveQuantity;
                    associatedCardItem.DeliveredQuantity   += regObj.DeliveredQuantity;
                    associatedCardItem.AvailableQuantity   += regObj.DeliveredQuantity - (regObj.MissingQuantity + regObj.DefectiveQuantity);
                    associatedCardItem.TimeStampDelivered   = deliveryAdded.TimeStampRegisered;
                    associatedCardItem.DefectiveBatchNumber = regObj.DefectiveBatchNumber;
                    associatedCardItem.Status = CardStatus.Registered;

                    var updateCardItem = _cardItemRepository.Update(associatedCardItem);
                    _uoWork.SaveChanges();
                    if (updateCardItem.CardItemId < 1)
                    {
                        db.Rollback();
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to complete your request. Please try again later";
                        response.Status.Message.TechnicalMessage = "Unable to save to database";
                        return(response);
                    }


                    associatedCard.Status = CardStatus.Registered;
                    var updateCard = _cardRepository.Update(associatedCard);
                    _uoWork.SaveChanges();
                    if (updateCard.CardId < 1)
                    {
                        db.Rollback();
                        response.Status.Message.FriendlyMessage  = "Error Occurred! Unable to complete your request. Please try again later";
                        response.Status.Message.TechnicalMessage = "Unable to save to database";
                        return(response);
                    }
                    db.Commit();

                    response.Status.IsSuccessful            = true;
                    response.CardDeliveryId                 = deliveryAdded.CardDeliveryId;
                    response.Status.Message.FriendlyMessage = "Card Delivery Added Successfully";
                }
            }
            catch (DbEntityValidationException ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
                response.Status.Message.FriendlyMessage  = "Error Occurred! Please try again later";
                response.Status.Message.TechnicalMessage = "Error: " + ex.GetBaseException().Message;
                response.Status.IsSuccessful             = false;
                return(response);
            }

            return(response);
        }