void SaveRouteOfficerTemp(string eventType, string batchId)
        {
            var rv = new AppRouteSession();
            //if (eventType == "New")
            //{
            var col = rv.GetRouteOfficer(User.Identity.Name);     // GetRvHeadLines();

            foreach (var d in col)
            {
                var obj = new SM_APPROVAL_ROUTE_OFFICER_TEMP()
                {
                    MENUID      = d.MENUID, //drpCalcBasis.SelectedValue,
                    BATCHID     = batchId,
                    APPROVER_ID = d.APPROVER_ID,
                    PRIORITY    = d.PRIORITY,
                    STATUS      = open,
                    CREATEDATE  = DateTime.Now,
                    USERID      = User.Identity.Name,
                    EVENTTYPE   = d.EVENTTYPE,
                };
                repoAppRouteOffTemp.Insert(obj);
            }

            //}
            //else
            //{
            //    var col = rv.GetRevenueHead(User.Identity.Name); // GetRvHeadLines();
            //    foreach (var d in col)
            //    {

            //        var obj = new SM_REVENUEHEADTEMP()
            //        {
            //            CODE = d.CODE, //drpCalcBasis.SelectedValue,
            //            RVGROUPCODE = rec.GROUPCODE,
            //            DESCRIPTION = d.DESCRIPTION,
            //            ACCOUNT_ID = d.ACCOUNT_ID,
            //            MERCHANTID = rec.MERCHANTID,
            //            STATUS = open,
            //            RECORDID = d.NewRecord ? 0 : d.ITBID,
            //            CREATEDATE = DateTime.Now,
            //            USERID = User.Identity.Name,
            //            EVENTTYPE = d.EVENTTYPE, // ? eventInsert : d.Deleted ? eventDelete : eventEdit,
            //            BATCHID = rec.BATCHID,
            //            SETTLEMENT_FREQUENCY = d.SETTLEMENT_FREQUENCY,
            //        };
            //        repoRvHeadTemp.Insert(obj);
            //    }
            //}
        }
        public ActionResult DeleteRouteOfficer(string id, string m)
        {
            var rv = new AppRouteSession();

            try
            {
                rv.DeleteRouteOfficer(id, User.Identity.Name);

                var lst2  = rv.GetRouteOfficer(User.Identity.Name); // GetRvHeadLines().ToList();
                var html2 = PartialView("_ViewRouteOfficer", lst2).RenderToString();
                return(Json(new { RespCode = 0, RespMessage = "", data_html = html2 }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var lst3 = rv.GetRouteOfficer(User.Identity.Name); //  GetRvHeadLines().ToList();
                var html = PartialView("_ViewRouteOfficer", lst3).RenderToString();
                return(Json(new { RespCode = 1, RespMessage = "Problem Processing Request.", data_html = html }, JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult EditRouteOfficer(string id)
 {
     try
     {
         var rv  = new AppRouteSession();
         var rec = rv.FindRouteOfficer(id, User.Identity.Name);
         if (rec != null)
         {
             BindComboMsc();
             ViewBag.ButtonText  = "Update";
             ViewBag.HeaderTitle = "Edit Route Officer";
             return(PartialView("_AddRouteOfficer", rec));
         }
     }
     catch (Exception ex)
     {
     }
     return(null);
 }
        public async Task <ActionResult> ApproverList(int id)
        {
            try
            {
                var rv = new AppRouteSession();
                rv.PurgeRouteOfficer(User.Identity.Name);
                var no_level = 0;
                var rec      = await _repo.GetMenuApproverOfficersAsync(id);

                if (rec.Count > 0)
                {
                    no_level = rec[0].NOLEVEL; //repoSession.FindAsync(id);
                }
                var html = PartialView("_ViewApproverLocal", rec).RenderToString();
                return(Json(new { data_html = html, data_level = no_level, RespCode = 0, RespMessage = "Success" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var obj1 = new { RespCode = 2, RespMessage = ex.Message };
                return(Json(obj1, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult DeleteRouteOfficerLocal(int id)
        {
            string msg   = "";
            var    rv    = new AppRouteSession();
            var    model = _repo.GetRouteOfficer(id);

            if (model == null)
            {
                msg = "Bad Request";
                return(Json(new { RespCode = 0, RespMessage = msg }, JsonRequestBehavior.AllowGet));
            }
            var obj = new ApprovalRouteOffObj()
            {
                APPROVER_ID = model.APPROVER_ID,
                MENUID      = model.MENUID,
                PRIORITY    = model.PRIORITY,
                USERID      = User.Identity.Name,
                DB_ITBID    = model.DB_ITBID,
                PID         = model.PID,
                EVENTTYPE   = eventDelete,
            };
            OutPutObj rst;

            rst = rv.PostRouteOfficer(obj, 2);
            if (rst != null && rst.RespCode != 0)
            {
                msg = rst.RespMessage; // "Revenue Code Already exist. Duplicate Record is not allowed.";
                return(Json(new { RespCode = 1, RespMessage = msg }, JsonRequestBehavior.AllowGet));
            }
            //SessionHelper.GetRvHead(Session).UpdateItem(obj);
            // rv.PostRevenueHead(obj, 2);
            var w    = rv.GetRouteOfficer(User.Identity.Name); // GetRvHeadLines().ToList();
            var html = PartialView("_ViewRouteOfficer", w).RenderToString();

            msg = "Record Updated to List";
            return(Json(new { data_html = html, RespCode = 0, RespMessage = msg }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddRouteOfficer(ApprovalRouteOffObj model, string m)
        {
            var    rv  = new AppRouteSession();
            string msg = "";

            try
            {
                //var lst = GetRvHeadLines().ToList();
                if (string.IsNullOrEmpty(model.PID) && model.DB_ITBID.GetValueOrDefault() <= 0)
                {
                    var obj = new ApprovalRouteOffObj()
                    {
                        APPROVER_ID = model.APPROVER_ID,
                        MENUID      = model.MENUID,
                        PRIORITY    = model.PRIORITY,
                        PID         = model.PID,
                        EVENTTYPE   = eventInsert,
                        USERID      = User.Identity.Name
                    };
                    //SessionHelper.GetRvHead(Session).AddItem(obj);
                    var rst = rv.PostRouteOfficer(obj, 1);
                    if (rst != null && rst.RespCode != 0)
                    {
                        msg = rst.RespMessage; // "Revenue Code Already exist. Duplicate Record is not allowed.";
                        return(Json(new { RespCode = 1, RespMessage = msg }, JsonRequestBehavior.AllowGet));
                    }
                    var w    = rv.GetRouteOfficer(User.Identity.Name); // GetRvHeadLines().ToList();
                    var html = PartialView("_ViewRouteOfficer", w).RenderToString();
                    msg = "Record Added to List";
                    return(Json(new { data_html = html, RespCode = 0, RespMessage = msg }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    var obj = new ApprovalRouteOffObj()
                    {
                        APPROVER_ID = model.APPROVER_ID,
                        MENUID      = model.MENUID,
                        PRIORITY    = model.PRIORITY,
                        USERID      = User.Identity.Name,
                        DB_ITBID    = model.DB_ITBID,
                        PID         = model.PID,
                        EVENTTYPE   = model.DB_ITBID > 0 ? eventEdit : eventInsert,
                    };
                    OutPutObj rst;
                    rst = rv.PostRouteOfficer(obj, 2);
                    if (rst != null && rst.RespCode != 0)
                    {
                        msg = rst.RespMessage; // "Revenue Code Already exist. Duplicate Record is not allowed.";
                        return(Json(new { RespCode = 1, RespMessage = msg }, JsonRequestBehavior.AllowGet));
                    }
                    //SessionHelper.GetRvHead(Session).UpdateItem(obj);
                    // rv.PostRevenueHead(obj, 2);
                    var w    = rv.GetRouteOfficer(User.Identity.Name); // GetRvHeadLines().ToList();
                    var html = PartialView("_ViewRouteOfficer", w).RenderToString();
                    msg = "Record Updated to List";
                    return(Json(new { data_html = html, RespCode = 0, RespMessage = msg }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                return(Json(new { RespCode = 1, RespMessage = msg }, JsonRequestBehavior.AllowGet));
            }
        }