コード例 #1
0
        public JsonResult GetBatchLists()
        {
            string LoginUser   = (string)Session["LoginSAPID"];
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string EmployerId  = (string)Session["EMPLOYER_ID"];
            string CompanyName = (string)Session["CompanyName"];
            string _access_key = ConfigurationManager.AppSettings["Salt"];

            try
            {
                Employer.Employer employer = new Employer.Employer();

                DataTable dt = employer.FetchStatementEmployerBatch(CompanyName, EmployerId, userkey, uid);
                dt.TableName = "EmployerBatch";
                dt.Columns.ToString();

                var batches = (from DataRow dr in dt.Rows
                               select new
                {
                    ID = CryptoEngine.EncryptString(dr["Category ID"].ToString(), _access_key),
                    BatchName = dr["StmtBatchName"].ToString(),
                    AddressId = CryptoEngine.EncryptString(dr["Address ID"].ToString(), _access_key),
                }).ToList();

                return(Json(new { data = batches }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "StatementOptions/GetBatchLists", "StatementOptions", "GetBatchLists", "FetchInternalUsers Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public JsonResult GetBatchList3([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, String batchId, String addressId)
        {
            string LoginUser   = (string)Session["LoginSAPID"];
            string userkey     = ConfigurationManager.AppSettings["userkey"];
            string uid         = ConfigurationManager.AppSettings["uid"];
            string CompanyName = (string)Session["CompanyName"];

            string WebUserID   = (string)Session["WebUserID"];
            string EMPLOYER_ID = (string)Session["EMPLOYER_ID"];

            try
            {
                Employer.Employer employer = new Employer.Employer();
                DataTable         dt       = employer.FetchStatementEmployerBatch(CompanyName, EMPLOYER_ID, userkey, uid);
                dt.TableName = "StatementEmployerBatch";
                dt.Columns.ToString();

                List <BatchList> batches = new List <BatchList>();
                int startRec             = requestModel.Start;
                int pageSize             = requestModel.Length;

                List <BatchList> batchCount = (from DataRow dr in dt.Rows
                                               select new BatchList()
                {
                    ID = dr["Category ID"].ToString(),
                }).ToList();

                batches = (from DataRow dr in dt.Rows
                           select new BatchList()
                {
                    ID = dr["Category ID"].ToString(),
                    AddressId = dr["Address ID"].ToString(),
                    BatchName = dr["StmtBatchName"].ToString(),
                    RecipientName = dr["Receipient Name"].ToString(),
                    Phone = dr["Phone Number"].ToString(),
                    RecipientName2 = dr["Recepient 2"].ToString(),
                    Phone2 = dr["Phone 2"].ToString(),
                    Address = dr["Statement Address 2"].ToString(),
                    State = dr["State"].ToString(),
                    LGA = dr["LGA"].ToString()
                }).Skip(startRec).Take(pageSize).ToList();

                var totalCount    = batchCount.Count();
                var filteredCount = batches.Count();

                if (requestModel.Search.Value != string.Empty)
                {
                    var value = requestModel.Search.Value.ToLower().Trim();

                    batchCount = (from DataRow dr in dt.Rows
                                  where dr["StmtBatchName"].ToString().ToLower().Contains(value)
                                  select new BatchList()
                    {
                        ID = dr["Category ID"].ToString(),
                    }).ToList();

                    batches = (from DataRow dr in dt.Rows
                               where dr["StmtBatchName"].ToString().ToLower().Contains(value)
                               select new BatchList()
                    {
                        ID = dr["Category ID"].ToString(),
                        AddressId = dr["Address ID"].ToString(),
                        BatchName = dr["StmtBatchName"].ToString(),
                        RecipientName = dr["Receipient Name"].ToString(),
                        Phone = dr["Phone Number"].ToString(),
                        RecipientName2 = dr["Recepient 2"].ToString(),
                        Phone2 = dr["Phone 2"].ToString(),
                        Address = dr["Statement Address 2"].ToString(),
                        State = dr["State"].ToString(),
                        LGA = dr["LGA"].ToString()
                    }).Skip(startRec).Take(pageSize).ToList();

                    totalCount    = batchCount.Count();
                    filteredCount = batches.Count();
                }

                var sortedColumns = requestModel.Columns.GetSortedColumns();
                var orderByString = String.Empty;

                foreach (var column in sortedColumns)
                {
                    orderByString += orderByString != String.Empty ? "," : "";
                    orderByString += (column.Data) + (column.SortDirection == Column.OrderDirection.Ascendant ? " asc" : " desc");
                }

                var data = batches.Select(emList => new
                {
                    ID             = emList.ID,
                    AddressId      = emList.AddressId,
                    BatchName      = emList.BatchName,
                    RecipientName  = emList.RecipientName,
                    Phone          = emList.Phone,
                    RecipientName2 = emList.RecipientName2,
                    Phone2         = emList.Phone2,
                    Address        = emList.Address,
                    State          = emList.State,
                    LGA            = emList.LGA,
                }).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, totalCount, totalCount), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                LogError logerror = new LogError();
                logerror.ErrorLog("", LoginUser, "", "StatementOptions/GetBatchList3", "StatementOptions", "GetBatchList3", "FetchStatementEmployerBatch Error", ex.Message.ToString(), 0);
                return(Json(new { data = "Error has occured" }, JsonRequestBehavior.AllowGet));
            }
        }