//
        // GET: /DELIVEREDBY/Delete/by id
        public ActionResult Delete(int id)
        {
            try
            {
                _boSIMREG_DELIVEREDBY = new BOSIMREG_DELIVEREDBY();

                var sIMREG_DELIVEREDBY = _boSIMREG_DELIVEREDBY.GetSIMREG_DELIVEREDBY(id);
                if (sIMREG_DELIVEREDBY != null)
                {
                    var sIMREG_DELIVEREDBYViewModel = new SIMREG_DELIVEREDBYViewModel
                    {
                        DELIVEREDBYID = sIMREG_DELIVEREDBY.DELIVEREDBYID,
                        TITLE = sIMREG_DELIVEREDBY.TITLE,
                        USERNAME = sIMREG_DELIVEREDBY.USERNAME,
                        //IDATE = sIMREG_DELIVEREDBY.IDATE,
                        //IUSER = sIMREG_DELIVEREDBY.IUSER,
                        //EDATE = sIMREG_DELIVEREDBY.EDATE,
                        //EUSER = sIMREG_DELIVEREDBY.EUSER
                    };

                    return PartialView("_Delete", sIMREG_DELIVEREDBYViewModel);
                }
                else
                {
                    return PartialView("_Error", "Could not found, your request data.");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex);
                return PartialView("_Error", ex);
            }
        }
        public ActionResult Edit(SIMREG_DELIVEREDBYViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _boSIMREG_DELIVEREDBY = new BOSIMREG_DELIVEREDBY();

                    var sIMREG_DELIVEREDBY = _boSIMREG_DELIVEREDBY.GetSIMREG_DELIVEREDBY(model.DELIVEREDBYID);

                    if (sIMREG_DELIVEREDBY != null)
                    {
                        sIMREG_DELIVEREDBY.DELIVEREDBYID = model.DELIVEREDBYID;
                        sIMREG_DELIVEREDBY.TITLE = model.TITLE;
                        sIMREG_DELIVEREDBY.USERNAME = model.USERNAME;
                        //sIMREG_DELIVEREDBY.IDATE = model.IDATE;
                        //sIMREG_DELIVEREDBY.IUSER = model.IUSER;
                        sIMREG_DELIVEREDBY.EDATE = DateTime.Now;
                        sIMREG_DELIVEREDBY.EUSER = model.EUSER;
                        sIMREG_DELIVEREDBY.IsNew = false;

                        _boSIMREG_DELIVEREDBY.Save(sIMREG_DELIVEREDBY);

                        return Content(Boolean.TrueString);
                    }
                    else
                    {
                        return Content("Could not found, your request data.");
                    }
                }

                return Content(ExceptionHelper.ModelStateErrorFormat(ModelState));
            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex);
                return Content("Sorry! Unable to edit this data.");
            }
        }
        //
        // GET: /NEWFORM/Edit/by id
        public ActionResult Edit(int id)
        {
            try
            {
                _boSIMREG_NEWFORM = new BOSIMREG_NEWFORM();
                _boSIMREG_REQUESTEDBY = new BOSIMREG_REQUESTEDBY();
                _boSIMREG_REQUESTEDTYPE = new BOSIMREG_REQUESTEDTYPE();
                _boSIMREG_DELIVEREDBY = new BOSIMREG_DELIVEREDBY();

                var sIMREG_NEWFORM = _boSIMREG_NEWFORM.GetSIMREG_NEWFORM(id);
                if (sIMREG_NEWFORM != null)
                {

                    var sIMREG_REQUESTEDBYList = SelectListItemExtension.PopulateDropdownList(_boSIMREG_REQUESTEDBY.GetSIMREG_REQUESTEDBYs().ToList<BESIMREG_REQUESTEDBY>(), "REQUESTEDBYID", "TITLE", isEdit: true, selectedValue: sIMREG_NEWFORM != null ? sIMREG_NEWFORM.REQUESTEDBYID.ToString() : "0").ToList();

                    var sIMREG_REQUESTEDTYPEList = SelectListItemExtension.PopulateDropdownList(_boSIMREG_REQUESTEDTYPE.GetSIMREG_REQUESTEDTYPEs().ToList<BESIMREG_REQUESTEDTYPE>(), "REQUESTEDTYPEID", "TITLE", isEdit: true, selectedValue: sIMREG_NEWFORM != null ? sIMREG_NEWFORM.REQUESTEDTYPEID.ToString() : "0").ToList();

                    var sIMREG_DELIVEREDBYList = SelectListItemExtension.PopulateDropdownList(_boSIMREG_DELIVEREDBY.GetSIMREG_DELIVEREDBYs().ToList<BESIMREG_DELIVEREDBY>(), "DELIVEREDBYID", "TITLE", isEdit: true, selectedValue: sIMREG_NEWFORM != null ? sIMREG_NEWFORM.DELIVEREDBYID.ToString() : "0").ToList();

                    var sIMREG_NEWFORMViewModel = new SIMREG_NEWFORMViewModel
                    {
                        ID = sIMREG_NEWFORM.ID,
                        MSISDNID = sIMREG_NEWFORM.MSISDNID,
                        //MSISDNTITLE = _boSIMREG_MSISDN.GetSIMREG_MSISDN(sIMREG_NEWFORM.MSISDNID).TITLE,
                        MSISDNTITLE = sIMREG_NEWFORM.MSISDNTITLE,
                        REQUESTEDDATE = sIMREG_NEWFORM.REQUESTEDDATE,
                        REQUESTEDBYID = sIMREG_NEWFORM.REQUESTEDBYID,
                        REQUESTEDBYTITLE = _boSIMREG_REQUESTEDBY.GetSIMREG_REQUESTEDBY(sIMREG_NEWFORM.REQUESTEDBYID).TITLE,
                        REQUESTEDTYPEID = sIMREG_NEWFORM.REQUESTEDTYPEID,
                        REQUESTEDTYPETITLE = _boSIMREG_REQUESTEDTYPE.GetSIMREG_REQUESTEDTYPE(sIMREG_NEWFORM.REQUESTEDTYPEID).TITLE,
                        DELIVEREDBYDATE = sIMREG_NEWFORM.DELIVEREDBYDATE,
                        DELIVEREDBYID = sIMREG_NEWFORM.DELIVEREDBYID,
                        DELIVEREDBYTITLE = _boSIMREG_DELIVEREDBY.GetSIMREG_DELIVEREDBY(sIMREG_NEWFORM.DELIVEREDBYID).TITLE,
                        IDATE = sIMREG_NEWFORM.IDATE,
                        IUSER = sIMREG_NEWFORM.IUSER,
                        EDATE = sIMREG_NEWFORM.EDATE,
                        EUSER = sIMREG_NEWFORM.EUSER,
                        ddlREQUESTEDBYS = sIMREG_REQUESTEDBYList,
                        ddlREQUESTEDTYPES = sIMREG_REQUESTEDTYPEList,
                        //ddlDELIVEREDBYS = sIMREG_DELIVEREDBYList
                    };

                    return PartialView("_Edit", sIMREG_NEWFORMViewModel);
                }
                else
                {
                    return PartialView("_Error", "Could not found, your request data.");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex);
                return PartialView("_Error", ex);
            }
        }
        //private List<SIMREG_NEWFORMViewModel> GetNEWFORMDataList(string msisdnTitle, string requestById, string requestTypeId, string deliverById, string fromDate, string toDate)
        private List<SIMREG_NEWFORMViewModel> GetNEWFORMDataList(string sidx, string sord, int page, int rows, string msisdnTitle, string requestById, string requestTypeId, string deliverById, string requestFromDate, string requestToDate, string deliverFromDate, string deliverToDate)
        {
            _boSIMREG_NEWFORM = new BOSIMREG_NEWFORM();
            _boSIMREG_REQUESTEDBY = new BOSIMREG_REQUESTEDBY();
            _boSIMREG_REQUESTEDTYPE = new BOSIMREG_REQUESTEDTYPE();
            _boSIMREG_DELIVEREDBY = new BOSIMREG_DELIVEREDBY();

            if (!String.IsNullOrEmpty(requestFromDate))
            {
                requestFromDate = Convert.ToDateTime(requestFromDate).ToString("dd-MMM-yyyy");
            }

            if (!String.IsNullOrEmpty(requestToDate))
            {
                requestToDate = Convert.ToDateTime(requestToDate).ToString("dd-MMM-yyyy");
            }

            if (!String.IsNullOrEmpty(deliverFromDate))
            {
                deliverFromDate = Convert.ToDateTime(deliverFromDate).ToString("dd-MMM-yyyy");
            }

            if (!String.IsNullOrEmpty(deliverToDate))
            {
                deliverToDate = Convert.ToDateTime(deliverToDate).ToString("dd-MMM-yyyy");
            }

            List<SIMREG_NEWFORMViewModel> modellist = new List<SIMREG_NEWFORMViewModel>();

            var sIMREG_NEWFORMList = _boSIMREG_NEWFORM.GetSIMREG_NEWFORMs(sidx, sord, page, rows, msisdnTitle, requestById, requestTypeId, deliverById, requestFromDate, requestToDate, deliverFromDate, deliverToDate).ToList();

            modellist = sIMREG_NEWFORMList.Select(x => new SIMREG_NEWFORMViewModel
            {

                ID = x.ID,
                MSISDNID = x.MSISDNID,
                //MSISDNTITLE = _boSIMREG_MSISDN.GetSIMREG_MSISDN(x.MSISDNID).TITLE,
                MSISDNTITLE = x.MSISDNTITLE,
                REQUESTEDDATE = x.REQUESTEDDATE,
                REQUESTEDBYID = x.REQUESTEDBYID,
                REQUESTEDBYTITLE = _boSIMREG_REQUESTEDBY.GetSIMREG_REQUESTEDBY(x.REQUESTEDBYID).TITLE,
                REQUESTEDTYPEID = x.REQUESTEDTYPEID,
                REQUESTEDTYPETITLE = _boSIMREG_REQUESTEDTYPE.GetSIMREG_REQUESTEDTYPE(x.REQUESTEDTYPEID).TITLE,
                DELIVEREDBYDATE = x.DELIVEREDBYDATE,
                DELIVEREDBYID = x.DELIVEREDBYID,
                DELIVEREDBYTITLE = _boSIMREG_DELIVEREDBY.GetSIMREG_DELIVEREDBY(x.DELIVEREDBYID).TITLE,
                IDATE = x.IDATE,
                IUSER = x.IUSER,
                EDATE = x.EDATE,
                EUSER = x.EUSER

            }).ToList();

            return modellist;
        }
        //[HttpPost]
        //public ActionResult ExportToExcel(List<SIMREG_NEWFORMViewModel> modelList)
        //{
        //    try
        //    {
        //        if (modelList.Count > 0)
        //        {
        //            var modelDataTable = ConvertHelper.ConvertToDataTable<SIMREG_NEWFORMViewModel>(modelList);
        //            //ExportHelper exportHelper = new ExportHelper("SimRegisterReport.csv", true);
        //            //string expData = exportHelper.ExportData(modelDataTable, System.Web.HttpContext.Current.Response);
        //            //return File(new System.Text.UTF8Encoding().GetBytes(expData), "text/csv", "Report123.csv");
        //            return Content(Boolean.TrueString);
        //        }
        //        else
        //        {
        //            return Content("Sorry! Unable to export null data.");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return Content(ExceptionHelper.ExceptionMessageFormat(ex));
        //    }
        //}
        //
        // GET: /NEWFORM/Details/by id
        public ActionResult Details(int id)
        {
            try
            {
                _boSIMREG_NEWFORM = new BOSIMREG_NEWFORM();
                _boSIMREG_REQUESTEDBY = new BOSIMREG_REQUESTEDBY();
                _boSIMREG_REQUESTEDTYPE = new BOSIMREG_REQUESTEDTYPE();
                _boSIMREG_DELIVEREDBY = new BOSIMREG_DELIVEREDBY();

                var sIMREG_NEWFORM = _boSIMREG_NEWFORM.GetSIMREG_NEWFORM(id);
                if (sIMREG_NEWFORM != null)
                {
                    var sIMREG_NEWFORMViewModel = new SIMREG_NEWFORMViewModel
                    {
                        ID = sIMREG_NEWFORM.ID,
                        MSISDNID = sIMREG_NEWFORM.MSISDNID,
                        //MSISDNTITLE = _boSIMREG_MSISDN.GetSIMREG_MSISDN(sIMREG_NEWFORM.MSISDNID).TITLE,
                        MSISDNTITLE = sIMREG_NEWFORM.MSISDNTITLE,
                        REQUESTEDDATE = sIMREG_NEWFORM.REQUESTEDDATE,
                        REQUESTEDBYID = sIMREG_NEWFORM.REQUESTEDBYID,
                        REQUESTEDBYTITLE = _boSIMREG_REQUESTEDBY.GetSIMREG_REQUESTEDBY(sIMREG_NEWFORM.REQUESTEDBYID).TITLE,
                        REQUESTEDTYPEID = sIMREG_NEWFORM.REQUESTEDTYPEID,
                        REQUESTEDTYPETITLE = _boSIMREG_REQUESTEDTYPE.GetSIMREG_REQUESTEDTYPE(sIMREG_NEWFORM.REQUESTEDTYPEID).TITLE,
                        DELIVEREDBYDATE = sIMREG_NEWFORM.DELIVEREDBYDATE,
                        DELIVEREDBYID = sIMREG_NEWFORM.DELIVEREDBYID,
                        DELIVEREDBYTITLE = _boSIMREG_DELIVEREDBY.GetSIMREG_DELIVEREDBY(sIMREG_NEWFORM.DELIVEREDBYID).TITLE,
                        IDATE = sIMREG_NEWFORM.IDATE,
                        IUSER = sIMREG_NEWFORM.IUSER,
                        EDATE = sIMREG_NEWFORM.EDATE,
                        EUSER = sIMREG_NEWFORM.EUSER
                    };

                    return PartialView("_Details", sIMREG_NEWFORMViewModel);
                }
                else
                {
                    return PartialView("_Error", "Could not found, your request data.");
                }

            }
            catch (Exception ex)
            {
                ExceptionHelper.ExceptionMessageFormat(ex);
                return PartialView("_Error", ex);
            }
        }