Пример #1
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == @"Reject" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    try
                    {
                        var type     = Convert.ToInt32(hfType.Value);
                        var id       = Convert.ToInt32(hfId.Value);
                        var idNumber = string.Empty;

                        var cApprovalHistory = new CApprovalHistory();
                        var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);
                        approvalHistory.ApprovalDate = DateTime.Now;
                        approvalHistory.ApprovalMemo = tbRemark.Text;
                        // Reject
                        approvalHistory.ApprovalStep = (int)CConstValue.ApprovalStatus.Rejected;

                        if (type == (int)CConstValue.Approval.Refund)
                        {
                            var cC = new CRefund();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            if (cC.Update(c))
                            {
                                var cInvoiceInfo = new CInvoice();
                                var invoiceInfo  = cInvoiceInfo.Get(c.InvoiceId);

                                var cOriginalInvoiceInfo = new CInvoice();
                                var originalInvoiceInfo  = cOriginalInvoiceInfo.Get(Convert.ToInt32(invoiceInfo.OriginalInvoiceId));

                                invoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Cancelled_RF; // Canceled_R
                                invoiceInfo.UpdatedId = CurrentUserId;

                                originalInvoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Invoiced; // Invoiced
                                originalInvoiceInfo.UpdatedId = CurrentUserId;

                                cInvoiceInfo.Update(invoiceInfo);
                                cOriginalInvoiceInfo.Update(originalInvoiceInfo);
                            }
                        }
                        // Agency
                        else if (type == (int)CConstValue.Approval.Agency)
                        {
                            var cC = new CAgency();
                            var c  = cC.Get(id);
                            idNumber         = c.AgencyNumber;
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.CorporateCreditCard)
                        {
                            var cC = new CCorporateCreditCard();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // BusinessTrip
                        else if (type == (int)CConstValue.Approval.BusinessTrip)
                        {
                            var cC = new CBusinessTrip();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // PackageProgram
                        else if (type == (int)CConstValue.Approval.Package)
                        {
                            var cC = new CPackageProgram();
                            var c  = cC.GetPackageProgram(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // Expense
                        else if (type == (int)CConstValue.Approval.Expense)
                        {
                            var cC = new CExpense();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // Purchase Order
                        else if (type == (int)CConstValue.Approval.PurchaseOrder)
                        {
                            var cP = new CPurchaseOrder();
                            var c  = cP.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cP.Update(c);
                        }
                        // Hire
                        else if (type == (int)CConstValue.Approval.Hire)
                        {
                            var cC = new CHire();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        // Vacation
                        else if (type == (int)CConstValue.Approval.Vacation)
                        {
                            var cC = new CVacation();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        //Scholarship
                        else if (type == (int)CConstValue.Approval.Scholarship)
                        {
                            var cC = new CScholarship();
                            var c  = cC.Get(id);
                            idNumber         = c.ScholarshipMasterNo;
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;
                            cC.Update(c);
                        }
                        //Promotion
                        else if (type == (int)CConstValue.Approval.Promotion)
                        {
                            var cC = new CPromotion();
                            var c  = cC.Get(id);
                            idNumber         = c.PromotionMasterNo;
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;
                            cC.Update(c);
                        }
                        // CreditMemo
                        else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                        {
                            var cC = new CCreditMemoPayout();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;
                            cC.Update(c);
                        }

                        // update approvalHistory
                        cApprovalHistory.Update(approvalHistory);

                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, idNumber, CurrentUserId);

                        RunClientScript("Close();");
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message);
                    }
                }
            }
        }
Пример #2
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == @"Accept" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    var type = Convert.ToInt32(hfType.Value);
                    var id   = Convert.ToInt32(hfId.Value);

                    var cApprovalHistory = new CApprovalHistory();
                    var approvalHistory  = new ApprovalHistory()
                    {
                        CreatedId         = CurrentUserId,
                        CreatedDate       = DateTime.Now,
                        ApprovalDate      = DateTime.Now,
                        ApprovalMemo      = tbRemark.Text,
                        ApproveType       = type,
                        MenuSeqId         = id,
                        ApprovalUser      = CurrentUserId,
                        IsApprovalRequest = true,
                        ApprovalStep      = (int)CConstValue.ApprovalStatus.InProgress
                    };

                    if (type == (int)CConstValue.Approval.CorporateCreditCard)
                    {
                        try
                        {
                            var cCorporateCreditCard = new CCorporateCreditCard();
                            var corporateCreditCard  = cCorporateCreditCard.Get(id);

                            corporateCreditCard.ApprovalDate   = approvalHistory.ApprovalDate;
                            corporateCreditCard.ApprovalId     = approvalHistory.ApprovalUser;
                            corporateCreditCard.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            corporateCreditCard.ApprovalStatus = approvalHistory.ApprovalStep;

                            cCorporateCreditCard.Update(corporateCreditCard);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // BusinessTrip
                    if (type == (int)CConstValue.Approval.BusinessTrip)
                    {
                        try
                        {
                            var cBusinessTrip = new CBusinessTrip();
                            var businessTrip  = cBusinessTrip.Get(id);

                            businessTrip.ApprovalDate   = approvalHistory.ApprovalDate;
                            businessTrip.ApprovalId     = approvalHistory.ApprovalUser;
                            businessTrip.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            businessTrip.ApprovalStatus = approvalHistory.ApprovalStep;

                            cBusinessTrip.Update(businessTrip);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Expense Program
                    else if (type == (int)CConstValue.Approval.Expense)
                    {
                        try
                        {
                            var cExpense = new CExpense();
                            var expense  = cExpense.Get(id);

                            expense.ApprovalDate   = approvalHistory.ApprovalDate;
                            expense.ApprovalId     = approvalHistory.ApprovalUser;
                            expense.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            expense.ApprovalStatus = approvalHistory.ApprovalStep;

                            cExpense.Update(expense);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Purchase Order
                    else if (type == (int)CConstValue.Approval.PurchaseOrder)
                    {
                        try
                        {
                            // approved
                            approvalHistory.ApprovalStep = (int)CConstValue.ApprovalStatus.Approved;

                            var cPurchaseOrder = new CPurchaseOrder();
                            var purchaseOrder  = cPurchaseOrder.Get(id);

                            purchaseOrder.ApprovalDate   = approvalHistory.ApprovalDate;
                            purchaseOrder.ApprovalId     = approvalHistory.ApprovalUser;
                            purchaseOrder.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            purchaseOrder.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPurchaseOrder.Update(purchaseOrder);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }

                    // update approvalHistory
                    cApprovalHistory.Add(approvalHistory);

                    new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, string.Empty, CurrentUserId);
                }
            }
        }
Пример #3
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Cancel" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    try
                    {
                        var type = Convert.ToInt32(hfType.Value);
                        var id   = Convert.ToInt32(hfId.Value);

                        var cApprovalHistory = new CApprovalHistory();
                        var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);

                        bool isExists = true;
                        if (approvalHistory == null)
                        {
                            approvalHistory = new ApprovalHistory();
                            approvalHistory.ApprovalUser = CurrentUserId;
                            isExists = false;
                        }

                        approvalHistory.ApprovalDate = DateTime.Now;
                        approvalHistory.ApprovalMemo = tbRemark.Text;
                        approvalHistory.ApprovalStep = (int)CConstValue.ApprovalStatus.Canceled;

                        // update approvalHistory
                        if (isExists)
                        {
                            cApprovalHistory.Update(approvalHistory);
                        }

                        if (type == (int)CConstValue.Approval.Refund)
                        {
                            var cRefund = new CRefund();
                            var refund  = cRefund.Get(id);
                            refund.ApprovalDate   = approvalHistory.ApprovalDate;
                            refund.ApprovalId     = approvalHistory.ApprovalUser;
                            refund.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            refund.ApprovalStatus = approvalHistory.ApprovalStep;

                            if (cRefund.Update(refund))
                            {
                                var cInvoiceInfo = new CInvoice();
                                var invoiceInfo  = cInvoiceInfo.Get(refund.InvoiceId);

                                var cOriginalInvoiceInfo = new CInvoice();
                                var originalInvoiceInfo  = cOriginalInvoiceInfo.Get(Convert.ToInt32(invoiceInfo.OriginalInvoiceId));

                                invoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Cancelled_RF; // Canceled_R
                                invoiceInfo.UpdatedId = CurrentUserId;

                                originalInvoiceInfo.Status    = (int)CConstValue.InvoiceStatus.Invoiced; // Invoiced
                                originalInvoiceInfo.UpdatedId = CurrentUserId;

                                cInvoiceInfo.Update(invoiceInfo);
                                cOriginalInvoiceInfo.Update(originalInvoiceInfo);
                            }
                        }
                        else if (type == (int)CConstValue.Approval.Agency)
                        {
                            var cAgency = new CAgency();
                            var agency  = cAgency.Get(id);
                            agency.ApprovalDate   = approvalHistory.ApprovalDate;
                            agency.ApprovalId     = approvalHistory.ApprovalUser;
                            agency.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            agency.ApprovalStatus = approvalHistory.ApprovalStep;

                            cAgency.Update(agency);
                        }
                        else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                        {
                            var cCreditMemoPayout = new CCreditMemoPayout();
                            var creditMemoPayout  = cCreditMemoPayout.Get(id);
                            creditMemoPayout.ApprovalDate   = approvalHistory.ApprovalDate;
                            creditMemoPayout.ApprovalId     = approvalHistory.ApprovalUser;
                            creditMemoPayout.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            creditMemoPayout.ApprovalStatus = approvalHistory.ApprovalStep;

                            cCreditMemoPayout.Update(creditMemoPayout);
                        }
                        else if (type == (int)CConstValue.Approval.Package)
                        {
                            var cPackageProgram = new CPackageProgram();
                            var packageProgram  = cPackageProgram.GetPackageProgram(id);
                            packageProgram.ApprovalDate   = approvalHistory.ApprovalDate;
                            packageProgram.ApprovalId     = approvalHistory.ApprovalUser;
                            packageProgram.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            packageProgram.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPackageProgram.Update(packageProgram);
                        }
                        else if (type == (int)CConstValue.Approval.Promotion)
                        {
                            var cPromotion = new CPromotion();
                            var promotion  = cPromotion.Get(id);
                            promotion.ApprovalDate   = approvalHistory.ApprovalDate;
                            promotion.ApprovalId     = approvalHistory.ApprovalUser;
                            promotion.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            promotion.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPromotion.Update(promotion);
                        }
                        else if (type == (int)CConstValue.Approval.Scholarship)
                        {
                            var cScholarship = new CScholarship();
                            var scholarship  = cScholarship.Get(id);
                            scholarship.ApprovalDate   = approvalHistory.ApprovalDate;
                            scholarship.ApprovalId     = approvalHistory.ApprovalUser;
                            scholarship.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            scholarship.ApprovalStatus = approvalHistory.ApprovalStep;

                            cScholarship.Update(scholarship);
                        }
                        else if (type == (int)CConstValue.Approval.CorporateCreditCard)
                        {
                            var cCorporateCreditCard = new CCorporateCreditCard();
                            var corporateCreditCard  = cCorporateCreditCard.Get(id);
                            corporateCreditCard.ApprovalDate   = approvalHistory.ApprovalDate;
                            corporateCreditCard.ApprovalId     = approvalHistory.ApprovalUser;
                            corporateCreditCard.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            corporateCreditCard.ApprovalStatus = approvalHistory.ApprovalStep;

                            cCorporateCreditCard.Update(corporateCreditCard);
                        }
                        // BusinessTrip
                        else if (type == (int)CConstValue.Approval.BusinessTrip)
                        {
                            var cBusinessTrip = new CBusinessTrip();
                            var businessTrip  = cBusinessTrip.Get(id);
                            businessTrip.ApprovalDate   = approvalHistory.ApprovalDate;
                            businessTrip.ApprovalId     = approvalHistory.ApprovalUser;
                            businessTrip.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            businessTrip.ApprovalStatus = approvalHistory.ApprovalStep;

                            cBusinessTrip.Update(businessTrip);
                        }
                        // Purchase Order
                        else if (type == (int)CConstValue.Approval.PurchaseOrder)
                        {
                            var cPurchaseOrder = new CPurchaseOrder();
                            var purchaseOrder  = cPurchaseOrder.Get(id);
                            purchaseOrder.ApprovalDate   = approvalHistory.ApprovalDate;
                            purchaseOrder.ApprovalId     = approvalHistory.ApprovalUser;
                            purchaseOrder.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            purchaseOrder.ApprovalStatus = approvalHistory.ApprovalStep;

                            cPurchaseOrder.Update(purchaseOrder);
                        }
                        // Expense
                        else if (type == (int)CConstValue.Approval.Expense)
                        {
                            var cExpense = new CExpense();
                            var expense  = cExpense.Get(id);
                            expense.ApprovalDate   = approvalHistory.ApprovalDate;
                            expense.ApprovalId     = approvalHistory.ApprovalUser;
                            expense.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            expense.ApprovalStatus = approvalHistory.ApprovalStep;

                            cExpense.Update(expense);
                        }
                        // Hire
                        else if (type == (int)CConstValue.Approval.Hire)
                        {
                            var cHire = new CHire();
                            var hire  = cHire.Get(id);
                            hire.ApprovalDate   = approvalHistory.ApprovalDate;
                            hire.ApprovalId     = approvalHistory.ApprovalUser;
                            hire.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            hire.ApprovalStatus = approvalHistory.ApprovalStep;

                            cHire.Update(hire);
                        }
                        // Vacation
                        else if (type == (int)CConstValue.Approval.Vacation)
                        {
                            var cVacation = new CVacation();
                            var vacation  = cVacation.Get(id);
                            vacation.ApprovalDate   = approvalHistory.ApprovalDate;
                            vacation.ApprovalId     = approvalHistory.ApprovalUser;
                            vacation.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            vacation.ApprovalStatus = approvalHistory.ApprovalStep;

                            cVacation.Update(vacation);
                        }

                        RunClientScript("Close();");
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message);
                    }
                }
            }
        }
Пример #4
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Revise" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    try
                    {
                        var type = Convert.ToInt32(hfType.Value);
                        var id   = Convert.ToInt32(hfId.Value);

                        var cApprovalHistory = new CApprovalHistory();
                        var approvalHistory  = cApprovalHistory.Get(type, id, CurrentUserId);
                        approvalHistory.ApprovalDate = DateTime.Now;
                        approvalHistory.ApprovalMemo = tbRemark.Text;
                        // Revice
                        approvalHistory.ApprovalStep = (int)CConstValue.ApprovalStatus.Revise;

                        if (type == (int)CConstValue.Approval.Refund)
                        {
                            var cC = new CRefund();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Agency)
                        {
                            var cC = new CAgency();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.CorporateCreditCard)
                        {
                            var cC = new CCorporateCreditCard();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.BusinessTrip)
                        {
                            var cC = new CBusinessTrip();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Package)
                        {
                            var cC = new CPackageProgram();
                            var c  = cC.GetPackageProgram(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Expense)
                        {
                            var cC = new CExpense();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.PurchaseOrder)
                        {
                            var cC = new CPurchaseOrder();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Hire)
                        {
                            var cC = new CHire();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Vacation)
                        {
                            var cC = new CVacation();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Scholarship)
                        {
                            var cC = new CScholarship();
                            var c  = cC.Get(id);
                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.Promotion)
                        {
                            var cC = new CPromotion();
                            var c  = cC.Get(id);

                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }
                        else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                        {
                            var cC = new CCreditMemoPayout();
                            var c  = cC.Get(id);

                            c.ApprovalDate   = approvalHistory.ApprovalDate;
                            c.ApprovalId     = approvalHistory.ApprovalUser;
                            c.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            c.ApprovalStatus = approvalHistory.ApprovalStep;

                            cC.Update(c);
                        }

                        // update approvalHistory
                        cApprovalHistory.Update(approvalHistory);

                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, string.Empty, CurrentUserId);

                        RunClientScript("Close();");
                    }
                    catch (Exception ex)
                    {
                        ShowMessage(ex.Message);
                    }
                }
            }
        }
Пример #5
0
        protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            // Save
            if (e.Item.Text == "TempSave" || e.Item.Text == "Request")
            {
                if (IsValid)
                {
                    var corporateCreditCardSchema = new CCorporateCreditCardSchema().GetByUserId(CurrentUserId);
                    if (corporateCreditCardSchema != null)
                    {
                        var corporateCreditCard = new CCorporateCreditCard().GetByUserId(CurrentUserId);
                        if (corporateCreditCard != null)
                        {
                            var startDay = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 4);
                            var endDay   = startDay.AddMonths(1);
                            if (corporateCreditCard.PeriodStart >= startDay && corporateCreditCard.PeriodEnd < endDay)
                            {
                                ShowMessage("Credit on this month is already requested. Try it again when 4th beginning of month.");
                                return;
                            }
                        }

                        if (RadNumericTextBoxGrandTotal.Value > (double)corporateCreditCardSchema.CreditLimit)
                        {
                            ShowMessage("Your limited Credit Amount of  is " + corporateCreditCardSchema.CreditLimit);
                            return;
                        }

                        var cObj = new CCorporateCreditCard();
                        var obj  = cObj.Get(Id);

                        // new one
                        if (obj == null)
                        {
                            obj             = new Erp2016.Lib.CorporateCreditCard();
                            obj.CreatedId   = Convert.ToInt32(CurrentUserId);
                            obj.CreatedDate = DateTime.Now;
                            obj.PeriodStart = (DateTime)RadDatePickerStart.SelectedDate;
                            obj.PeriodEnd   = (DateTime)RadDatePickerEnd.SelectedDate;
                            int newIndex = Convert.ToInt32(cObj.Add(obj).ToString());
                            obj = cObj.Get(newIndex);
                            ViewState["NewIndex"] = newIndex;
                        }
                        else
                        {
                            obj.PeriodStart       = (DateTime)RadDatePickerStart.SelectedDate;
                            obj.PeriodEnd         = (DateTime)RadDatePickerEnd.SelectedDate;
                            obj.UpdatedId         = Convert.ToInt32(CurrentUserId);
                            obj.UpdatedDate       = DateTime.Now;
                            ViewState["NewIndex"] = obj.CorporateCreditCardId.ToString();
                        }

                        obj.ApprovalId   = CurrentUserId;
                        obj.ApprovalDate = DateTime.Now;

                        if (e.Item.Text == "TempSave")
                        {
                            obj.ApprovalStatus = null;
                        }
                        else
                        {
                            var cApprovalHistory = new CApprovalHistory();
                            cApprovalHistory.DelApprovalHistory((int)CConstValue.Approval.CorporateCreditCard, Convert.ToInt32(ViewState["NewIndex"]));

                            // approve request
                            var approval       = new CApproval();
                            var approvalResult = approval.ApproveRequstCreate((int)CConstValue.Approval.CorporateCreditCard, CurrentUserId, Convert.ToInt32(ViewState["NewIndex"]));
                            if (approvalResult > 0)
                            {
                                obj.ApprovalStatus = approvalResult;
                            }
                            else
                            {
                                ShowMessage("Failed");
                                return;
                            }

                            new CMail().SendMail(CConstValue.Approval.CorporateCreditCard, CConstValue.MailStatus.ToApproveUser, Convert.ToInt32(ViewState["NewIndex"]), string.Empty, CurrentUserId);
                        }



                        cObj.Update(obj);

                        // save uploading file
                        FileDownloadList1.SaveFile(Convert.ToInt32(ViewState["NewIndex"]));

                        // save other tables
                        RunClientScript("SaveChanges();");
                    }
                    else
                    {
                        ShowMessage("not found Limit credit amount. It needs to be registered.");
                    }
                }
                else
                {
                    ShowMessage("Failed");
                }
            }
            // Revise
            else if (e.Item.Text == "Revise")
            {
                RunClientScript("ShowApprovalReviseWindow('" + Id + "');");
            }
            // Approval
            else if (e.Item.Text == "Approve")
            {
                RunClientScript("ShowApprovalWindow('" + Id + "');");
            }
            // Reject
            else if (e.Item.Text == "Reject")
            {
                RunClientScript("ShowApprovalRejectWindow('" + Id + "');");
            }
            // Accept
            else if (e.Item.Text == "Accept")
            {
                RunClientScript("ShowApprovalAcceptWindow('" + Id + "');");
            }
            // Complete
            else if (e.Item.Text == "Complete")
            {
                RunClientScript("ShowApprovalCompleteWindow('" + Id + "');");
            }
            // Print
            else if (e.Item.Text == "Print")
            {
                RunClientScript("ShowPrint();");
            }
            // Cancel
            else if (e.Item.Text == "Cancel")
            {
                RunClientScript("ShowApprovalCancelWindow('" + Id + "');");
            }
            // close
            else if (e.Item.Text == "Close")
            {
                RunClientScript("Close();");
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Convert.ToInt32(Request["id"]);

            if (!IsPostBack)
            {
                foreach (GridColumn v in RadGridCorporateCreditCardDetail.Columns)
                {
                    if (v.GetType() == typeof(GridTemplateColumn))
                    {
                        var column = (GridTemplateColumn)v;
                        switch (column.UniqueName)
                        {
                        case "Date":
                            column.DefaultInsertValue = DateTime.Today.ToString("MM-dd-yyyy");
                            break;

                        case "SiteLocationId":
                            var vwSiteLocationList = new CSiteLocation().GetSiteLocationList(CurrentSiteLocationId);
                            if (vwSiteLocationList != null)
                            {
                                column.DefaultInsertValue = vwSiteLocationList.SiteAndSiteLocationName;
                            }
                            break;
                        }
                    }
                }

                var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1");
                //scriptManager.Scripts.Add(new ScriptReference() { Path = ResolveUrl("~/assets/js/jquery.printArea.js") });
                //scriptManager.RegisterPostBackControl(RadButtonFileDownload);
                FileDownloadList1.InitFileDownloadList((int)CConstValue.Upload.CorporateCreditCard);

                var obj = new CCorporateCreditCard();
                var requestOrApprovalType = Request["requestOrApprovalType"];
                var approvalType          = Request["approvalType"];

                var buttonList = new List <string>();

                // new
                if (Request["createOrListType"] == "0")
                {
                    obj = obj.GetNewDocument(CurrentUserId);

                    buttonList.Add("TempSave");
                    buttonList.Add("Request");
                    buttonList.Add("Close");

                    SetVisibleItems(true);
                }
                // select
                else
                {
                    FileDownloadList1.GetFileDownload(Convert.ToInt32(Id));

                    // date
                    obj = new CCorporateCreditCard(Id);

                    // request list
                    if (requestOrApprovalType == "0")
                    {
                        // Revise
                        if (approvalType == ((int)CConstValue.ApprovalStatus.Revise).ToString())
                        {
                            buttonList.Add("Request");
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(true);
                        }
                        // TempSave
                        else if (approvalType == string.Empty)
                        {
                            buttonList.Add("TempSave");
                            buttonList.Add("Request");
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(true);
                        }
                        // Request
                        else if (approvalType == ((int)CConstValue.ApprovalStatus.Requested).ToString())
                        {
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(false);
                        }
                        else
                        {
                            buttonList.Add("Close");

                            SetVisibleItems(false);
                        }
                    }
                    // approval
                    else if (requestOrApprovalType == "1")
                    {
                        // approved or rejected
                        if (approvalType == ((int)CConstValue.ApprovalStatus.Approved).ToString() ||
                            approvalType == ((int)CConstValue.ApprovalStatus.Rejected).ToString() ||
                            approvalType == ((int)CConstValue.ApprovalStatus.Canceled).ToString())
                        {
                            buttonList.Add("Close");
                        }
                        else
                        {
                            var refundApproveInfo = new CGlobal();
                            var supervisor        = refundApproveInfo.CheckApprovalEnable((int)CConstValue.Approval.CorporateCreditCard, Convert.ToInt32(Id));

                            if (CurrentUserId == supervisor)
                            {
                                buttonList.Add("Approve");
                                buttonList.Add("Reject");
                                buttonList.Add("Revise");
                                buttonList.Add("Close");
                            }
                            else
                            {
                                buttonList.Add("Close");
                            }
                        }

                        SetVisibleItems(false);
                    }
                    // Hire from HQ
                    else if (requestOrApprovalType == "2")
                    {
                        // Wating for review from HQ
                        if (approvalType == ((int)CConstValue.ApprovalStatus.WaitingForPreviewFromHq).ToString())
                        {
                            buttonList.Add("Accept");
                            buttonList.Add("Reject");
                            buttonList.Add("Close");
                        }
                        // In progress
                        else if (approvalType == ((int)CConstValue.ApprovalStatus.InProgress).ToString())
                        {
                            buttonList.Add("Print");
                            buttonList.Add("Complete");
                            buttonList.Add("Reject");
                            buttonList.Add("Close");
                        }
                        // Approved
                        else if (approvalType == ((int)CConstValue.ApprovalStatus.Approved).ToString())
                        {
                            buttonList.Add("Print");
                            buttonList.Add("Close");
                        }
                        else
                        {
                            buttonList.Add("Close");
                        }

                        SetVisibleItems(false);
                    }
                }

                foreach (RadToolBarItem item in RadToolBar1.Items)
                {
                    if (buttonList.Contains(item.Text))
                    {
                        item.Visible = true;
                    }
                    else
                    {
                        item.Visible = false;
                    }
                }

                // new or temp
                if (approvalType == ((int)CConstValue.ApprovalStatus.Canceled).ToString() || approvalType == string.Empty)
                {
                    FileDownloadList1.SetVisibieUploadControls(true);
                }
                else
                {
                    FileDownloadList1.SetVisibieUploadControls(false);
                }

                var dt = new DataTable();
                dt.Columns.Add("DocNo");
                dt.Columns.Add("Site");
                dt.Columns.Add("Location");
                dt.Columns.Add("Name");
                dt.Columns.Add("Date");
                var newDr = dt.NewRow();
                newDr["DocNo"]    = obj.DocNo;
                newDr["Site"]     = obj.Site;
                newDr["Location"] = obj.Location;
                newDr["Name"]     = obj.Name;
                newDr["Date"]     = obj.Date;
                dt.Rows.Add(newDr);

                RadGridInfo.DataSource = dt;

                // date
                if (obj.StartDate != null)
                {
                    RadDatePickerStart.SelectedDate = obj.StartDate;
                }
                if (obj.EndDate != null)
                {
                    RadDatePickerEnd.SelectedDate = obj.EndDate;
                }
            }
        }