| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- 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;
- /// <summary>
- ///Naireclass 的摘要说明
- /// </summary>
- public class Naireclass
- {
- private static string constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["constr"].ToString();
- public Naireclass()
- {
- //
- //TODO: 在此处添加构造函数逻辑
- //
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="uid"></param>
- /// <param name="nid"></param>
- /// <returns></returns>
- 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;
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="uid"></param>
- /// <param name="nid"></param>
- /// <returns></returns>
- 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";
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sqls"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="username"></param>
- /// <param name="password"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="ROWGUID"></param>
- /// <returns></returns>
- 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;
- }
- }
|