Esempio n. 1
0
    public static ReturnObject DoExport(string filters, bool is_filter)
    {
        masters_branch page_object   = new masters_branch();
        ReturnObject   return_object = new ReturnObject();
        DBConnection   db_connection = new DBConnection();
        DataTable      branch_data   = new DataTable();
        DateTime       now           = DateTime.Now;
        int            export_limit  = Convert.ToInt32(ConfigurationManager.AppSettings["EXPORT_LIMIT"]);

        string[] column_names = new string[] { };

        string
            query = string.Empty, file_name = string.Empty;

        try
        {
            query = page_object.GetBaseQuery();

            if (is_filter)
            {
                query = page_object.GetFilterQuery(filters, query);
            }

            query += " Group by b.BranchCode, b.BranchName, c.CompanyCode, c.CompanyName, b.BranchAddress, b.PhoneNo, b.FaxNo, b.Email) a where row > 0 and row < " + export_limit;

            branch_data = db_connection.ReturnDataTable(query);

            if (branch_data.Rows.Count > 0)
            {
                file_name = page_object.CreateExport(branch_data);

                return_object.status      = "success";
                return_object.return_data = file_name;
            }
            else
            {
                return_object.status      = "info";
                return_object.return_data = "No data found with the selected filters. Please try again with different filters.";
            }
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_DATA_FOR_EXPORT");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while generating your report. Please try again. If the error persists, please contact Support.";

            throw;
        }
        finally
        {
            page_object.Dispose();
        }

        return(return_object);
    }
Esempio n. 2
0
    public static ReturnObject GetBranchData(int page_number, bool is_filter, string filters)
    {
        masters_branch page_object       = new masters_branch();
        DBConnection   db_connection     = new DBConnection();
        DataTable      branch_data_table = new DataTable();
        ReturnObject   return_object     = new ReturnObject();
        int            start_row         = (page_number - 1) * 30;
        int            number_of_record  = page_number * 30 + 1;
        string         query             = string.Empty;

        try
        {
            query = page_object.GetBaseQuery();

            if (is_filter)
            {
                query = page_object.GetFilterQuery(filters, query);
            }

            query += " Group by b.BranchCode, b.BranchName, c.CompanyCode, c.CompanyName, b.BranchAddress, b.PhoneNo, b.FaxNo, b.Email,b.HrIncharge,b.AlternativeHrIncharge) a where row > " + start_row + " and row < " + number_of_record;

            branch_data_table = db_connection.ReturnDataTable(query);

            return_object.status      = "success";
            return_object.return_data = JsonConvert.SerializeObject(branch_data_table, Formatting.Indented);
        }
        catch (Exception ex)
        {
            Logger.LogException(ex, page, "GET_BRANCH_DATA");

            return_object.status      = "error";
            return_object.return_data = "An error occurred while loading Branch Data. Please try again. If the error persists, please contact Support.";

            throw;
        }

        return(return_object);
    }