コード例 #1
0
 protected void ClearResult_Click(object sender, EventArgs e)
 {
     try
     {
         Lib.Center.Account_c acc = (Lib.Center.Account_c)Session["Account"];
         Lib.DataUtility du = new Lib.DataUtility();
         du.executeNonQueryBysp("Race_ClearData");
         Lib.SysSetting.AddLog("清除競賽成績", acc.Account, "競賽成績已被清除", DateTime.Now);
         ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('已清除競賽成績')", true);
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "')", true);
     }
 }
コード例 #2
0
 protected void submit_Click(object sender, EventArgs e)
 {
     Lib.Center.Account_c acc = new Lib.Center.Account_c(txtName.Text.Trim(), txtPwd.Text.Trim());
     if (acc.LoginStatus == Lib.Center.LoginStatus.Logout)
     {
         Lib.SysSetting.AddLog("登入", txtName.Text, "進階使用者登入密碼驗證失敗,登入IP : " + Request.UserHostAddress.ToString(), DateTime.Now);
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('登入失敗')", true);
     }
     if (acc.LoginStatus == Lib.Center.LoginStatus.Login)
     {
         Session["account"] = acc;
         Lib.SysSetting.AddLog("登入", acc.Account, "進階使用者登入成功,登入IP : " + Request.UserHostAddress.ToString(), DateTime.Now);
         Response.Redirect("~/Index.aspx");
     }
 }
コード例 #3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if ((CheckBoxList1.Items[0].Selected == true && CheckBoxList1.Items[1].Selected == true) ||
            (CheckBoxList1.Items[0].Selected == false && CheckBoxList1.Items[1].Selected == false))
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('請單選一類模式')", true);
        }
        else
        {
            if (string.IsNullOrEmpty(txtRemoteIP.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('請輸入遠端主機位址,若為本機模式請輸入127.0.0.1')", true);
            }
            else
            { 
                //進行更新資料庫資料
                string mode_value = string.Empty;
                if (CheckBoxList1.Items[0].Selected)
                {
                    mode_value = CheckBoxList1.Items[0].Value;
                }
                else
                {
                    mode_value = CheckBoxList1.Items[1].Value;
                }
                if (Session["Account"] != null)
                {
                    Lib.Center.Account_c acc = (Lib.Center.Account_c)Session["Account"];

                    Lib.DataUtility du = new Lib.DataUtility();
                    du.executeNonQueryByText("update sysvalue set value = '" + mode_value + "' where item = 'exchange'");
                    du.executeNonQueryByText("update sysvalue set value = '" + txtRemoteIP.Text.Trim() + "' where item = 'remote_ip'");
                    Lib.SysSetting.AddLog("更新競賽系統設定值", acc.Account, "競賽系統設定值已被更改", DateTime.Now);
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('更新成功')", true);
                    ShowSystemMode();
                    //Response.Redirect("~/index.aspx");
                }
                else
                {
                    Response.Redirect("~/Login.aspx");
                }
            }
        }
    }
コード例 #4
0
 protected void btnSwitch_Click(object sender, EventArgs e)
 {
     Lib.DataUtility du = new Lib.DataUtility();
     try
     {
         if (Session["Account"] != null)
         {
             Lib.Center.Account_c acc = (Lib.Center.Account_c)Session["Account"];
             du.executeNonQueryBysp("SwitchSystem");
             Lib.SysSetting.AddLog("更新系統模式", acc.Account, LB_mode.Text + "已被切換", DateTime.Now);
         }
         else
         {
             Response.Redirect("~/Login.aspx");
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "')", true);
     }
     ShowSystemMode();
 }
コード例 #5
0
 //新增帳號
 protected void btn_AddAccount_Click(object sender, EventArgs e)
 {
     //檢查必填欄位有無空白
     if (!string.IsNullOrEmpty(txtAcc.Text) && !string.IsNullOrEmpty(txtID.Text) && !string.IsNullOrEmpty(txtPwd.Text) &&
         !string.IsNullOrEmpty(txtName.Text) && !string.IsNullOrEmpty(txtRank.Text))
     {
         //檢查帳號有無重複
         Lib.DataUtility du    = new Lib.DataUtility();
         DataTable       AccDt = du.getDataTableByText("select account from Account_c where account='" + txtAcc.Text + "'");
         if (AccDt.Rows.Count == 0)
         {
             //檢查id是否有註冊過帳號
             DataTable IdDt = du.getDataTableByText("select id from Account_c where id='" + txtID.Text + "' and role_code='" + roleType.SelectedValue + "'");
             if (IdDt.Rows.Count == 0)
             {
                 Lib.Center.Account_c        a = (Lib.Center.Account_c)Session["account"];
                 Dictionary <string, object> d = new Dictionary <string, object>();
                 d.Add("account", txtAcc.Text.Trim());
                 d.Add("password", txtPwd.Text.Trim());
                 d.Add("rold_code", roleType.SelectedValue); // 3 = 鑑測站主任代碼, 4 = 鑑測官代碼
                 d.Add("name", txtName.Text.Trim());
                 d.Add("id", txtID.Text.Trim());
                 d.Add("rank_code", txtRank.Text.Trim());
                 d.Add("tel", txtTel.Text.Trim());
                 d.Add("cellphone", txtCell.Text.Trim());
                 d.Add("mail", txtMail.Text.Trim());
                 d.Add("ip", txtIP.Text.Trim());
                 d.Add("pwdChange", "0");
                 d.Add("status", "1");
                 d.Add("byAcc", ((Lib.Center.Account_c)Session["account"]).Account);
                 du.executeNonQueryByText("insert into account_c (account,password,role_code,name,id,rank_code,tel,cellphone,mail,ip,pwdChange,status,byAcc) values (@account,@password,@rold_code,@name,@id,@rank_code,@tel,@cellphone,@mail,@ip,@pwdChange,@status,@byAcc)", d);
                 Lib.SysSetting.AddLog("帳號管理", a.Account, "新增帳號:" + txtAcc.Text.Trim(), System.DateTime.Now);
                 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('新增成功');", true);
                 txtAcc.Text                 = "";
                 txtPwd.Text                 = "";
                 txtName.Text                = "";
                 txtID.Text                  = "";
                 txtRank.Text                = "";
                 txtTel.Text                 = "";
                 txtCell.Text                = "";
                 txtMail.Text                = "";
                 txtIP.Text                  = "";
                 txb_checkId.Text            = "";
                 tabconatiner.ActiveTabIndex = 0;
                 DropDownList1.DataBind();
                 this.div_inq.Style.Value  = "";
                 this.div_data.Style.Value = "display:none";
             }
             else
             {
                 if (roleType.SelectedValue == "3")
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('此身份證字號已註冊過「鑑測主任」之帳號,無法再新增!!');", true);
                 }
                 else
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('此身份證字號已註冊過「鑑測官」之帳號,無法再新增!!');", true);
                 }
             }
         }
         else
         {
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('帳號重複,無法使用!!');", true);
         }
     }
     else
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('帳號、姓名、身份證字號、密碼、級職代碼欄位不可空白!!');", true);
     }
 }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
        }
        if (Page.IsPostBack)
        {
            var v = submitType.Value;
            Lib.Center.Account_c        a  = (Lib.Center.Account_c)Session["account"];
            Dictionary <string, object> d  = new Dictionary <string, object>();
            Lib.DataUtility             du = new Lib.DataUtility();
            try
            {
                switch (v)
                {
                case "add":
                    #region 新增帳號管理員
                    d.Clear();
                    d.Add("acc", txtAcc.Text.Trim());
                    DataTable dt = du.getDataTableBysp("CheckAccExist", d);
                    if (dt.Rows.Count == 0)
                    {
                        d.Add("account", txtAcc.Text.Trim());
                        d.Add("password", txtPwd.Text.Trim());
                        d.Add("rold_code", roleType.SelectedValue);     // 3 = 鑑測站主任代碼, 4 = 鑑測官代碼
                        d.Add("name", txtName.Text.Trim());
                        d.Add("id", txtID.Text.Trim());
                        // d.Add("unit_code", txtUnit.Text.Trim());
                        d.Add("rank_code", txtRank.Text.Trim());
                        d.Add("tel", txtTel.Text.Trim());
                        d.Add("cellphone", txtCell.Text.Trim());
                        d.Add("mail", txtMail.Text.Trim());
                        d.Add("ip", txtIP.Text.Trim());
                        d.Add("pwdChange", "0");
                        d.Add("status", "1");
                        d.Add("byAcc", ((Lib.Center.Account_c)Session["account"]).Account);
                        du.executeNonQueryByText("insert into account_c (account,password,role_code,name,id,rank_code,tel,cellphone,mail,ip,pwdChange,status,byAcc) values (@account,@password,@rold_code,@name,@id,@rank_code,@tel,@cellphone,@mail,@ip,@pwdChange,@status,@byAcc)", d);
                        Lib.SysSetting.AddLog("帳號管理", a.Account, "新增帳號:" + txtAcc.Text.Trim(), System.DateTime.Now);
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('新增成功');", true);
                        txtAcc.Text  = "";
                        txtPwd.Text  = "";
                        txtName.Text = "";
                        txtID.Text   = "";
                        //txtUnit.Text = "";
                        txtRank.Text = "";
                        txtTel.Text  = "";
                        txtCell.Text = "";
                        txtMail.Text = "";
                        txtIP.Text   = "";
                        tabconatiner.ActiveTabIndex = 0;
                        DropDownList1.DataBind();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('帳號已存在請使用其他帳號');", true);
                        txtAcc.Text  = "";
                        txtPwd.Text  = "";
                        txtName.Text = "";
                        txtID.Text   = "";
                        //txtUnit.Text = "";
                        txtRank.Text = "";
                        txtTel.Text  = "";
                        txtCell.Text = "";
                        txtMail.Text = "";
                        txtIP.Text   = "";
                        tabconatiner.ActiveTabIndex = 0;
                    }
                    #endregion
                    break;

                case "update":
                    #region 更新帳號管理員
                    d.Add("password", _txtPwd.Text.Trim());
                    d.Add("name", _txtName.Text.Trim());
                    d.Add("id", _txtID.Text.Trim());
                    // d.Add("unit_code", _txtUnit.Text.Trim());
                    d.Add("rank_code", _txtRank.Text.Trim());
                    d.Add("tel", _txtTel.Text.Trim());
                    d.Add("cellphone", _txtCell.Text.Trim());
                    d.Add("mail", _txtMail.Text.Trim());
                    d.Add("ip", _txtIP.Text.Trim());
                    d.Add("account", DropDownList1.SelectedValue);
                    du.executeNonQueryByText("update account_c set password = @password, name = @name, id = @id, rank_code = @rank_code, tel = @tel, cellphone = @cellphone, mail = @mail, ip = @ip where account = @account", d);
                    Lib.SysSetting.AddLog("帳號管理", a.Account, "更新帳號:" + DropDownList1.SelectedValue, System.DateTime.Now);
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新成功');", true);
                    #endregion
                    break;

                case "delete":
                    #region
                    d.Add("account", DropDownList1.SelectedValue);
                    du.executeNonQueryBysp("DelAccount", d);
                    Lib.SysSetting.AddLog("帳號管理", a.Account, "刪除帳號:" + DropDownList1.SelectedValue, System.DateTime.Now);
                    _txtName.Text = "";
                    _txtID.Text   = "";
                    _txtPwd.Text  = "";
                    _txtRank.Text = "";
                    _txtTel.Text  = "";
                    _txtMail.Text = "";
                    _txtCell.Text = "";
                    _txtIP.Text   = "";
                    _txtFun.Text  = "";
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('成功刪除');", true);
                    DropDownList1.Items.Remove(DropDownList1.SelectedItem);
                    DropDownList1_OnDataBound(DropDownList1, e);
                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
                Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
            }
            d.Clear();
            submitType.Value = "";
        }
    }
コード例 #7
0
ファイル: Pro.aspx.cs プロジェクト: Proview-KUMA/108ARMY
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if ((Lib.Center.Account_c)Session["account"] != null)
            {
                Lib.Center.Account_c acc = (Lib.Center.Account_c)Session["account"];
                txtName.Text = acc.Name;
                txtID.Text   = acc.ID;
                txtPwd.Text  = acc.Password;
                pwd_HF.Value = acc.Password;
                txtRank.Text = acc.Rank_Code;
                txtTel.Text  = acc.Tel;
                txtCell.Text = acc.Cell;
                txtMail.Text = acc.Mail;
                txtIP.Text   = acc.IP;
            }
        }
        else
        {
            if ((Lib.Center.Account_c)Session["account"] != null)
            {
                Lib.Center.Account_c        acc = (Lib.Center.Account_c)Session["account"];
                Lib.DataUtility             du  = new Lib.DataUtility();
                Dictionary <string, object> d   = new Dictionary <string, object>();
                try
                {
                    if (submitType.Value == "profile")
                    {
                        d.Add("id", txtID.Text.Trim());
                        d.Add("name", txtName.Text.Trim());
                        d.Add("pwd", txtPwd.Text.Trim());
                        d.Add("rank", txtRank.Text.Trim());
                        d.Add("tel", txtTel.Text.Trim());
                        d.Add("cell", txtCell.Text.Trim());
                        d.Add("mail", txtMail.Text.Trim());
                        d.Add("ip", txtIP.Text.Trim());
                        d.Add("acc", acc.Account);

                        du.executeNonQueryByText("update account_c set id = @id, name = @name, password = @pwd, rank_code = @rank, tel = @tel, cellphone = @cell, mail = @mail, ip = @ip where account = @acc", d);

                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新成功');", true);
                        TabContainer1.ActiveTabIndex = 0;
                        Lib.Center.Account_c newacc = new Lib.Center.Account_c(acc.Account, txtPwd.Text.Trim());
                        Session["account"] = newacc;
                    }
                    if (submitType.Value == "pwdchange")
                    {
                        var newPwd = pwd_HF.Value;
                        d.Add("password", newPwd);
                        d.Add("account", acc.Account);
                        du.executeNonQueryByText("update account_c set password = @password where account = @account", d);
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新成功');", true);
                        acc.Password                 = newPwd;
                        Session["account"]           = acc;
                        TabContainer1.ActiveTabIndex = 1;
                    }
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message + "');", true);
                }
                finally
                {
                    d.Clear();
                    submitType.Value = "";
                }
            }
        }
    }