예제 #1
0
        public string DataAnalyzeResult(string message)
        {
            message = message.Trim();
            DBManager dbMana      = new DBManager();
            string    analyResult = "";

            GetsqlOrder(message);

            if (sqlOrder == null)
            {
                analyResult = "SOH#00#NO#EOT";
            }
            else
            {
                switch (sqlOrder)
                {
                case "01":
                {
                    if (dbMana.Insert(sqlStr))
                    {
                        analyResult = "SOH#10#OK#EOT";
                    }
                    else
                    {
                        analyResult = "SOH#10#NO#EOT";
                    }
                    break;
                }

                case "02":
                {
                    if (dbMana.Delete(sqlStr))
                    {
                        analyResult = "SOH#20#OK#EOT";
                    }
                    else
                    {
                        analyResult = "SOH#20#NO#EOT";
                    }
                    break;
                }

                case "03":
                {
                    DataTable dt = dbMana.Select(sqlStr);
                    if (dt != null)
                    {
                        string columncount = dt.Columns.Count.ToString();
                        foreach (DataRow row in dt.Rows)        //遍历查询信息
                        {
                            foreach (DataColumn column in dt.Columns)
                            {
                                analyResult = analyResult + column.ColumnName + "%" + row[column].ToString() + "%";
                            }
                        }
                        analyResult = "SOH#30#" + analyResult + columncount + "#EOT";
                    }
                    else
                    {
                        analyResult = "SOH#30#NO#EOT";
                    }
                    break;
                }

                case "04":
                {
                    if (dbMana.Update(sqlStr))
                    {
                        analyResult = "SOH#40#OK#EOT";
                    }
                    else
                    {
                        analyResult = "SOH#40#NO#EOT";
                    }
                    break;
                }

                default:
                    break;
                }
            }

            return(analyResult);
        }