Exemplo n.º 1
0
    public static DataTable findProductName(string name, string userId)
    {
        DataSet ds = DemandApplyReportSrv.findProductName(name, userId);

        if (ds == null)
        {
            return(null);
        }

        DataTable dt = new DataTable();

        dt.Columns.Add("value", Type.GetType("System.String"));
        dt.Columns.Add("target", Type.GetType("System.String"));

        int index = 0;

        if (ds.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                DataRow dr = dt.NewRow();

                dr["value"]  = row["name"];
                dr["target"] = row["name"];

                dt.Rows.Add(dr);
            }
        }
        else
        {
            ds = DemandApplyReportSrv.findProductName(userId);

            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                return(null);
            }

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (index >= 5)
                {
                    break;
                }

                if (PinYinHelper.ContainsFirstLetter(row["name"].ToString(), name))
                {
                    DataRow dr = dt.NewRow();

                    dr["value"]  = row["name"];
                    dr["target"] = row["name"];

                    dt.Rows.Add(dr);

                    index++;
                }
            }
        }

        return(dt);
    }
Exemplo n.º 2
0
    public static string find(string name, string q, string userId)
    {
        DataSet ds = new DataSet();

        if (name == "findHospitalName")
        {
            ds = DemandApplyReportSrv.findHospitalName(q, userId);
        }
        else if (name == "findProductName")
        {
            ds = DemandApplyReportSrv.findProductName(q, userId);
        }
        else if (name == "findInformer")
        {
            ds = DemandApplyReportSrv.findInformer();
        }
        else if (name == "findSpec")
        {
            ds = DemandApplyReportSrv.findSpec(q);
        }
        else if (name == "findUnit")
        {
            ds = DemandApplyReportSrv.findUnit(q);
        }
        else if (name == "findAgentName")
        {
            ds = DeliverApplyReportSrv.findAgent(q, userId);
        }


        if (ds == null)
        {
            return("");
        }

        DataTable dt = new DataTable();

        dt.Columns.Add("value", Type.GetType("System.String"));
        dt.Columns.Add("target", Type.GetType("System.String"));

        if (ds.Tables[0].Rows.Count > 0)
        {
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (q != "" && name != "findUnit" && name != "findSpec" && name != "findInformer" && name != "findAgentName")
                {
                    if (PinYinHelper.IsEqual(row[0].ToString(), q) ||
                        row[0].ToString().Trim().Contains(q)
                        )
                    {
                        DataRow dr = dt.NewRow();
                        dr["value"]  = row[0];
                        dr["target"] = row[0];
                        dt.Rows.Add(dr);
                    }
                }
                else if (name == "findInformer")
                {
                    if (PinYinHelper.IsEqual(row[0].ToString(), q) ||
                        row[0].ToString().Trim().Contains(q)
                        )
                    {
                        DataRow dr = dt.NewRow();
                        dr["value"]  = row[1];
                        dr["target"] = row[0];
                        dt.Rows.Add(dr);
                    }
                }
                else
                {
                    DataRow dr = dt.NewRow();
                    dr["value"]  = row[0];
                    dr["target"] = row[0];
                    dt.Rows.Add(dr);
                }
            }
        }
        if (dt == null)
        {
            return("");
        }
        return(JsonHelper.DataTable2Json(dt));
    }