Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //抓值
            string cAccount  = Request["Account"];
            string cPassword = Request["Password"];

            clsConn       clsConn = new clsConn();
            SqlConnection Conn    = clsConn.GetConnection();

            RPaWorkLibrary.Encryption RPa_EN = new RPaWorkLibrary.Encryption();
            //這段要寫認證機制Start--------------------------------
            string sAccount  = Request["Account"];
            string sPassword = Request["Password"];

            string     sCheckPsw    = "SELECT cPassword FROM DEF_UserBook WHERE cAccount = @Account";
            SqlCommand sc_CheckUser = new SqlCommand(sCheckPsw, Conn);
            sc_CheckUser.Parameters.Add(new SqlParameter("@Account", SqlDbType.NVarChar));

            sc_CheckUser.Parameters["@Account"].Value = sAccount;

            SqlDataReader sdr_CheckUser;
            sdr_CheckUser = sc_CheckUser.ExecuteReader();
            DataTable dt_CheckUser = new DataTable();
            dt_CheckUser.Load(sdr_CheckUser);


            if (dt_CheckUser.Rows.Count <= 0)
            {
                Response.Write("<script>alert('帳號或密碼輸入錯誤');</script>");
                Response.Write("<script>location.href='Default.aspx';</script>");
                Response.End();
            }

            string sEncryptionPws = RPa_EN.EnCodeString(sPassword);

            if (dt_CheckUser.Rows[0]["cPassword"].ToString() != sEncryptionPws)
            {
                Response.Write("<script>alert('帳號或密碼輸入錯誤');</script>");
                Response.Write("<script>location.href='Default.aspx';</script>");
                Response.End();
            }

            //認證中....
            //這段要寫認證機制End----------------------------------
            Session["Account"] = cAccount;
            Response.Write("<script>window.parent.location.reload();</script>");
        }
        catch (Exception ex)
        {
            throw new Exception("帳號驗證時發生錯誤 - " + ex.Message);
        }
    }
Ejemplo n.º 2
0
        private string getGameList(string AssignMonth)
        {
            if (AssignMonth == "")
            {
                AssignMonth = DateTime.Now.ToString("yyyy/MM");
            }
            else
            {
                AssignMonth = DateTime.Now.ToString("yyyy/") + AssignMonth;
            }


            string LastUpdateTime = "最後更新日期:2018/05/22 ";
            string sMyReply       = "本月遊戲清單\n";

            RPaWorkLibrary.MSSQL      RM = new RPaWorkLibrary.MSSQL();
            RPaWorkLibrary.Encryption RE = new RPaWorkLibrary.Encryption();
            DataTable dtGameList;

            try
            {
                RM.ServerName   = RE.EnCodeString(System.Configuration.ConfigurationManager.AppSettings["DBServer"]);
                RM.DataBaseName = RE.EnCodeString(System.Configuration.ConfigurationManager.AppSettings["DBDataBase"]);
                RM.DB_Id        = RE.EnCodeString(System.Configuration.ConfigurationManager.AppSettings["DBId"]);
                RM.DB_Psw       = RE.EnCodeString(System.Configuration.ConfigurationManager.AppSettings["DBPws"]);

                try
                {
                    DateTime LastDay = Convert.ToDateTime(AssignMonth + "/01").AddMonths(1).AddDays(-Convert.ToDateTime(AssignMonth + "/01").AddMonths(1).Day);

                    string WhereString = " AND dSaleDate >= '" + AssignMonth + "/01' ";
                    WhereString += " AND dSaleDate <= '" + AssignMonth + "/" + LastDay.ToString("dd") + "' ";
                    dtGameList   = RM.Get_DataTable("SELECT * FROM GameList WHERE 1 = 1 " + WhereString);

                    if (dtGameList.Rows.Count == 0)
                    {
                        return("此月無發售遊戲(" + LastUpdateTime + ")");
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("【撈資料發生問題】" + ex.Message);
                }


                try
                {
                    foreach (DataRow dr in dtGameList.Rows)
                    {
                        string sLanguage = "";
                        string sSaleDate = dr["dSaleDate"].ToString();

                        if (dr["sLanguage"].ToString().Trim() != "中")
                        {
                            sLanguage = "(" + dr["sLanguage"].ToString().Trim() + ")";
                        }

                        sMyReply += Convert.ToDateTime(sSaleDate).ToString("yyyy/MM/dd") + " " + dr["sName"].ToString().TrimEnd() + sLanguage + " \n";
                    }

                    return(sMyReply + LastUpdateTime);
                }
                catch (Exception ex)
                {
                    throw new Exception("【組合文字訊息發生錯誤】" + ex.Message);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("本月遊戲清單執行錯誤 - " + ex.Message);
            }
        }
Ejemplo n.º 3
0
    /// <summary>
    /// 送出註冊資訊後的值做處理
    /// </summary>
    /// <returns></returns>
    private bool InsertUserInfo()
    {
        RPaWorkLibrary.Encryption EN = new RPaWorkLibrary.Encryption();


        SortedList <string, string> slUserInfo = new SortedList <string, string>();

        slUserInfo.Add("Account", Request["Account"]);
        slUserInfo.Add("Password", EN.EnCodeString(Request["Password"]));
        slUserInfo.Add("RealName", Request["RealName"]);
        slUserInfo.Add("Email", Request["Email"]);
        slUserInfo.Add("MobilePhone", Request["MobilePhone"]);
        slUserInfo.Add("PasswordCheck", Request["PasswordCheck"]);
        slUserInfo.Add("Sex", Request["Sex"]);
        slUserInfo.Add("Address", Request["Address"]);

        //string InsertFields = "";
        //string InsertValues = "";

        //for (int i = 0; i <= slUserInfo.Keys.Count - 1; i++)
        //{
        //    InsertFields += slUserInfo.Keys[i]
        //}
        StringBuilder sb = new StringBuilder();

        sb.AppendLine(@"INSERT [dbo].[DEF_UserBook](
                        cAccount,cPassword,cRealName,cPowerLevel,mMoney,cEmail,cAttestation,
                        cMobilePhone,cAddress,mSex,dRegisteredTime
                        )
                        Values(
                        @cAccount,@cPassword,@cRealName,@cPowerLevel,@mMoney,@cEmail,@cAttestation,
                        @cMobilePhone,@cAddress,@mSex,@dRegisteredTime
                        )
        ");
        SqlCommand InsertCom = new SqlCommand(sb.ToString(), Conn);

        InsertCom.Parameters.Add(new SqlParameter("@cAccount", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@cPassword", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@cRealName", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@cPowerLevel", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@mMoney", SqlDbType.Int));
        InsertCom.Parameters.Add(new SqlParameter("@cEmail", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@cAttestation", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@cMobilePhone", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@cAddress", SqlDbType.NVarChar));
        InsertCom.Parameters.Add(new SqlParameter("@mSex", SqlDbType.Int));
        InsertCom.Parameters.Add(new SqlParameter("@dRegisteredTime", SqlDbType.DateTime));

        InsertCom.Parameters["@cAccount"].Value        = slUserInfo["Account"];
        InsertCom.Parameters["@cPassword"].Value       = slUserInfo["Password"];
        InsertCom.Parameters["@cRealName"].Value       = slUserInfo["RealName"];
        InsertCom.Parameters["@cPowerLevel"].Value     = "Customer";
        InsertCom.Parameters["@mMoney"].Value          = 0;
        InsertCom.Parameters["@cEmail"].Value          = slUserInfo["Email"];
        InsertCom.Parameters["@cAttestation"].Value    = slUserInfo["Account"] + "_" + Guid.NewGuid().ToString();
        InsertCom.Parameters["@cMobilePhone"].Value    = slUserInfo["MobilePhone"];
        InsertCom.Parameters["@cAddress"].Value        = slUserInfo["Address"];
        InsertCom.Parameters["@mSex"].Value            = slUserInfo["Sex"];
        InsertCom.Parameters["@dRegisteredTime"].Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

        //InsertCom.ExecuteNonQuery();

        return(true);
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string        sFunctionName = Request["FunctionName"];
        SqlConnection Conn          = clsConn.GetConnection();

        RPaWorkLibrary.Encryption RPa_EN = new RPaWorkLibrary.Encryption();

        switch (sFunctionName)
        {
        case "AccountApply":

            string sInputAccount = Request["CheckValue"];
            string sSql          = "SELECT cAccount FROM DEF_UserBook WHERE cAccount = @Account";

            SqlCommand sc = new SqlCommand(sSql, Conn);

            sc.Parameters.Add(new SqlParameter("@Account", SqlDbType.NVarChar));

            sc.Parameters["@Account"].Value = sInputAccount;

            SqlDataReader sdr;
            sdr = sc.ExecuteReader();

            DataTable dt = new DataTable();
            dt.Load(sdr);

            if (dt.Rows.Count <= 0)
            {
                Response.Write("OK");
            }
            else
            {
                Response.Write("此帳號已重複");
            }

            sc.Dispose();
            sdr.Dispose();
            dt.Dispose();

            break;


        case "CheckUser":

            string sAccount  = Request["CheckAcc"];
            string sPasswoed = Request["CheckPsw"];

            string     sCheckPsw    = "SELECT cPassword FROM DEF_UserBook WHERE cAccount = @Account";
            SqlCommand sc_CheckUser = new SqlCommand(sCheckPsw, Conn);
            sc_CheckUser.Parameters.Add(new SqlParameter("@Account", SqlDbType.NVarChar));

            sc_CheckUser.Parameters["@Account"].Value = sAccount;

            SqlDataReader sdr_CheckUser;
            sdr_CheckUser = sc_CheckUser.ExecuteReader();
            DataTable dt_CheckUser = new DataTable();
            dt_CheckUser.Load(sdr_CheckUser);


            if (dt_CheckUser.Rows.Count <= 0)
            {
                Response.Write("帳號或密碼輸入錯誤");
                break;
            }

            string sEncryptionPws = RPa_EN.EnCodeString(sPasswoed);

            if (dt_CheckUser.Rows[0]["cPassword"].ToString() != sEncryptionPws)
            {
                Response.Write("帳號或密碼輸入錯誤");
                break;
            }

            Response.Write("OK");

            break;

        default:
            Response.Write("錯誤的參數名稱");

            break;
        }
    }