Exemplo n.º 1
0
    /// <summary>
    /// 存入中獎名單
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        PetaPoco.Sql sql = PetaPoco.Sql.Builder;
        sql.Append(string.Format("UPDATE {0} SET {1}='1' WHERE {2} IN (SELECT MAX({2}) FROM {0} WHERE {4} IN ({3}) GROUP BY {4})", TableName, WinFlagColumn, PKColumn, Session["DrawIDs"], DistinctColumn));
        patwGridView1.Visible = false;
        btnExport.Visible     = false;
        btnSave.Visible       = false;
        db.Execute(sql);

        PatwCommon.RegisterClientScriptAlert(this.Page, "存入成功");
        Query();
    }
Exemplo n.º 2
0
    protected void btnLogin_Click(object sender, System.EventArgs e)
    {
        string strAccount  = this.txtAct.Text.Trim();
        string strPassword = this.txtPWD.Text.Trim();
        string strVCode    = this.VCode.Text.Trim();

        if ((!(strVCode == Convert.ToString(Session["ValidateCode"]))))
        {
            VCode.Text = "";
            PatwCommon.RegisterClientScriptAlert(this, "認證碼錯誤");
        }
        else
        {
            checkLogin(strAccount, strPassword);
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// 檢查登入並設定 Session
    /// </summary>
    /// <param name="acct"></param>
    /// <param name="pw"></param>
    private void checkLogin(string acct, string pw)
    {
        // 取得 AppSettings 中後台登入相關設定 檔案:web.config
        string strDefaultAct = "" + System.Configuration.ConfigurationManager.AppSettings["BackendLoginAct"];
        string strDefaultPwd = "" + System.Configuration.ConfigurationManager.AppSettings["BackendLoginPwd"];

        string strBackendSession = "" + System.Configuration.ConfigurationManager.AppSettings["BackendSession"];

        // 檢查是否為預設帳號
        if (strDefaultAct == acct && strDefaultPwd == pw)
        {
            Session[strBackendSession] = acct;
            Response.Redirect("~/BM/Main.aspx");
        }
        else
        {
            PatwCommon.RegisterClientScriptAlert(this, "帳號或密碼錯誤!");
        }
    }
Exemplo n.º 4
0
    /// <summary>
    /// 主要查詢方法
    /// </summary>
    /// <param name="page">頁數(預設為 1)</param>
    /// <param name="NewDraw">重新抽獎(預設為 false)</param>
    /// <param name="ExportMode">匯出模式。(預設為 false)若為真,則取消分頁。</param>
    private void Query(long page = 1, bool NewDraw = false, bool ExportMode = false)
    {
        patwGridView1.Visible = false;
        btnSave.Visible       = false;
        btnExport.Visible     = false;

        string DistinctSQLStatement = "";

        if (Session["DrawIDs"] == null || NewDraw)
        {
            // 抽出結果
            DrawResult result = MakeDraw(int.Parse(tbDrawCount.Text), MaxDrawQuota, PKColumn, WinFlagColumn, DistinctColumn, TableName, BasicCondition, IsGroup);

            // 若發生異常,無法抽出
            if (!result.Result)
            {
                PatwCommon.RegisterClientScriptAlert(this, result.Msg);
                return;
            }
            else // 正常抽出
            {
                patwGridView1.Visible = true;
                btnSave.Visible       = false;
                btnExport.Visible     = true;

                // 排除重複後的名單
                DistinctSQLStatement = result.Msg;
                // 塞入 Session
                Session["DrawIDs"] = result.Msg;
            }
        }
        else
        {
            patwGridView1.Visible = true;
            btnSave.Visible       = false;
            btnExport.Visible     = true;

            // 排除重複後的名單
            DistinctSQLStatement = Convert.ToString(Session["DrawIDs"]);
        }

        // 組成 SQL 指令, 僅取上面抽出的那幾筆名單
        sql.Append(String.Format("SELECT * FROM {0}", TableName));
        sql.Append(String.Format("WHERE 1=1 AND {0} IN (SELECT MAX({0}) FROM {1} WHERE {3} IN ({2}) {4} GROUP BY {3})", PKColumn, TableName, DistinctSQLStatement, DistinctColumn, BasicCondition));

        if (!ExportMode)
        {
            var data = db.Page <DataModel_a12SupauCheckin>(page, PageSize, sql);
            patwGridView1.DataSource = data.Items;
            patwGridView1.DataBind();

            AspNetPager1.PageSize    = (int)data.ItemsPerPage;
            AspNetPager1.RecordCount = (int)data.TotalItems;
            lbTotal.Text             = "依據條件,目前共有 " + data.TotalItems.ToString() + " 筆";
        }
        else
        {
            var data = db.Query <DataModel_a12SupauCheckin>(sql);
            patwGridView1.DataSource = data;
            patwGridView1.DataBind();

            AspNetPager1.Visible = false;
            lbTotal.Text         = "依據條件,目前共有 " + data.Count() + " 筆";
        }
    }