using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
//
using System.Data;
using System.Data.SqlClient;
using DotNet.FrameWork.Data;
/// <summary>
/// Summary description for DataHelpService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class DataHelpService : System.Web.Services.WebService {

    public DataHelpService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
    [WebMethod(Description = "判断用户手机号是否存在")]
    public int ExitsUserPhone(string userphone)
    {
        string strsql = "select count(Ht_customerId) from Ht_customerExtensionBase where Ht_mobile='"+userphone+"'" ;
        int i = (int)DotNet.FrameWork.Data.DbHelperSQL.GetSingle(strsql);
        return i;
    }
    [WebMethod(Description = "如果用户存在修改状态")]
    public void ExitsUpdateUserPhone(string userphone)
    {
        string strsql = "update Ht_customerExtensionBase set ht_state='1' where Ht_mobile='" + userphone + "'";
        DotNet.FrameWork.Data.DbHelperSQL.ExecuteSql(strsql);
    }
    [WebMethod(Description = "获取签到用户")]
    public DataSet GetAllStateCustomer()
    {
        string strsql = "select * from   Ht_customerExtensionBase where ht_state='1'";
        return DotNet.FrameWork.Data.DbHelperSQL.GetDataSet(strsql);
    }
    [WebMethod(Description = "注册用户信息")]
    public int AddCustomer(string username, string email, string phone, string customername)
    {
        SqlParameter[] Parameters ={
                                       new SqlParameter("@name", SqlDbType.VarChar),new SqlParameter("@sex", SqlDbType.Int),new SqlParameter("@telephone", SqlDbType.VarChar),new SqlParameter("@email", SqlDbType.VarChar),new SqlParameter("@mobile", SqlDbType.VarChar), new SqlParameter("@corpName", SqlDbType.VarChar),new SqlParameter("@department", SqlDbType.VarChar),new SqlParameter("@duties", SqlDbType.VarChar),new SqlParameter("@address", SqlDbType.VarChar),new SqlParameter("@postcode", SqlDbType.VarChar),new SqlParameter("@fax", SqlDbType.VarChar),new SqlParameter("@isaddIT", SqlDbType.Int)
                                   };
                                   Parameters[0].Value=username;
                                   Parameters[1].Value = 1;
                                   Parameters[2].Value = null;
                                    Parameters[3].Value=email;
                                    Parameters[4].Value = phone;
                                    Parameters[5].Value = customername;
                                    Parameters[6].Value = null;
                                    Parameters[7].Value = null;
                                    Parameters[8].Value = null;
                                    Parameters[9].Value = null;
                                    Parameters[10].Value = null;
                                    Parameters[11].Value = 1;
                                    int icount;
                                    int i = DbHelperSQL.RunProcedure("ht_RegCustomer", Parameters,out icount);
                                    return icount;
    }
    [WebMethod(Description = "用户发表问题")]
    public int AddCustomerQuestion(string userphone,string question)
    {
        string strsql = "insert into ht_CustomerQusestion(QusMobile,Qustion,qverfiy)values('" + userphone + "','" + question + "','0')";
        int i = (int)DotNet.FrameWork.Data.DbHelperSQL.ExecuteSqlInt(strsql);
        return i;
    }
    [WebMethod(Description = "获取单条数据详细信息")]
    public DataSet GetOneCustomerQuestion(string questionid)
    {
        string strsql = "select [qid],[qguid] ,[QusMobile],[Qustion],[QusDateTime],[ClickTime] from [ht_CustomerQusestion] where [qid]='" + questionid + "'";
        DataSet ds = DbHelperSQL.GetDataSet(strsql);
        return ds;
    }
    [WebMethod(Description = "获取所有用户发表问题")]
    public DataSet GetAllCustomerQuestion()
    {
        string strsql = "select [qid],[qguid] ,[QusMobile],[Qustion],[QusDateTime],[ClickTime] from [ht_CustomerQusestion]";
        DataSet ds = DbHelperSQL.GetDataSet(strsql);
        return ds;
    }
    [WebMethod(Description = "获取用户的发表问题")]
    public DataSet GetCustomerQuestion(int iveryfiy)
    {
        string strsql = "select [qid],[qguid] ,[QusMobile],[Qustion],[QusDateTime],[ClickTime] from [ht_CustomerQusestion] where [qverfiy]='" + iveryfiy+ "'";
        DataSet ds = DbHelperSQL.GetDataSet(strsql);
        return ds;
    }
    [WebMethod(Description = "更新问题是否允许显示")]
    public int UpdateCustomerQuestion(string questionid)
    {
        string strsql = "update [ht_CustomerQusestion] set [qverfiy]=1 where [qid] in ("+questionid+")";
        int icount= DbHelperSQL.ExecuteSqlInt(strsql);
        return icount;
    }
    [WebMethod(Description = "更新热点问题点击次数")]
    public int UpdateHotCustomerQuestion(string hotnum,string questionid)
    {
        string strsql = "update [ht_CustomerQusestion] set [ClickTime]='" + hotnum + "' where [qid]='" + questionid + "'";
        int icount = DbHelperSQL.ExecuteSqlInt(strsql);
        return icount;
    }
    [WebMethod(Description = "获取热点问题排序")]
    public DataSet GetHotCustomerQuestion()
    {
        string strsql = "select [qid],[qguid] ,[QusMobile],[Qustion],[QusDateTime],[ClickTime] from [ht_CustomerQusestion] where [qverfiy]=1 order by [ClickTime] desc";
        DataSet ds = DbHelperSQL.GetDataSet(strsql);
        return ds;
    }
    [WebMethod(Description = "获取最新问题排序")]
    public DataSet GetNewCustomerQuestion()
    {
        string strsql = "select [qid],[qguid] ,[QusMobile],[Qustion],[QusDateTime],[ClickTime] from [ht_CustomerQusestion] where [qverfiy]=1 order by [qid] desc";
        DataSet ds = DbHelperSQL.GetDataSet(strsql);
        return ds;
    }
    [WebMethod(Description = "获取试题题目和选项")]
    public DataSet GetCustomerProblem(int cptype, int cpid)
    {
        string strsql = "select ProTitle,ProAnswerA,ProAnswerB,ProAnswerC,ProAnswerD,ProAnswer,ProcImg from ht_CustomerProblems where cptype=" + cptype + " and ProID=" + cpid;
        DataSet ds = DbHelperSQL.GetDataSet(strsql);
        return ds;
    }
    [WebMethod(Description = "判断用户是否已经参加闯关游戏")]
    public int ExitsUserGame(string userphone, int cpType)
    {
        string strsql = "select count(cpmid) from [ht_CustomerProblemsmark] where [Mobile]='" + userphone + "' and cptype='"+cpType+"'";
        int i = (int)DotNet.FrameWork.Data.DbHelperSQL.GetSingle(strsql);
        return i;
    }
    [WebMethod(Description = "增加用户参加闯关信息")]
    public int AddUserGame(string userphone, int cpType)
    {
        string strsql = "insert into [ht_CustomerProblemsmark](mobile,cptype) values('"+userphone+"','"+cpType+"')";
        int i = (int)DotNet.FrameWork.Data.DbHelperSQL.ExecuteSqlInt(strsql);
        return i;
    }
}
