Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Convert.ToInt32(Request["id"]);

            if (!IsPostBack)
            {
                var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1");
                //scriptManager.Scripts.Add(new ScriptReference() { Path = ResolveUrl("~/assets/js/jquery.printArea.js") });
                //scriptManager.RegisterPostBackControl(RadButtonFileDownload);

                var obj            = new CVacation();
                var vacationDetail = obj.Get(Id);
                var cUser          = new CUser();
                var user           = cUser.Get((int)vacationDetail.CreatedId);
                ViewState["UserId"] = user.UserId;

                SetVisibleItems(false);

                var dt = new DataTable();
                dt.Columns.Add("FullName");
                dt.Columns.Add("Site");
                dt.Columns.Add("SiteLocation");
                var newDr = dt.NewRow();
                newDr["FullName"] = cUser.GetUserName(user);
                var campus = (new CSiteLocation()).Get(user.SiteLocationId);
                newDr["SiteLocation"] = campus.Name;
                var site = (new CSite()).Get(campus.SiteId);
                newDr["Site"] = site.Name;
                dt.Rows.Add(newDr);
                RadGridInfo.DataSource = dt;
            }
        }
Example #2
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);
                    }
                }
            }
        }
Example #3
0
        protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            // Save
            if (e.Item.Text == "TempSave" || e.Item.Text == "Request")
            {
                if (IsValid)
                {
                    var cObj = new CVacation();
                    var obj  = cObj.Get(Id);

                    // new one
                    if (obj == null)
                    {
                        obj             = new Erp2016.Lib.Vacation();
                        obj.CreatedId   = Convert.ToInt32(CurrentUserId);
                        obj.CreatedDate = DateTime.Now;

                        int newIndex = Convert.ToInt32(cObj.Add(obj).ToString());
                        obj = cObj.Get(newIndex);
                        ViewState["NewIndex"] = newIndex;
                    }
                    else
                    {
                        obj.UpdatedId         = Convert.ToInt32(CurrentUserId);
                        obj.UpdatedDate       = DateTime.Now;
                        ViewState["NewIndex"] = obj.VacationId.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.Vacation, Convert.ToInt32(ViewState["NewIndex"]));

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

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

                    // data
                    obj.VacationType = Convert.ToInt32(RadComboBoxVacationType.SelectedValue);
                    obj.Remark       = RadTextBoxRemark.Text;

                    cObj.Update(obj);

                    // delete
                    CVacationDetail vacationDetailClass = new CVacationDetail();
                    vacationDetailClass.DeleteItemsByVacationId(obj.VacationId);

                    // insert
                    foreach (RadDate radDate in RadCalendar1.SelectedDates)
                    {
                        vacationDetailClass.Add(new VacationDetail()
                        {
                            CreatedId   = CurrentUserId,
                            CreatedDate = DateTime.Now,
                            VacationId  = obj.VacationId,
                            IsFullDay   = RadComboBoxDayType.SelectedValue == "1" ? true : false,
                            Date        = radDate.Date
                        });
                    }

                    // save other tables
                    RunClientScript("Close();");
                }
                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 + "');");
            }
            // 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();");
            }
        }
Example #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Id = Convert.ToInt32(Request["id"]);

            if (!IsPostBack)
            {
                var scriptManager = (RadScriptManager)Page.Master.FindControl("RadScriptManager1");
                //scriptManager.Scripts.Add(new ScriptReference() { Path = ResolveUrl("~/assets/js/jquery.printArea.js") });
                //scriptManager.RegisterPostBackControl(RadButtonFileDownload);

                var obj = new CVacation();
                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
                {
                    // date
                    obj = new CVacation(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("Request");
                            buttonList.Add("Cancel");
                            buttonList.Add("Close");

                            SetVisibleItems(true);
                        }
                        // Request
                        else if (approvalType == "1")
                        {
                            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())
                        {
                            // permission
                            if (CurrentGroupId == (int)CConstValue.UserGroupForVacation.IT ||
                                CurrentGroupId == (int)CConstValue.UserGroupForVacation.HR)
                            {
                                buttonList.Add("Cancel");
                            }

                            buttonList.Add("Close");
                        }
                        else if (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.Vacation, 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")
                    {
                        // permission
                        if (CurrentGroupId == (int)CConstValue.UserGroupForVacation.IT ||
                            CurrentGroupId == (int)CConstValue.UserGroupForVacation.HR)
                        {
                            buttonList.Add("Cancel");
                        }

                        buttonList.Add("Print");
                        buttonList.Add("Close");

                        SetVisibleItems(false);
                    }
                }

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

                var dt = new DataTable();
                dt.Columns.Add("DocNo");
                dt.Columns.Add("DateOfIssue");
                var newDr = dt.NewRow();
                newDr["DocNo"]       = obj.DocNo;
                newDr["DateOfIssue"] = obj.DateOfIssue;
                dt.Rows.Add(newDr);
                RadGridInfo.DataSource = dt;

                // Get Data
                var vacationObj = obj.Get(Id);
                if (vacationObj != null)
                {
                    RadComboBoxVacationType.SelectedIndex = vacationObj.VacationType;

                    CVacationDetail vacationDetailClass = new CVacationDetail();

                    foreach (VacationDetail vd in vacationDetailClass.Get(vacationObj.VacationId))
                    {
                        RadComboBoxDayType.SelectedIndex = vd.IsFullDay ? 0 : 1;
                        RadCalendar1.SelectedDates.Add(new RadDate(vd.Date));
                    }

                    ViewState["SelectedDates"] = RadCalendar1.SelectedDates.ToArray();
                    RadTextBoxRemark.Text      = vacationObj.Remark;

                    SetDataInformation();

                    // save for remain Days in load
                    ViewState["UserId"] = vacationObj.CreatedId;
                }
                else
                {
                    // save for remain Days in load
                    ViewState["UserId"] = CurrentUserId;
                }
            }
        }
Example #5
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);
                    }
                }
            }
        }
Example #6
0
    public static void SetFilterCheckListItems(GridFilterCheckListItemsRequestedEventArgs e)
    {
        object dataSource = null;
        string dataField  = (e.Column as IGridDataColumn).GetActiveDataField();

        switch (dataField)
        {
        // Common
        case "SiteName":
            dataSource = new CSite().GetSiteNameList();
            break;

        case "SiteLocationName":
            dataSource = new CSiteLocation().GetSiteLocationNameList();
            break;

        case "CountryName":
            dataSource = new CCountry().GetCountryNameList();
            break;

        case "AgencyName":
            dataSource = new CAgency().GetAgencyNameList();
            break;

        case "ProgramName":
            dataSource = new CProgram().GetProgramNameList();
            break;

        case "InvoiceCoaItemId":
            dataSource = new CInvoiceCoaItem().GetInvoiceCoaItemIdNameList();
            break;

        case "InvoiceName":
            dataSource = new CProgram().GetInvoiceNameList();
            break;

        case "StudentName":
            dataSource = new CStudent().GetStudentNameList();
            break;

        case "UserName":
            dataSource = new CUser().GetUserNameList();
            break;

        case "Status":
            dataSource = new CApproval().GetStatusNameList();
            break;

        case "ApprovalUserName":
            dataSource = new CUser().GetApprovalUserNameList();
            break;

        case "InstructorName":
            dataSource = new CUser().GetInstructorNameList();
            break;

        case "ProgramStatusName":
            dataSource = new CProgramRegistration().GetProgramStatusList();
            break;

        // Dashboard
        case "Type":
            dataSource = new CApproval().GetApprovalTypeNameList();
            break;

        // Invoice
        case "InvoiceType":
            dataSource = new CInvoice().GetInvoiceTypeList();
            break;

        case "InvoiceStatus":
            dataSource = new CInvoice().GetInvoiceStatusList();
            break;

        // Deposit
        case "DepositStatus":
            dataSource = new CDeposit().GetDepositStatusNameList();
            break;

        case "DepositBank":
            dataSource = new CDeposit().GetDepositBankNameList();
            break;

        case "PaidMethod":
            dataSource = new CDeposit().GetPaidMethodNameList();
            break;

        case "ExtraTypeName":
            dataSource = new CDeposit().GetExtraTypeNameList();
            break;

        // CreditMemo
        case "CreditMemoType":
            dataSource = new CCreditMemo().GetCreditMemoTypeNameList();
            break;

        case "PayoutMethodName":
            dataSource = new CCreditMemoPayout().GetPayoutMethodNameList();
            break;

        // Academic
        case "FacultyName":
            dataSource = new CFaculty().GetFacultyNameList();
            break;

        case "ProgramGroupName":
            dataSource = new CProgramGroup().GetProgramGroupNameList();
            break;

        // Vacation
        case "VacationType":
            dataSource = new CVacation().GetVacationTypeNameList();
            break;

        // User
        case "CreatedUserName":
            dataSource = new CUser().GetCreatedUserNameList();
            break;

        case "UpdatedUserName":
            dataSource = new CUser().GetUpdatedUserNameList();
            break;

        case "PositionName":
            dataSource = new CUser().GetPositionNameList();
            break;

        case "Email":
            dataSource = new CUser().GetEmailNameList();
            break;

        case "LoginId":
            dataSource = new CUser().GetLoginIdNameList();
            break;

        // PurchaseOrder
        case "PurchaseOrderTypeName":
            dataSource = new CPurchaseOrder().GetPurchaseOrderTypeNameList();
            break;

        case "PriorityTypeName":
            dataSource = new CPurchaseOrder().GetPriorityTypeNameList();
            break;

        case "ReviewTypeName":
            dataSource = new CPurchaseOrder().GetReviewTypeNameList();
            break;
        ////Invoice#
        //case "SchoolName":
        //    dataSource = new CSite().GetSiteNameList();
        //    break;

        // Inventory
        case "AssignedUserName":
            dataSource = new CUser().GetAssignedUserNameList();
            break;

        case "InventoryCategoryName":
            dataSource = new CInventory().GetInventoryCategoryNameList();
            break;

        case "InventoryCategoryItemName":
            dataSource = new CInventory().GetInventoryCategoryItemNameList();
            break;

        case "ConditionName":
            dataSource = new CInventory().GetConditionNameList();
            break;

        case "InUseName":
            dataSource = new CInventory().GetInUseNameList();
            break;
        }

        if (dataSource != null)
        {
            SetFilter(e, dataField, dataSource);
        }
    }
Example #7
0
        protected void MainToolBar_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == @"Approve" && !string.IsNullOrEmpty(hfId.Value))
            {
                if (IsValid)
                {
                    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;
                    // cal
                    int approvalStatus = cApprovalHistory.CheckApprovalStep(type, id);
                    if (approvalStatus == (int)CConstValue.ApprovalStatus.Approved)
                    {
                        approvalStatus = new CGlobal().GetApprovalValue(type);
                    }
                    approvalHistory.ApprovalStep = approvalStatus;
                    // update approvalHistory
                    cApprovalHistory.Update(approvalHistory);

                    //Refund & Commission
                    if (type == (int)CConstValue.Approval.Refund)
                    {
                        var cRefundInfo = new CRefund();
                        var refundInfo  = cRefundInfo.Get(Convert.ToInt32(hfId.Value));

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

                        if (cRefundInfo.Update(refundInfo))
                        {
                            //if last approve
                            if (refundInfo.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                var vwRefund      = cRefundInfo.GetVwRefund(refundInfo.RefundId);
                                var refundAmount  = Math.Abs((decimal)vwRefund.RefundAmount);
                                var sumOfMdfAndCp = new CCreditMemo().GetSumOfMdfAndCp(vwRefund.RefundId);

                                var cCreditMemoPayout = new CCreditMemoPayout();
                                var creditMemoPayout  = cCreditMemoPayout.Get(refundInfo.CreditMemoPayoutId);

                                var cCreditMemo = new CCreditMemo();
                                var creditMemo  = cCreditMemo.Get(creditMemoPayout.CreditMemoId);

                                creditMemo.OriginalCreditMemoAmount = refundAmount - sumOfMdfAndCp;
                                creditMemo.CreditMemoStartDate      = DateTime.Now;
                                creditMemo.CreditMemoEndDate        = DateTime.Now.AddYears(1);
                                creditMemo.IsActive    = true;
                                creditMemo.UpdatedId   = CurrentUserId;
                                creditMemo.UpdatedDate = DateTime.Now;

                                // Approved
                                creditMemoPayout.ApprovalStatus = (int)CConstValue.ApprovalStatus.Approved;
                                creditMemoPayout.ApprovalDate   = DateTime.Now;
                                creditMemoPayout.ApprovalId     = CurrentUserId;
                                creditMemoPayout.Amount         = refundAmount;
                                creditMemoPayout.PayoutMethod   = vwRefund.PayoutMethod;
                                creditMemoPayout.IsActive       = true;

                                creditMemoPayout.UpdatedId   = CurrentUserId;
                                creditMemoPayout.UpdatedDate = DateTime.Now;

                                cCreditMemoPayout.Update(creditMemoPayout);

                                if (cCreditMemo.Update(creditMemo))
                                {
                                    var cInvoiceInfo = new CInvoice();
                                    var invoiceInfo  = cInvoiceInfo.Get(refundInfo.InvoiceId);

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

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

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

                                    var startDate = DateTime.Now;
                                    var endDate   = DateTime.Now;

                                    //invoice status update
                                    if (cInvoiceInfo.Update(invoiceInfo) && cOriginalInvoiceInfo.Update(originalInvoiceInfo))
                                    {
                                        // Program
                                        if (invoiceInfo.ProgramRegistrationId != null)
                                        {
                                            var cProgramRegiInfo = new CProgramRegistration();
                                            var programRegiInfo  = cProgramRegiInfo.Get(Convert.ToInt32(invoiceInfo.ProgramRegistrationId));
                                            programRegiInfo.UpdatedId               = CurrentUserId;
                                            programRegiInfo.UpdatedDate             = DateTime.Now;
                                            programRegiInfo.ProgramRegistrationType = 12; // cancel

                                            cProgramRegiInfo.Update(programRegiInfo);

                                            startDate = programRegiInfo.StartDate.Value;
                                            endDate   = programRegiInfo.EndDate.Value;
                                        }
                                        // Homestay
                                        else if (invoiceInfo.HomestayRegistrationId != null)
                                        {
                                            var cHomestayStudentRequest = new CHomestayStudentRequest();
                                            var homestayStudentRequest  = cHomestayStudentRequest.GetHomestayStudentRequest(Convert.ToInt32(invoiceInfo.HomestayRegistrationId));
                                            homestayStudentRequest.UpdateUserId          = CurrentUserId;
                                            homestayStudentRequest.UpdatedDate           = DateTime.Now;
                                            homestayStudentRequest.HomestayStudentStatus = 1; // cancel

                                            cHomestayStudentRequest.Update(homestayStudentRequest);

                                            startDate = homestayStudentRequest.StartDate.Value;
                                            endDate   = homestayStudentRequest.EndDate.Value;
                                        }
                                        // Dormitory
                                        else if (invoiceInfo.DormitoryRegistrationId != null)
                                        {
                                            var cDormitoryStudentRequest = new CDormitoryRegistrations();
                                            var dormitoryStudentRequest  = cDormitoryStudentRequest.GetDormitoryStudentRequest(Convert.ToInt32(invoiceInfo.ProgramRegistrationId));
                                            dormitoryStudentRequest.DormitoryStudentStatus = 1; // cancel
                                            dormitoryStudentRequest.UpdatedId   = CurrentUserId;
                                            dormitoryStudentRequest.UpdatedDate = DateTime.Now;

                                            cDormitoryStudentRequest.Update(dormitoryStudentRequest);

                                            startDate = dormitoryStudentRequest.StartDate.Value;
                                            endDate   = dormitoryStudentRequest.EndDate.Value;
                                        }

                                        // Rev
                                        var cInterimInvoice = new CInvoice();
                                        var interimInvoice  = new Invoice();
                                        CGlobal.Copy(invoiceInfo, interimInvoice);
                                        interimInvoice.OriginalInvoiceId = invoiceInfo.InvoiceId;
                                        interimInvoice.InvoiceType       = (int)CConstValue.InvoiceType.Refund_RV;
                                        interimInvoice.Status            = (int)CConstValue.InvoiceStatus.Invoiced;
                                        interimInvoice.CreatedId         = CurrentUserId;
                                        interimInvoice.CreatedDate       = DateTime.Now;

                                        if (cInterimInvoice.Add(interimInvoice) > 0)
                                        {
                                            var totalDays   = Convert.ToDateTime(endDate) - Convert.ToDateTime(startDate);
                                            var interimDays = Convert.ToDateTime(endDate) - Convert.ToDateTime(refundInfo.RefundDate);
                                            var interimRate = Math.Round((interimDays.TotalDays / totalDays.TotalDays), 2) * 100;

                                            var cInvoiceItem = new CInvoiceItem();
                                            var cOriginalInvoiceItemModels     = cInvoiceItem.GetInvoiceItemModels(invoiceInfo.InvoiceId);
                                            List <InvoiceItem> newInvoiceItems = new List <InvoiceItem>();
                                            foreach (CInvoiceItemModel ori in cOriginalInvoiceItemModels)
                                            {
                                                if (ori.InvoiceCoaItem.RevenueRecognition == 1)
                                                {
                                                    var newInvoiceRevItem = new InvoiceItem();
                                                    CGlobal.Copy(ori.InvoiceItem, newInvoiceRevItem);
                                                    newInvoiceRevItem.InvoiceId = interimInvoice.InvoiceId;

                                                    newInvoiceRevItem.StandardPrice *= (decimal)interimRate;
                                                    newInvoiceRevItem.StudentPrice  *= (decimal)interimRate;
                                                    newInvoiceRevItem.AgencyPrice   *= (decimal)interimRate;

                                                    newInvoiceRevItem.CreatedId   = CurrentUserId;
                                                    newInvoiceRevItem.CreatedDate = DateTime.Now;
                                                    newInvoiceRevItem.Remark      = "Refund Rev";
                                                    newInvoiceItems.Add(newInvoiceRevItem);
                                                }
                                            }

                                            if (newInvoiceItems.Count > 0)
                                            {
                                                // copy invoiceItems
                                                if (cInvoiceItem.Add(newInvoiceItems))
                                                {
                                                    RunClientScript("Close();");
                                                }
                                                else
                                                {
                                                    ShowMessage("failed to update inqury (Refund Ref Invoice Item)");
                                                }
                                            }
                                            else
                                            {
                                                RunClientScript("Close();");
                                            }
                                        }
                                        else
                                        {
                                            ShowMessage("failed to update inqury (Refund Ref Invoice)");
                                        }
                                    }
                                    else
                                    {
                                        ShowMessage("failed to update inqury (Original Invoice and Refund Invoice)");
                                    }
                                }
                                else
                                {
                                    ShowMessage("failed to update inqury (CreditMemo Info)");
                                }
                            }
                            else
                            {
                                RunClientScript("Close();");
                            }
                        }
                        else
                        {
                            ShowMessage("failed to update inqury (Refund Info)");
                        }
                    }
                    // Agency
                    else if (type == (int)CConstValue.Approval.Agency)
                    {
                        try
                        {
                            var cAgency = new CAgency();
                            var agency  = cAgency.Get(id);

                            idNumber              = agency.AgencyNumber;
                            agency.ApprovalDate   = approvalHistory.ApprovalDate;
                            agency.ApprovalId     = approvalHistory.ApprovalUser;
                            agency.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            agency.ApprovalStatus = approvalHistory.ApprovalStep;

                            cAgency.Update(agency);

                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // BusinessTrip
                    else 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);
                        }
                    }
                    // Purchase Order
                    else if (type == (int)CConstValue.Approval.PurchaseOrder)
                    {
                        try
                        {
                            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);
                        }
                    }
                    // Package Program
                    else if (type == (int)CConstValue.Approval.Package)
                    {
                        try
                        {
                            var cP             = new CPackageProgram();
                            var packageProgram = cP.GetPackageProgram(id);

                            packageProgram.ApprovalDate   = approvalHistory.ApprovalDate;
                            packageProgram.ApprovalId     = approvalHistory.ApprovalUser;
                            packageProgram.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            packageProgram.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (packageProgram.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                packageProgram.IsActive = true;
                            }

                            cP.Update(packageProgram);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    //Scholarship//
                    else if (type == (int)CConstValue.Approval.Scholarship)
                    {
                        try
                        {
                            var cScholar = new CScholarship();
                            var scholar  = cScholar.Get(Convert.ToInt32(id));

                            idNumber               = scholar.ScholarshipMasterNo;
                            scholar.ApprovalDate   = approvalHistory.ApprovalDate;
                            scholar.ApprovalId     = approvalHistory.ApprovalUser;
                            scholar.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            scholar.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (scholar.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                scholar.IsActive = true;
                            }

                            cScholar.Update(scholar);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    //Promotion//
                    else if (type == (int)CConstValue.Approval.Promotion)
                    {
                        try
                        {
                            var cPromo = new CPromotion();
                            var promo  = cPromo.Get(Convert.ToInt32(id));

                            idNumber             = promo.PromotionMasterNo;
                            promo.ApprovalDate   = approvalHistory.ApprovalDate;
                            promo.ApprovalId     = approvalHistory.ApprovalUser;
                            promo.ApprovalMemo   = approvalHistory.ApprovalMemo;
                            promo.ApprovalStatus = approvalHistory.ApprovalStep;
                            if (promo.ApprovalStatus == (int)CConstValue.ApprovalStatus.Approved)
                            {
                                promo.IsActive = true;
                            }

                            cPromo.Update(promo);
                            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);
                        }
                    }
                    // Hire
                    else if (type == (int)CConstValue.Approval.Hire)
                    {
                        try
                        {
                            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);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // Vacation
                    else if (type == (int)CConstValue.Approval.Vacation)
                    {
                        try
                        {
                            var cVacationDetail = new CVacation();
                            var vacation        = cVacationDetail.Get(id);

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

                            cVacationDetail.Update(vacation);
                            RunClientScript("Close();");
                        }
                        catch (Exception ex)
                        {
                            ShowMessage(ex.Message);
                        }
                    }
                    // CreditMemoPayout
                    else if (type == (int)CConstValue.Approval.CreditMemoPayout)
                    {
                        try
                        {
                            var cCreditMemo = new CCreditMemoPayout();
                            var creditMemo  = cCreditMemo.Get(id);

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

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


                    if (approvalHistory.ApprovalStep != (int)CConstValue.ApprovalStatus.Approved) //if has a next approver, request approve
                    {
                        var approvalInfo = new CApproval();
                        var supervisor   = approvalInfo.GetSupuervisor(type, CurrentUserId);

                        if (supervisor > 0)
                        {
                            var cNextApprove = new CApprovalHistory();
                            var nextApprove  = cNextApprove.Get(type, id, supervisor);

                            nextApprove.IsApprovalRequest = true;
                            cNextApprove.Update(nextApprove);
                        }

                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToApproveUserAndRequestUser, id, idNumber, CurrentUserId);
                    }
                    // approved
                    else
                    {
                        new CMail().SendMail((CConstValue.Approval)type, CConstValue.MailStatus.ToRequestUser, id, idNumber, CurrentUserId);
                    }
                }
            }
        }
Example #8
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);
                    }
                }
            }
        }