示例#1
0
    public string get_approve_work_form_list()
    {
        string function_code_list = Request["function_code_list"];

        if (string.IsNullOrEmpty(function_code_list))
        {
            return(new AjaxErrorResult("function_code_list不能为空").ToString());
        }

        string type = Request["type"];
        string page = Request["page"];

        StringBuilder str_table        = new StringBuilder();
        StringBuilder str_table_column = new StringBuilder();
        List <string> list             = function_code_list.Split("_".ToCharArray()).ToList();

        for (int i = 0; i < list.Count; i++)
        {
            string function_code = list[i];

            H5Objects        o           = GData.GetObject(Convert.ToInt32(function_code));
            List <H5Columns> list_column = GData.GetColumn(Convert.ToInt32(function_code));

            if (i > 0)
            {
                str_table_column.Append("  union all ");
            }

            str_table_column.Append(" select ");
            str_table_column.Append(o.HO_ID_FIELD + " as id");
            str_table_column.Append("," + o.HO_USER_FIELD + " as user_id");
            str_table_column.Append(",dbo.fn_convert_datetime(" + o.HO_DATE_FIELD + ") as date");
            str_table_column.Append("," + o.HO_STAUTS_FIELD + " as status");
            str_table_column.Append("," + o.HO_MASTER_FIELD + " as master");
            str_table_column.Append("," + o.HO_DATE_FIELD + " as create_date ");
            str_table_column.Append("," + o.HO_BUSINESS_TYPE + " as business");
            str_table_column.Append("," + "'" + o.HO_NAME + "'" + " as business_text");
            str_table_column.Append("  from " + o.HO_TABLE_NAME + "");
        }

        str_table.Append("(" + str_table_column.ToString() + ") as sp_view");



        //H5Objects o = GData.GetObject(Convert.ToInt32(function_code));
        //List<H5Columns> list_column = GData.GetColumn(Convert.ToInt32(function_code));
        List <SqlParameter> list_para       = new List <SqlParameter>();
        List <SqlParameter> list_para_count = new List <SqlParameter>();
        StringBuilder       strsql          = new StringBuilder();
        StringBuilder       str_column      = new StringBuilder();

        StringBuilder str_where = new StringBuilder();
        StringBuilder str_order = new StringBuilder();
        StringBuilder str_count = new StringBuilder();

        //我的发起
        if (type == "me")
        {
            str_where.Append(" and user_id=@user_id");
            list_para.Add(new SqlParameter("@user_id", Cookies.UserCode));
            list_para_count.Add(new SqlParameter("@user_id", Cookies.UserCode));
        }

        //我的审批
        if (type == "other")
        {
            str_table.Append(" inner join SP_WORK_FOLLOW on WF_BUSINESS_TYPE=business and WF_BUSINESS_KEY=id ");
            str_where.Append(" and WF_TO_USER=@WF_TO_USER");
            list_para.Add(new SqlParameter("@WF_TO_USER", Cookies.UserCode));
            list_para_count.Add(new SqlParameter("@WF_TO_USER", Cookies.UserCode));
        }

        str_order.Append(" order by create_date desc");


        SqlConnection cn_count = comm_fun.get_cn();
        string        count    = "0";

        try
        {
            str_count.Append("select " + "count(1)" + "  from " + str_table.ToString() + " where 1=1 " + str_where);
            count = comm_fun.ExecuteScalar(str_count.ToString(), cn_count, list_para_count);
        }
        catch (Exception ex)
        {
            comm_fun.WriteLog(ex.ToString());
            count = "0";
        }
        finally
        {
            comm_fun.CloseConnection(cn_count);
        }

        int SAO_PAGE_SIZE    = 20;
        int SAO_CURRENT_PAGE = Convert.ToInt32(page);


        str_column.Append("id");
        str_column.Append(",user_id");
        str_column.Append(",date");
        str_column.Append(",status");
        str_column.Append(",master");
        str_column.Append(",business");
        str_column.Append(",business_text");
        if (type == "other")
        {
            str_column.Append(",WF_STATUS");
        }


        strsql.Append("select top " + SAO_PAGE_SIZE + "  " + str_column.ToString() + "  from " + str_table.ToString() + " where 1=1");
        strsql.Append(" and id not in (select top " + (SAO_CURRENT_PAGE * SAO_PAGE_SIZE).ToString() + " id  " + "  from " + str_table.ToString() + " where 1=1 " + str_where.ToString() + "  " + str_order.ToString() + ")" + str_where.ToString() + "  " + str_order.ToString());



        DataTable     dt = new DataTable();
        SqlConnection cn = comm_fun.get_cn();

        try
        {
            dt = comm_fun.GetDatatable(strsql.ToString(), cn, list_para);
            if (dt.Rows.Count > 0)
            {
                dt.Columns.Add("user_name");
                dt.Columns.Add("user_image");
                dt.Columns.Add("status_name");
                dt.Columns.Add("status_class");

                foreach (DataRow dr in dt.Rows)
                {
                    dr["user_name"]  = get_user_name(dr["user_id"].ToString());
                    dr["user_image"] = GData.get_user_image(dr["user_id"].ToString());

                    dr["status_name"]  = GData.get_status_name(dr["status"].ToString());
                    dr["status_class"] = GData.get_status_class(dr["status"].ToString());
                }
            }
        }
        catch (Exception ex)
        {
            comm_fun.WriteLog(ex.ToString());
        }
        if (dt.Rows.Count > 0)
        {
            return(new AjaxDataResult(dt).ToString());
        }
        else
        {
            return(new AjaxErrorResult("").ToString());
        }
    }
示例#2
0
    public string get_work_form_list()
    {
        string function_code = Request["function_code"];

        if (string.IsNullOrEmpty(function_code))
        {
            return(new AjaxErrorResult("function_code不能为空").ToString());
        }
        FunctionCode = Convert.ToInt32(function_code);

        string page = Request["page"];

        if (string.IsNullOrEmpty(page))
        {
            return(new AjaxErrorResult("page不能为空").ToString());
        }

        H5Objects           o           = GData.GetObject(Convert.ToInt32(function_code));
        List <H5Columns>    list_column = GData.GetColumn(Convert.ToInt32(function_code));
        List <SqlParameter> list_para   = new List <SqlParameter>();
        StringBuilder       strsql      = new StringBuilder();
        StringBuilder       str_column  = new StringBuilder();

        StringBuilder str_where = new StringBuilder();
        StringBuilder str_order = new StringBuilder();
        StringBuilder str_count = new StringBuilder();

        str_where.Append(" and " + o.HO_USER_FIELD + "=@" + o.HO_USER_FIELD);
        str_order.Append(" order by " + o.HO_DATE_FIELD + " desc");
        list_para.Add(new SqlParameter("@" + o.HO_USER_FIELD, Cookies.UserCode));

        SqlConnection cn_count = comm_fun.get_cn();
        string        count    = "0";

        try
        {
            str_count.Append("select " + "count(1)" + "  from " + o.HO_TABLE_NAME + " where 1=1 " + str_where);
            count = comm_fun.ExecuteScalar(str_count.ToString(), cn_count, list_para);
        }
        catch (Exception ex)
        {
            comm_fun.WriteLog(ex.ToString());
            count = "0";
        }
        finally
        {
            comm_fun.CloseConnection(cn_count);
        }

        int SAO_PAGE_SIZE    = 20;
        int SAO_CURRENT_PAGE = Convert.ToInt32(page);


        str_column.Append(o.HO_ID_FIELD + " as id");
        str_column.Append("," + o.HO_USER_FIELD + " as user_id");
        str_column.Append(",dbo.fn_convert_datetime(" + o.HO_DATE_FIELD + ") as date");
        str_column.Append("," + o.HO_STAUTS_FIELD + " as status");
        str_column.Append("," + o.HO_MASTER_FIELD + " as master");

        strsql.Append("select top " + SAO_PAGE_SIZE + "  " + str_column.ToString() + "  from " + o.HO_TABLE_NAME + " where 1=1");
        strsql.Append(" and " + o.HO_ID_FIELD + "  not in (select top " + (SAO_CURRENT_PAGE * SAO_PAGE_SIZE).ToString() + " " + o.HO_ID_FIELD + "   " + "  from " + o.HO_TABLE_NAME + " where 1=1 " + str_where.ToString() + "  " + str_order.ToString() + ")" + str_where.ToString() + "  " + str_order.ToString());



        DataTable     dt = new DataTable();
        SqlConnection cn = comm_fun.get_cn();

        try
        {
            dt = comm_fun.GetDatatable(strsql.ToString(), cn, list_para);
            if (dt.Rows.Count > 0)
            {
                dt.Columns.Add("user_name");
                dt.Columns.Add("user_image");
                dt.Columns.Add("status_name");
                dt.Columns.Add("status_class");

                foreach (DataRow dr in dt.Rows)
                {
                    dr["user_name"]  = get_user_name(dr["user_id"].ToString());
                    dr["user_image"] = GData.get_user_image(dr["user_id"].ToString());

                    dr["status_name"]  = GData.get_status_name(dr["status"].ToString());
                    dr["status_class"] = GData.get_status_class(dr["status"].ToString());
                }
            }
        }
        catch (Exception ex)
        {
            comm_fun.WriteLog(ex.ToString());
        }
        if (dt.Rows.Count > 0)
        {
            return(new AjaxDataResult(dt).ToString());
        }
        else
        {
            return(new AjaxErrorResult("").ToString());
        }
    }