using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data.SqlClient;
using System.Data;
using ServiceReference;
///
///Naireclass 的摘要说明
///
public class Naireclass
{
private static string constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["constr"].ToString();
public Naireclass()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
///
///
///
///
///
///
public static bool IsHasCarry(string uid, string nid)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT ID FROM Q_Answer WHERE Uid=" + uid + " AND Nid=" + nid + "", con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
///
///
///
///
///
///
public static string backnum(string sqls)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(sqls, con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["count"].ToString() ;
}
else
{
return "0";
}
}
///
///
///
///
///
public static DataTable backdatas(string sqls)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(sqls, con);
sda.Fill(dt);
con.Close();
return dt;
}
///
///
///
///
///
///
public static bool checkusername(string username, string password)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT ID FROM Q_User WHERE name='" + username + "' AND psword='" + password + "'", con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
return true;
}
else
{
return false;
}
}
public static int RecordResult(string uid, string nid, string val)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
SqlCommand cmd = new SqlCommand("exec sp_NaireAnswer " + uid + "," + nid + ",'" + val + "'", con);
int i = cmd.ExecuteNonQuery();
con.Close();
return i;
}
///
///
///
///
///
public static string CheckROWGUID(string ROWGUID)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT ID,ROWGUID FROM Q_Naire WHERE ROWGUID='" + ROWGUID + "'", con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["ID"].ToString();
}
else
{
IPowerMettersService services= new PowerMettersServiceClient();
con.Open();
SqlCommand cmd = new SqlCommand("insert into Q_Naire(ROWGUID,title,descr) values('" + ROWGUID + "','" + services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "") + "','" + services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "") + "')", con); ///services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "")
//SqlCommand cmd = new SqlCommand("insert into Q_Naire(ROWGUID,title,descr) values('" + ROWGUID + "','" + ROWGUID + "','" + ROWGUID + "')", con); ///services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "")
int num= cmd.ExecuteNonQuery();
con.Close();
if (num > 0)
{
con.Open();
DataTable dts = new DataTable();
SqlDataAdapter sdas = new SqlDataAdapter("SELECT ID,ROWGUID FROM Q_Naire WHERE ROWGUID='" + ROWGUID + "'", con);
sdas.Fill(dts);
con.Close();
return dts.Rows[0]["ID"].ToString();
}
else
{
return "0";
}
}
}
public static string CheckROWGUIDone(string ROWGUID)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT ID,ROWGUID FROM Q_Naire WHERE ROWGUID='" + ROWGUID + "'", con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["ID"].ToString();
}
else
{
IPowerMettersService services = new PowerMettersServiceClient();
con.Open();
//SqlCommand cmd = new SqlCommand("insert into Q_Naire(ROWGUID,title,descr) values('" + ROWGUID + "','" + services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "") + "','" + services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "") + "')", con); ///services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "")
SqlCommand cmd = new SqlCommand("insert into Q_Naire(ROWGUID,title,descr) values('" + ROWGUID + "','" + ROWGUID + "','" + ROWGUID + "')", con); ///services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "")
int num = cmd.ExecuteNonQuery();
con.Close();
if (num > 0)
{
con.Open();
DataTable dts = new DataTable();
SqlDataAdapter sdas = new SqlDataAdapter("SELECT ID,ROWGUID FROM Q_Naire WHERE ROWGUID='" + ROWGUID + "'", con);
sdas.Fill(dts);
con.Close();
return dts.Rows[0]["ID"].ToString();
}
else
{
return "0";
}
}
}
public static string CheckROWGUIDones(string ROWGUID,string q_name)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT ID,ROWGUID FROM Q_Naire WHERE ROWGUID='" + ROWGUID + "'", con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["ID"].ToString();
}
else
{
IPowerMettersService services = new PowerMettersServiceClient();
con.Open();
//SqlCommand cmd = new SqlCommand("insert into Q_Naire(ROWGUID,title,descr) values('" + ROWGUID + "','" + services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "") + "','" + services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "") + "')", con); ///services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "")
SqlCommand cmd = new SqlCommand("insert into Q_Naire(ROWGUID,title,descr) values('" + ROWGUID + "','" + q_name + "','" + q_name + "')", con); ///services.GetPowerMattersDetailByRowID(ROWGUID).QL_NAME.Replace("$", "")
int num = cmd.ExecuteNonQuery();
con.Close();
if (num > 0)
{
con.Open();
DataTable dts = new DataTable();
SqlDataAdapter sdas = new SqlDataAdapter("SELECT ID,ROWGUID FROM Q_Naire WHERE ROWGUID='" + ROWGUID + "'", con);
sdas.Fill(dts);
con.Close();
return dts.Rows[0]["ID"].ToString();
}
else
{
return "0";
}
}
}
public static string CheckROWGUIDS(string ROWGUID)
{
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT ID,ROWGUID FROM Q_Naire WHERE ROWGUID='" + ROWGUID + "'", con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["ID"].ToString();
}
else
{
return "0";
}
}
public static string getcutnum(string nid)
{
string cutnum="";
SqlConnection con = new SqlConnection(constr);
con.Open();
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("SELECT floor(count(id)/6) as cutnum FROM Q_Answer WHERE Nid=" + nid + "", con);
sda.Fill(dt);
con.Close();
if (dt.Rows.Count > 0)
{
cutnum=dt.Rows[0]["cutnum"].ToString();
}
else
{
cutnum="";
}
return cutnum;
}
}