Exemplo n.º 1
0
    protected void confirm_Click(object sender, EventArgs e)
    {
        // to do
        if (Session["account"] != null)
        {
            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            string _start = (Convert.ToInt32(startDate.Value.Substring(0, 3)) + 1911).ToString() + "/" + startDate.Value.Substring(3, 2) + "/" + startDate.Value.Substring(5, 2);
            string _end   = (Convert.ToInt32(endDate.Value.Substring(0, 3)) + 1911).ToString() + "/" + endDate.Value.Substring(3, 2) + "/" + endDate.Value.Substring(5, 2);
            //新增單位名稱2016-5-4
            d.Add("unit_name", center_name);

            d.Add("head", header.Text.Trim());
            d.Add("text", Ftb1.Text);
            d.Add("acc", ((Lib.Account)Session["account"]).AccountName);
            d.Add("insertDate", DateTime.Now);
            d.Add("start", Convert.ToDateTime(_start));
            d.Add("deadline", Convert.ToDateTime(_end));
            d.Add("shorttext", Ftb2.Text);
            du.executeNonQueryBysp("AddBulletin", d);
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('最新消息新增成功');window.close();", true);
            Lib.SysSetting.AddLog("最新消息", ((Lib.Account)Session["account"]).AccountName, "新增最新消息:" + header.Text.Trim(), System.DateTime.Now);
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('您閒置過時,請複製內容後重新登入進行');", true);
        }
    }
Exemplo n.º 2
0
    protected void ReNew_Click(object sender, EventArgs e)
    {
        try
        {
            MainWS.WebService mainWS = new MainWS.WebService();
            DataTable         dt     = mainWS.UnitData();
            Lib.DataUtility   du     = new Lib.DataUtility();
            du.executeNonQueryByText("delete from unit");
            List <Dictionary <string, object> > list = new List <Dictionary <string, object> >();
            foreach (DataRow row in dt.Rows)
            {
                Dictionary <string, object> d = new Dictionary <string, object>();
                d.Add("unit_code", row["unit_code"]);
                d.Add("unit_title", row["unit_title"]);
                d.Add("parent_unit_code", row["parent_unit_code"]);
                d.Add("service", row["service_code"]);
                list.Add(d);
                du.executeNonQueryByText("insert into unit (unit_code,unit_title,parent_unit_code,service_code) values (@unit_code,@unit_title,@parent_unit_code,@service)", list);
                list.Clear();
            }


            du.executeNonQueryBysp("add_roc_order");
            GridView1.DataSource = dt;
            GridView1.DataBind();
            version.Text = mainWS.Unit_Version();
            Lib.SysSetting.Unit_Version = mainWS.Unit_Version();
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message.Replace("\"", "").Replace("'", "") + "\");", true);
            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
        }
    }
Exemplo n.º 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (DropDownList1.Items.Count > 0)
        {
            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();

            try
            {
                if (DropDownList1.SelectedValue.Length == 5)
                {
                    d.Add("value", DropDownList1.SelectedValue);
                    d.Add("type", "unit_code");
                }
                else
                {
                    d.Add("value", DropDownList1.SelectedValue);
                    d.Add("type", "personal");
                }
                du.executeNonQueryBysp("Race_DelCheckinInfo", d);
                System.Threading.Thread.Sleep(2000);
                Response.Redirect("DeSignUp.aspx");
            }
            catch (Exception ex)
            {
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"無報進名單\");", true);
        }
    }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         // Get the data
         HttpPostedFile jpeg_image_upload = Request.Files["Filedata"];
         byte[]         data = new byte[jpeg_image_upload.ContentLength];
         jpeg_image_upload.InputStream.Read(data, 0, data.Length);
         jpeg_image_upload.InputStream.Close();
         var    check      = Request.Params["myname"];
         string dd         = Server.MapPath(Request.ApplicationPath);
         string s          = System.IO.Path.GetExtension(jpeg_image_upload.FileName);
         string _filetitle = System.DateTime.Now.ToFileTimeUtc().ToString();
         jpeg_image_upload.SaveAs(dd + "\\Uploads\\" + _filetitle + s);
         //jpeg_image_upload.SaveAs("D:\\Uploads\\" + _filetitle + s);
         Lib.DataUtility             du = new Lib.DataUtility();
         Dictionary <string, object> d  = new Dictionary <string, object>();
         d.Add("filename", check);
         d.Add("filepath", _filetitle + s);
         d.Add("uploaddate", System.DateTime.Now);
         d.Add("data", data);
         du.executeNonQueryBysp("AddFile", d);
     }
     catch (Exception ex)
     {
         Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
         Response.StatusCode = 500;
         Response.Write("An error occured");
         Response.End();
     }
     finally
     {
         Response.End();
     }
 }
Exemplo n.º 5
0
 protected void submit_Click(object sender, EventArgs e)
 {
     if (this.IsPostBack)
     {
         Lib.Player player = (Lib.Player)Session["player"];
         if (player.IsCanReSetPassword)
         {
             if (txtPwd.Text.Trim() == txtPwd_Confirm.Text.Trim())
             {
                 if (string.IsNullOrEmpty(Request.Form["hidden_msg_confirm"]) && string.IsNullOrEmpty(Request.Form["hidden_msg"]))
                 {
                     if (!player.IsMustReSetPassword)
                     {
                         //如果Session正確的話, 重新導到哪一頁.
                         //才可以接受變更.
                         Lib.DataUtility             du = new Lib.DataUtility();
                         Dictionary <string, object> d  = new Dictionary <string, object>();
                         d.Add(@"id", player.ID);
                         d.Add(@"password", txtPwd_Confirm.Text.Trim());
                         du.executeNonQueryBysp(@"Ex105_UpdatePassword", d);
                         Session["player"] = null;
                         Response.Redirect("Redirect.html");
                     }
                     else
                     {
                         //如果Session正確的話, 重新導到哪一頁.
                         //才可以接受變更.
                         Lib.DataUtility             du = new Lib.DataUtility();
                         Dictionary <string, object> d  = new Dictionary <string, object>();
                         d.Add(@"id", player.ID);
                         d.Add(@"password", txtPwd_Confirm.Text.Trim());
                         d.Add(@"mail", Request.Form["txtMail"].Trim());
                         du.executeNonQueryBysp(@"Ex105_UpdatePasswordnMail", d);
                         Session["player"] = null;
                         Response.Redirect("Redirect.html");
                     }
                 }
                 else
                 {
                     ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('密碼不正確');", true);
                 }
             }
             else
             {
                 ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('密碼不一致');", true);
             }
         }
         else
         {
             Response.Redirect("Login.aspx");
             Session.Clear();
         }
     }
 }
Exemplo n.º 6
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (HiddenField1.Value != null)
     {
         Dictionary <String, object> list = new Dictionary <string, object>();
         list.Add("unit", 5);
         list.Add("center_code", Convert.ToInt32(HiddenField1.Value));
         Lib.DataUtility du = new Lib.DataUtility();
         du.executeNonQueryBysp("Ex102_DeleteOverDueByCenter", list);
         GridView1.DataSource = null;
         GridView1.DataBind();
     }
 }
Exemplo n.º 7
0
 //2018-11-5新增成績補正log
 public static void AddResultCorrectLog(Dictionary <string, object> dic)
 {
     try
     {
         DataUtility du = new DataUtility();
         Dictionary <string, object> d = dic;
         du.executeNonQueryBysp("Ex108_AddResultCorrectLog", d);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 8
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        GridViewRow row = (GridViewRow)((Button)sender).NamingContainer;
        string      sid = row.Cells[0].Text;
        Dictionary <String, object> list = new Dictionary <string, object>();

        list.Add("unit", 5);
        list.Add("sid", Convert.ToInt32(sid));
        Lib.DataUtility du = new Lib.DataUtility();
        du.executeNonQueryBysp("Ex102_DeleteOverDueBySID", list);
        GridView1.Rows[row.RowIndex].Visible = false;
        //GridView1.DataBind();
    }
Exemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            //前端已經先關好站了,再來處理關站刪除
            if (HF_CheckDel.Value == "ok")
            {
                HF_CheckDel.Value = "no";
                //逐筆寄信後刪除
                string date        = txb_InqDate.Text;
                string center_name = DropDownList1.SelectedItem.Text;
                string reason      = txb_Reason.Text;//關站原因
                for (int i = 0; i < GridView2.Rows.Count; i++)
                {
                    string sid  = GridView2.Rows[i].Cells[0].Text;
                    string id   = GridView2.Rows[i].Cells[2].Text;
                    string mail = GridView2.Rows[i].Cells[8].Text;


                    //檢查信箱欄位,有的才寄信
                    //信件文字檔案夾位置
                    string       dd = Server.MapPath(Request.ApplicationPath);
                    StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\OffStation.txt");
                    //先寄信
                    if (!string.IsNullOrEmpty(mail) & mail != "&nbsp;")    //表格空字串會變成「&nbsp;」
                    {
                        MailMessage _MailToUser = new MailMessage();
                        _MailToUser.Body = _MailContentToUser.ReadToEnd();
                        _MailToUser.Body = _MailToUser.Body.Replace("%reason%", reason);
                        _MailToUser.Body = _MailToUser.Body.Replace("%id%", (id.Substring(0, id.Length - 3) + "***"));
                        _MailToUser.Body = _MailToUser.Body.Replace("%date%", date);
                        _MailToUser.Body = _MailToUser.Body.Replace("%location%", center_name);
                        Lib.SysSetting.SaveLetter(mail + "@webmail.mil.tw", "國軍體能鑑測中心", _MailToUser.Body, "臨時關站取消報名通知信", "00");
                    }
                    Lib.DataUtility du = new Lib.DataUtility();
                    //再刪報名
                    du.executeNonQueryBysp("Ex107_DelResultbySid", "sid", sid);
                }
                Lib.SysSetting.AddLog("臨時關站", "admin", "臨時關站取消報名 , 日期:" + date + " , 地點:" + center_name, System.DateTime.Now);
                GridView2.DataSource = null;
                GridView2.DataBind();
                CloseEnter();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('鑑測站已關閉,報名資料已刪除。');", true);

                //重新整理網頁
                //Response.Redirect(Request.FilePath);
            }
        }
    }
Exemplo n.º 10
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (Session["account"] != null)
     {
         if (acc.Text.Trim() != "")
         {
             Dictionary <string, object> d  = new Dictionary <string, object>();
             Lib.DataUtility             du = new Lib.DataUtility();
             d.Add("account", acc.Text.Trim());
             du.executeNonQueryBysp("DelAccount", d);
             Lib.SysSetting.AddLog("帳號管理", ((Lib.Account)Session["account"]).AccountName, acc.Text.Trim() + " 帳號被刪除", DateTime.Now);
             ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('帳號已刪除!!!');window.close();", true);
         }
     }
 }
Exemplo n.º 11
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);
     }
 }
Exemplo n.º 12
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Session["account"] != null)
        {
            if (acc.Text.Trim() != "" && pwd.Text.Trim() != "" && name.Text.Trim() != "" && id.Text.Trim() != "" &&
                unit_code.Text.Trim() != "" && rank_code.Text.Trim() != "" && tel.Text.Trim() != "" &&
                cell.Text.Trim() != "" && ip.Text.Trim() != "")
            {
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                d.Add("updater", ((Lib.Account)Session["account"]).AccountName);
                d.Add("account", acc.Text.Trim());
                d.Add("password", pwd.Text.Trim());
                d.Add("name", name.Text.Trim());
                d.Add("id", id.Text.Trim());
                d.Add("unit_code", unit_code.Text.Trim());
                d.Add("rank_code", rank_code.Text.Trim());
                d.Add("tel", tel.Text.Trim());
                d.Add("cellphone", cell.Text.Trim());
                d.Add("mail", email.Text.Trim());
                d.Add("ip", ip.Text.Trim());
                du.executeNonQueryByText("update account set password = @password, name = @name, id = @id, unit_code = @unit_code, rank_code = @rank_code, tel = @tel, cellphone = @cellphone, mail = @mail, ip = @ip where account = @account", d);
                //d.Clear();

                Dictionary <string, object> d_option = new Dictionary <string, object>();
                d_option.Add("accName", acc.Text.Trim());

                foreach (ListItem items in CheckBoxList1.Items)
                {
                    if (items.Selected == true)
                    {
                        d_option.Add("option" + items.Value, "true");
                    }
                    else
                    {
                        d_option.Add("option" + items.Value, "false");
                    }
                }
                du.executeNonQueryBysp("updateoptions", d_option);
                Lib.SysSetting.AddLog("帳號管理", ((Lib.Account)Session["account"]).AccountName, acc.Text.Trim() + " 帳號資料被更改", DateTime.Now);
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新成功!!!');window.close();", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料有缺漏!!!');", true);
            }
        }
    }
Exemplo n.º 13
0
 public static void AddLog(string _type, string _acc, string _event, DateTime _eventTime)
 {
     try
     {
         DataUtility du = new DataUtility();
         Dictionary <string, object> d = new Dictionary <string, object>();
         d.Add("type", _type);
         d.Add("acc", _acc);
         d.Add("event", _event);
         d.Add("eventTime", _eventTime);
         du.executeNonQueryBysp("AddLog", d);
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 14
0
 //刪除現報未檢錄之人員
 protected void btn_Del999_Click(object sender, EventArgs e)
 {
     Lib.DataUtility du = new Lib.DataUtility();
     try
     {
         du.executeNonQueryBysp("EX107_DelReportedNoCheck");
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料刪除完成!!');", true);
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料刪除失敗:" + ex.Message + "');", true);
     }
     GridView1.DataBind();
     //重新整理網頁
     Response.Redirect(Request.FilePath);
     TabContainer1.ActiveTabIndex = 4;
 }
Exemplo n.º 15
0
 public static bool SaveLetter(string mailto, string mailfrom, string body, string type, string status)
 {
     try
     {
         DataUtility du = new DataUtility();
         Dictionary <string, object> d = new Dictionary <string, object>();
         d.Add("mailto", mailto);
         d.Add("mailfrom", mailfrom);
         d.Add("body", body);
         d.Add("type", type);
         d.Add("status", status);
         du.executeNonQueryBysp("AddMail", d);
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemplo n.º 16
0
    protected void confirm_Click(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        d.Add("apply", ((Lib.Account)Session["account"]).AccountName);
        d.Add("ip_new", newip.Value.Trim());
        d.Add("date", DateTime.Now);
        try
        {
            du.executeNonQueryBysp("updateip", d);
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('申請成功,請等候審查');window.close();", true);
        }
        catch (Exception ex)
        {
            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message + "');", true);
        }
    }
Exemplo n.º 17
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();
 }
Exemplo n.º 18
0
    protected void btn_SetWorkWeek_Click(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        d.Add("year", Year);
        d.Add("Monday", ch1);
        d.Add("Tuesday", ch2);
        d.Add("Wednesday", ch3);
        d.Add("Thursday", ch4);
        d.Add("Friday", ch5);
        d.Add("Saturday", ch6);
        d.Add("Sunday", ch7);
        try
        {
            du.executeNonQueryBysp("Ex107_SetWorkWeek", d);

            Response.Redirect(Request.FilePath);
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('更新失敗');", true);
        }
    }
Exemplo n.º 19
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        //if (id.Value != "" && situps.Value != "" && pushups.Value != "" && run.Value != "" && id.Value == checkid.Value )
        if (id.Value != "" && id.Value == checkid.Value)
        {
            if (status.Value == "001")
            {   //For status 001
                string                      t  = old_run_score;
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                //
                //d.Add("id", string t = (id.Value == "")?id.Value : System.DBNull.Value);
                if (!situps.Disabled)
                {
                    if (situps.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("sit_ups", Convert.ToInt32(situps.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (situps_min.Value == "" && situps_sec.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        if (situps_min.Value != "")
                        {
                            total += Convert.ToInt32(situps_min.Value) * 60;
                        }

                        if (situps_sec.Value != "")
                        {
                            total += Convert.ToInt32(situps_sec.Value);
                        }
                        if (total != 0)
                        {
                            d.Add("sit_ups", total);
                        }
                        else
                        {
                            d.Add("sit_ups", DBNull.Value);
                        }
                    }
                }

                if (!pushups.Disabled)
                {
                    if (pushups.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("push_ups", Convert.ToInt32(pushups.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (pushups_min.Value == "" && pushups_sec.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        if (pushups_min.Value != "")
                        {
                            total += Convert.ToInt32(pushups_min.Value) * 60;
                        }

                        if (pushups_sec.Value != "")
                        {
                            total += Convert.ToInt32(pushups_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("push_ups", total);
                        }
                        else
                        {
                            d.Add("push_ups", DBNull.Value);
                        }
                    }
                }

                if (!run.Disabled)
                {
                    if (run.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        d.Add("run", Convert.ToInt32(run.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (run_min.Value == "" && run_sec.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        if (run_min.Value != "")
                        {
                            total += Convert.ToInt32(run_min.Value) * 60;
                        }

                        if (run_sec.Value != "")
                        {
                            total += Convert.ToInt32(run_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("run", total);
                        }
                        else
                        {
                            d.Add("run", DBNull.Value);
                        }
                    }
                }

                d.Add("id", id.Value);
                //d.Add("date", Convert.ToDateTime(dateValue.Value));
                try
                {
                    du.executeNonQueryBysp("Race_ResultCorrect", d);
                    Account_c acc = (Account_c)Session["account"];
                    Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次, " + push_ups_name.Text + ": " + old_pushups + "次, " + run_name.Text + ": " + old_run + "秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + situps.Value + "次, " + situps_min.Value + "分:" + situps_sec.Value + "秒" + push_ups_name.Text + ": " + pushups.Value + "次, " + pushups_min.Value + "分:" + pushups_sec.Value + "秒" + run_name.Text + ": " + run.Value + "次," + run_min.Value + "分:" + run_sec.Value + "秒)", DateTime.Now);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('完成補正成績');", true);
                    id.Value          = "";
                    situps.Value      = "";
                    situps_min.Value  = "";
                    situps_sec.Value  = "";
                    pushups.Value     = "";
                    pushups_min.Value = "";
                    pushups_sec.Value = "";
                    run.Value         = "";
                    run_min.Value     = "";
                    run_sec.Value     = "";
                    name.Value        = "";
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message.ToString() + "');", true);
                }
            }
            else
            {   //For Status 102, 103
                string                      t  = old_run_score;
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                //
                //d.Add("id", string t = (id.Value == "")?id.Value : System.DBNull.Value);
                if (!situps.Disabled)
                {
                    if (situps.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("sit_ups", Convert.ToInt32(situps.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (situps_min.Value == "" && situps_sec.Value == "")
                    {
                        d.Add("sit_ups", DBNull.Value);
                    }
                    else
                    {
                        if (situps_min.Value != "")
                        {
                            total += Convert.ToInt32(situps_min.Value) * 60;
                        }

                        if (situps_sec.Value != "")
                        {
                            total += Convert.ToInt32(situps_sec.Value);
                        }
                        if (total != 0)
                        {
                            d.Add("sit_ups", total);
                        }
                        else
                        {
                            d.Add("sit_ups", DBNull.Value);
                        }
                    }
                }

                if (!pushups.Disabled)
                {
                    if (pushups.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        d.Add("push_ups", Convert.ToInt32(pushups.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (pushups_min.Value == "" && pushups_sec.Value == "")
                    {
                        d.Add("push_ups", DBNull.Value);
                    }
                    else
                    {
                        if (pushups_min.Value != "")
                        {
                            total += Convert.ToInt32(pushups_min.Value) * 60;
                        }

                        if (pushups_sec.Value != "")
                        {
                            total += Convert.ToInt32(pushups_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("push_ups", total);
                        }
                        else
                        {
                            d.Add("push_ups", DBNull.Value);
                        }
                    }
                }

                if (!run.Disabled)
                {
                    if (run.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        d.Add("run", Convert.ToInt32(run.Value));
                    }
                }
                else
                {
                    int total = 0;
                    if (run_min.Value == "" && run_sec.Value == "")
                    {
                        d.Add("run", DBNull.Value);
                    }
                    else
                    {
                        if (run_min.Value != "")
                        {
                            total += Convert.ToInt32(run_min.Value) * 60;
                        }

                        if (run_sec.Value != "")
                        {
                            total += Convert.ToInt32(run_sec.Value);
                        }

                        if (total != 0)
                        {
                            d.Add("run", total);
                        }
                        else
                        {
                            d.Add("run", DBNull.Value);
                        }
                    }
                }

                d.Add("id", id.Value);
                //d.Add("date", Convert.ToDateTime(dateValue.Value));
                try
                {
                    du.executeNonQueryBysp("Race_ResultCorrect", d);
                    d.Clear();
                    d.Add("id", id.Value);
                    du.executeNonQueryBysp("Race_CalResult", d);
                    Account_c acc = (Account_c)Session["account"];
                    //Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次, " + push_ups_name.Text + ": " + old_pushups + "次, " + run_name.Text + ": " + old_run + "秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + situps.Value + "次, " + push_ups_name.Text + ": " + pushups.Value + "次, " + run_name.Text + ": " + run.Value + "秒)", DateTime.Now);
                    Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次, " + push_ups_name.Text + ": " + old_pushups + "次, " + run_name.Text + ": " + old_run + "秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + situps.Value + "次, " + situps_min.Value + "分:" + situps_sec.Value + "秒" + push_ups_name.Text + ": " + pushups.Value + "次, " + pushups_min.Value + "分:" + pushups_sec.Value + "秒" + run_name.Text + ": " + run.Value + "次," + run_min.Value + "分:" + run_sec.Value + "秒)", DateTime.Now);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('完成補正成績');", true);
                    id.Value          = "";
                    situps.Value      = "";
                    situps_min.Value  = "";
                    situps_sec.Value  = "";
                    pushups.Value     = "";
                    pushups_min.Value = "";
                    pushups_sec.Value = "";
                    run.Value         = "";
                    run_min.Value     = "";
                    run_sec.Value     = "";
                    name.Value        = "";
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message.ToString() + "');", true);
                }
            }
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料有缺漏!!!');", true);
        }
    }
Exemplo n.º 20
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        Dictionary <string, object> d = new Dictionary <string, object>();

        Lib.DataUtility du = new Lib.DataUtility();
        try
        {
            DataTable checkid    = new DataTable();
            DataTable ResultCall = new DataTable();
            ResultCall.Columns.Add("身份證");
            ResultCall.Columns.Add("姓名");
            ResultCall.Columns.Add("生日");
            ResultCall.Columns.Add("性別");
            ResultCall.Columns.Add("單位代碼");
            ResultCall.Columns.Add("軍階代碼");
            ResultCall.Columns.Add("鑑測站代碼");
            ResultCall.Columns.Add("役別");
            ResultCall.Columns.Add("新進人員區分代碼");
            ResultCall.Columns.Add("組別");
            ResultCall.Columns.Add("訊息");

            List <string>       Id_Exist = new List <string>();
            int                 count    = 0;
            DataTable           dt       = (DataTable)Session["CanAccess"];
            List <SqlParameter> list     = new List <SqlParameter>();
            foreach (DataRow DR in dt.Rows)
            {
                d.Clear();
                d.Add("id", DR[0].ToString());
                checkid = du.getDataTableBysp("Race_QueryPlayer", d);
                if (checkid.Rows.Count != 0)
                {
                    Id_Exist.Add(DR[0].ToString());
                }
            }

            if (Id_Exist.Count == 0)
            {
                foreach (DataRow DR in dt.Rows)
                {
                    //CanAccess.Columns.Add("身份證"); 0
                    //CanAccess.Columns.Add("姓名");   1
                    //CanAccess.Columns.Add("生日");   2
                    //CanAccess.Columns.Add("性別");    3
                    //CanAccess.Columns.Add("單位代碼");4
                    //CanAccess.Columns.Add("軍階代碼");5
                    //CanAccess.Columns.Add("鑑測站代碼");6
                    //CanAccess.Columns.Add("役別");7
                    //CanAccess.Columns.Add("新進人員區分代碼");8
                    //CanAccess.Columns.Add("組別");9
                    #region New SqlParameter
                    SqlParameter p1 = new SqlParameter("message", SqlDbType.NVarChar, 50);
                    SqlParameter p2 = new SqlParameter("id", DR[0].ToString());
                    SqlParameter p3 = new SqlParameter("gender", DR[3].ToString());
                    SqlParameter p4 = new SqlParameter("birth", Convert.ToDateTime(DR[2]));
                    SqlParameter p5 = new SqlParameter("name", DR[1]);
                    SqlParameter p6 = new SqlParameter("unit_code", DR[4].ToString());
                    SqlParameter p7 = new SqlParameter("rank_code", DR[5].ToString());
                    SqlParameter p8 = new SqlParameter("center_code", DR[6].ToString());
                    SqlParameter p9 = new SqlParameter("result", DR[9].ToString() + DR[7].ToString() + DR[8].ToString());
                    //SqlParameter p10 = new SqlParameter("date", System.DateTime.Today);
                    #endregion
                    p1.Direction = ParameterDirection.Output;
                    list.Clear();
                    #region List.Add SqlParameter
                    list.Add(p1);
                    list.Add(p2);
                    list.Add(p3);
                    list.Add(p4);
                    list.Add(p5);
                    list.Add(p6);
                    list.Add(p7);
                    list.Add(p8);
                    list.Add(p9);
                    //list.Add(p10);
                    #endregion
                    SqlParameter[] sqls = list.ToArray();
                    du.executeNonQueryBysp("Race_AddPlayer", sqls);

                    if (p1.Value.ToString() == "canreserve")
                    {
                        count++;
                    }
                }
                Label13.Text    = "共 " + count.ToString() + " 名完成報進.";
                Button3.Enabled = false;
            }
            else
            {
                Label13.Text = string.Empty;
                foreach (string s in Id_Exist)
                {
                    Label13.Text = Label13.Text + " " + s + " 已報進 , 不可重覆報進" + "<br>";
                }
            }
        }
        catch (Exception ex)
        {
            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
        }
    }
Exemplo n.º 21
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (check_num.Value == "1")//前台傳回來的值(1:正確、0:錯誤)
        {
            string                      t  = old_run_score;
            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            d.Clear();
            //判斷身份證字號是否正確
            if (id1.Value != "" && id1.Value == checkid.Value)
            {
                //判斷第一項是用次數還是秒
                //使用分秒
                if (sit_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60) + Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60);
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("sit_ups", DBNull.Value);
                        new_sit_ups = string.Empty;
                    }
                }
                //使用次數
                else
                {
                    //2016-1-26再修正值不等於"秒",也是判斷二個欄位來相加
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60) + Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_sit1.Text.Trim()) & string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = (Convert.ToInt32(txb_sit1.Text.Trim()) * 60);
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_sit1.Text.Trim()) & !string.IsNullOrEmpty(txb_sit2.Text.Trim()))
                    {
                        int sit_sec = Convert.ToInt32(txb_sit2.Text.Trim());
                        d.Add("sit_ups", sit_sec);
                        new_sit_ups = sit_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("sit_ups", DBNull.Value);
                        new_sit_ups = string.Empty;
                    }
                }

                //判斷第二項是用次數還是秒
                //使用分秒
                if (push_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60) + Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60);
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("push_ups", DBNull.Value);
                        new_push_ups = string.Empty;
                    }
                }
                //使用次數
                else
                {
                    if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60) + Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_push1.Text.Trim()) & string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = (Convert.ToInt32(txb_push1.Text.Trim()) * 60);
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_push1.Text.Trim()) & !string.IsNullOrEmpty(txb_push2.Text.Trim()))
                    {
                        int push_sec = Convert.ToInt32(txb_push2.Text.Trim());
                        d.Add("push_ups", push_sec);
                        new_push_ups = push_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("push_ups", DBNull.Value);
                        new_push_ups = string.Empty;
                    }
                }

                //判斷第三項是用次數還是秒
                //使用分秒
                if (run_note == "秒")
                {
                    //2016-1-14新判斷
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60) + Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60);
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("run", DBNull.Value);
                        new_run = string.Empty;
                    }
                }
                //使用次數
                else
                {
                    //分、秒都有值
                    if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60) + Convert.ToInt32(txb_run2.Text.Trim());
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分有值、秒空白
                    else if (!string.IsNullOrEmpty(txb_run1.Text.Trim()) & string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = (Convert.ToInt32(txb_run1.Text.Trim()) * 60);
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //分空白、秒有值
                    else if (string.IsNullOrEmpty(txb_run1.Text.Trim()) & !string.IsNullOrEmpty(txb_run2.Text.Trim()))
                    {
                        int run_sec = Convert.ToInt32(txb_run2.Text);
                        d.Add("run", run_sec);
                        new_run = run_sec.ToString();
                    }
                    //都空白
                    else
                    {
                        d.Add("run", DBNull.Value);
                        new_run = string.Empty;
                    }
                }

                d.Add("id", id1.Value.ToUpper());
                d.Add("date", Convert.ToDateTime(dateValue.Value));
                try
                {
                    du.executeNonQueryByText("update result set sit_ups = @sit_ups, push_ups = @push_ups, run=@run where id = @id and date = @date and status in ('102','103','105')", d);

                    //2017-1-26再重新計算一次成績
                    Dictionary <string, object> d1 = new Dictionary <string, object>();
                    d1.Add("id", id1.Value.ToUpper());
                    d1.Add("date", Convert.ToDateTime(dateValue.Value));
                    //2018-10-11新增異動時間點
                    DateTime ChangeDate = new DateTime(2018, 12, 31, 23, 59, 59);
                    DateTime TodayDate  = Convert.ToDateTime(dateValue.Value);
                    if (TodayDate > ChangeDate)
                    {
                        du.executeNonQueryBysp("Ex108_CalResultByID", d1);
                    }
                    else
                    {
                        du.executeNonQueryBysp("Ex106_CalResultByID", d1);
                    }

                    d1.Clear();

                    Account_c acc = (Account_c)Session["account"];
                    //Lib.SysSetting.AddLog("成績補正", acc.Account, "補正對象: (" + id.Value + ") 補正前成績為(" + sit_ups_name.Text + ": " + old_situps + "次/秒, " + push_ups_name.Text + ": " + old_pushups + "次/秒, " + run_name.Text + ": " + old_run + "次/秒)" + "補正後成績為(" + sit_ups_name.Text + ": " + sit_value + "次/秒, " + push_ups_name.Text + ": " + push_value + "次/秒, " + run_name.Text + ": " + run_value + "次/秒)", DateTime.Now);
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("id", id1.Value.ToUpper());
                    dic.Add("name", name.Value);
                    dic.Add("date", Convert.ToDateTime(dateValue.Value));
                    if (!string.IsNullOrEmpty(old_situps))
                    {
                        dic.Add("old_sit_ups", old_situps);
                    }
                    else
                    {
                        dic.Add("old_sit_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(old_pushups))
                    {
                        dic.Add("old_push_ups", old_pushups);
                    }
                    else
                    {
                        dic.Add("old_push_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(old_run))
                    {
                        dic.Add("old_run", old_run);
                    }
                    else
                    {
                        dic.Add("old_run", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(new_sit_ups))
                    {
                        dic.Add("new_sit_ups", new_sit_ups);
                    }
                    else
                    {
                        dic.Add("new_sit_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(new_push_ups))
                    {
                        dic.Add("new_push_ups", new_push_ups);
                    }
                    else
                    {
                        dic.Add("new_push_ups", DBNull.Value);
                    }
                    if (!string.IsNullOrEmpty(new_run))
                    {
                        dic.Add("new_run", new_run);
                    }
                    else
                    {
                        dic.Add("new_run", DBNull.Value);
                    }
                    dic.Add("account", acc.Account);
                    if (!string.IsNullOrEmpty(acc.ID))
                    {
                        dic.Add("account_id", acc.ID);
                    }
                    else
                    {
                        dic.Add("account_id", DBNull.Value);
                    }
                    dic.Add("update_time", DateTime.Now);
                    dic.Add("type", "成績補正");

                    Lib.SysSetting.AddResultCorrectLog(dic);
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('成績補正完成!!');", true);
                    id1.Value = "";
                    //situps.Value = "";
                    //pushups.Value = "";
                    //run.Value = "";
                    name.Value = "";
                    //清空欄位
                    txb_sit1.Text  = null;
                    txb_sit2.Text  = null;
                    txb_push1.Text = null;
                    txb_push2.Text = null;
                    txb_run1.Text  = null;
                    txb_run2.Text  = null;
                    sit_note       = string.Empty;
                    push_note      = string.Empty;
                    run_note       = string.Empty;
                    sit_value      = string.Empty;
                    push_value     = string.Empty;
                    run_value      = string.Empty;
                    new_sit_ups    = string.Empty;
                    new_push_ups   = string.Empty;
                    new_run        = string.Empty;
                    //2016-1-25修改完後欄位全關閉
                    sit_ups_name.Text  = null;
                    txb_sit1.Visible   = false;
                    txb_sit2.Visible   = false;
                    lab_sit1.Text      = null;
                    lab_sit2.Text      = null;
                    push_ups_name.Text = null;
                    txb_push1.Visible  = false;
                    txb_push2.Visible  = false;
                    lab_push1.Text     = null;
                    lab_push2.Text     = null;
                    run_name.Text      = null;
                    txb_run1.Visible   = false;
                    txb_run2.Visible   = false;
                    lab_run1.Text      = null;
                    lab_run2.Text      = null;
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message.ToString() + "');", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料有誤!!請重新執行搜尋!!');", true);
                //清空欄位
                name.Value     = null;
                txb_sit1.Text  = null;
                txb_sit2.Text  = null;
                txb_push1.Text = null;
                txb_push2.Text = null;
                txb_run1.Text  = null;
                txb_run2.Text  = null;
                sit_note       = string.Empty;
                push_note      = string.Empty;
                run_note       = string.Empty;
                sit_value      = string.Empty;
                push_value     = string.Empty;
                run_value      = string.Empty;

                //2016-1-25修改完後欄位全關閉
                sit_ups_name.Text  = null;
                txb_sit1.Visible   = false;
                txb_sit2.Visible   = false;
                lab_sit1.Text      = null;
                lab_sit2.Text      = null;
                push_ups_name.Text = null;
                txb_push1.Visible  = false;
                txb_push2.Visible  = false;
                lab_push1.Text     = null;
                lab_push2.Text     = null;
                run_name.Text      = null;
                txb_run1.Visible   = false;
                txb_run2.Visible   = false;
                lab_run1.Text      = null;
                lab_run2.Text      = null;
            }
        }
    }
Exemplo n.º 22
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        string _selectdate = selectDate.Text;

        if (Session["player"] != null && Request.QueryString["center_code"] != null && Request.QueryString["center_code"] != "" && Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            CultureInfo ci_en = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentCulture = ci_en;
            Dictionary <string, object> d = new Dictionary <string, object>();
            DateTime        reserveDate   = Convert.ToDateTime(Request.QueryString["date"].ToString().Trim());
            DateTime        Checkover     = reserveDate.AddDays(-30);
            Lib.DataUtility du            = new Lib.DataUtility();
            d.Add("id", ((Lib.Player)Session["player"]).ID);
            d.Add("reserveDate", reserveDate);
            d.Add("checkover", Checkover);
            DataTable dt_again = du.getDataTableByText("select count(id) as count from result where id = @id and status = '205' AND date BETWEEN @checkover AND @reserveDate", d);
            if (Convert.ToInt32(dt_again.Rows[0]["count"].ToString()) == 0)
            {   //檢查是否有補測人員
                DateTime     newreserveDate = Lib.SysSetting.ToWorldDate(_selectdate);
                DateTime     newCheckover   = newreserveDate.AddDays(-30);
                DateTime     firstday       = new DateTime(newreserveDate.Year, 1, 1);
                DateTime     lastday        = new DateTime(newreserveDate.Year, 12, 31);
                DateTime     Start          = new DateTime(newreserveDate.Year, newreserveDate.Month, 1);
                DateTime     End            = Start.AddMonths(1).AddDays(-1);
                SqlParameter _p1            = new SqlParameter("message", SqlDbType.NVarChar, 50);
                SqlParameter _p2            = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                SqlParameter _p3            = new SqlParameter("reserveDate", newreserveDate);
                SqlParameter _p4            = new SqlParameter("start", Start);
                SqlParameter _p5            = new SqlParameter("end", End);
                SqlParameter _p6            = new SqlParameter("checkover", newCheckover);
                SqlParameter _p7            = new SqlParameter("firstday", firstday);
                SqlParameter _p8            = new SqlParameter("lastday", lastday);
                _p1.Direction = ParameterDirection.Output;
                List <SqlParameter> list = new List <SqlParameter>();
                list.Add(_p1);
                list.Add(_p2);
                list.Add(_p3);
                list.Add(_p4);
                list.Add(_p5);
                list.Add(_p6);
                list.Add(_p7);
                list.Add(_p8);
                SqlParameter[] sqls = list.ToArray();
                du.executeNonQueryBysp("ChangePlayerByRepair", sqls);

                switch (_p1.Value.ToString())
                {
                case "canreservefromno":
                    Boolean       isCenter   = false;
                    Boolean       isOverTime = false;
                    SqlConnection conn       = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDB"].ConnectionString);
                    conn.Open();
                    SqlCommand     comm = conn.CreateCommand();
                    SqlTransaction trans;
                    trans            = conn.BeginTransaction("mytrans");
                    comm.Connection  = conn;
                    comm.Transaction = trans;
                    DataTable dt        = new DataTable();
                    DataTable dt_center = new DataTable();
                    try
                    {
                        SqlParameter p4 = new SqlParameter("center_code", Request.QueryString["center_code"].ToString().Trim());
                        SqlParameter p5 = new SqlParameter("new_center_code", cneterSel.SelectedValue.ToString());
                        SqlParameter p6 = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                        comm.Parameters.Add(p4);
                        comm.Parameters.Add(p5);
                        comm.Parameters.Add(p6);
                        comm.CommandText = "select top(1) memo from result where id = @id ORDER BY date DESC";
                        //comm.CommandText = "select top(1) (select IsSwin from Center where center_code = @center_code) as IsSwin ,  (select IsSwin from Center where center_code = @new_center_code) as new_IsSwin ,r.memo from result r where r.id = @id ORDER BY date DESC";
                        dt_center.Load(comm.ExecuteReader());
                        DataTable dt_center_ok = Lib.SysSetting.GetCenterFromMemo(dt_center.Rows[0]["memo"].ToString());
                        foreach (DataRow dr in dt_center_ok.Rows)
                        {
                            if (dr["center_code"].ToString() == cneterSel.SelectedValue.ToString())
                            {
                                isCenter = true;
                            }
                        }
                        //if (dt_center.Rows[0]["memo"].ToString() == "000")
                        //{
                        //    isCenter = true;
                        //}
                        //else
                        //{
                        //    if (Convert.ToBoolean(dt_center.Rows[0]["IsSwin"]))
                        //    {
                        //        if (dt_center.Rows[0]["IsSwin"].ToString() == dt_center.Rows[0]["new_IsSwin"].ToString())
                        //        {
                        //            isCenter = true;
                        //        }
                        //        else
                        //        {
                        //            isCenter = false;
                        //        }
                        //    }
                        //    else //之前選擇的鑑測站沒有游泳池,所以可以任意選擇新的鑑測站
                        //    {
                        //        isCenter = true;
                        //    }
                        //}

                        if (isCenter)
                        {
                            DataTable dt_result    = new DataTable();
                            DateTime  _reserveDate = Lib.SysSetting.ToWorldDate(_selectdate);
                            //DateTime firstday = new DateTime(_reserveDate.Year, 1, 1);
                            //DateTime lastday = new DateTime(_reserveDate.Year, 12, 31);
                            SqlParameter p7 = new SqlParameter("firstday", firstday);
                            SqlParameter p8 = new SqlParameter("lastday", lastday);
                            SqlParameter p9 = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                            comm.Parameters.Clear();
                            comm.Parameters.Add(p7);
                            comm.Parameters.Add(p8);
                            comm.Parameters.Add(p9);
                            comm.CommandText = "select count(id) from result where (status in ('203','204','205')) and (id = @id) and ( date BETWEEN @firstday and @lastday)";
                            dt_result.Load(comm.ExecuteReader());
                            int _count = Convert.ToInt32(dt_result.Rows[0][0]);
                            if (_count > 0)
                            {
                                isOverTime = false;
                            }
                            else
                            {
                                isOverTime = true;
                            }

                            if (!isOverTime)
                            {
                                comm.Parameters.Clear();
                                SqlParameter p1 = new SqlParameter("date", Convert.ToDateTime(Request.QueryString["date"].ToString().Trim()));
                                SqlParameter p2 = new SqlParameter("center_code", Request.QueryString["center_code"].ToString().Trim());
                                SqlParameter p3 = new SqlParameter("op_id", ((Lib.Player)Session["player"]).ID);
                                comm.Parameters.Add(p1);
                                comm.Parameters.Add(p2);
                                comm.Parameters.Add(p3);
                                comm.CommandText = "select sid,birth from Result where date = @date and center_code = @center_code and id = @op_id and status = '000'";
                                dt.Load(comm.ExecuteReader());      //抓出要變更的那筆預約
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    comm.Parameters.Clear();
                                    comm.Parameters.Add("age", Lib.SysSetting.ConvertAge(Convert.ToDateTime(dt.Rows[i]["birth"]), Lib.SysSetting.ToWorldDate(_selectdate)));
                                    comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                                    comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                    comm.Parameters.Add("op_id", ((Lib.Player)Session["player"]).ID);
                                    comm.Parameters.Add("sid", dt.Rows[i]["sid"].ToString());
                                    comm.CommandText = "UPDATE Result SET age = @age, date = @date, center_code = @center_code where sid = @sid and id = @op_id ";
                                    comm.ExecuteNonQuery();
                                }
                                DataTable dt_reserved = new DataTable();      //計算選定的鑑測站與鑑測日期所剩餘的人數
                                comm.Parameters.Clear();
                                comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                                comm.CommandText = "select count (id) as reserved,(select limit from center where center_code = @center_code) as limit from result where center_code = @center_code and date = @date";
                                dt_reserved.Load(comm.ExecuteReader());
                                if (((Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString())) >= 0))
                                {
                                    //if ((Convert.ToInt32(oldcount.Text) <= (Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString()))))
                                    trans.Commit();
                                    newcenter.Text                    = cneterSel.SelectedItem.Text;
                                    newcount.Text                     = oldcount.Text;
                                    newdate.Text                      = _selectdate;
                                    this.Result.Style.Value           = "";
                                    this.ReturnStep1.Style.Value      = "";
                                    this.OrderStep1.Style.Value       = "display:none";
                                    this.SureTimeAndPlace.Style.Value = "display:none";
                                    this.Div1.Style.Value             = "display:none";
                                    this.Nonenough.Style.Value        = "display:none";
                                    this.AgaginError.Style.Value      = "display:none";
                                    this.nonecenter.Style.Value       = "display:none";
                                    this.noreserve.Style.Value        = "display:none";
                                    this.overtime.Style.Value         = "display:none";
                                    this.ConnectError.Style.Value     = "display:none";
                                    #region 通知受測人員變更報進
                                    MailMessage  _MailToUser        = new MailMessage();
                                    StreamReader _MailContentToUser = new StreamReader(Server.MapPath(Request.ApplicationPath) + "\\Mail\\UpdateSelfReserve.txt");
                                    _MailToUser.Body = _MailContentToUser.ReadToEnd();
                                    _MailToUser.Body = _MailToUser.Body.Replace("%olddate%", olddate.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%oldlocation%", oldcenter.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%newdate%", newdate.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%newlocation%", newcenter.Text);
                                    Lib.SysSetting.SaveLetter(((Lib.Player)Session["player"]).Mail + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "報進變更通知信", "00");
                                    #endregion
                                }
                                else
                                {
                                    trans.Rollback();
                                    this.Nonenough.Style.Value    = "";
                                    this.Div1.Style.Value         = "display:none";
                                    this.nonecenter.Style.Value   = "display:none";
                                    this.noreserve.Style.Value    = "display:none";
                                    this.overtime.Style.Value     = "display:none";
                                    this.ConnectError.Style.Value = "display:none";
                                    this.AgaginError.Style.Value  = "display:none";
                                    //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('餘額不足 , 無法預約');", true);
                                }
                            }
                            else     //超過可接受的補測時間,不可選擇跨年度
                            {
                                trans.Rollback();
                                this.overtime.Style.Value     = "";
                                this.Div1.Style.Value         = "display:none";
                                this.nonecenter.Style.Value   = "display:none";
                                this.noreserve.Style.Value    = "display:none";
                                this.Nonenough.Style.Value    = "display:none";
                                this.ConnectError.Style.Value = "display:none";
                                this.AgaginError.Style.Value  = "display:none";
                            }
                        }
                        else     //使用者變更的鑑測站與原本選擇的鑑測站在可接受的鑑測項目上有差異
                        {
                            trans.Rollback();
                            this.nonecenter.Style.Value   = "";
                            this.Div1.Style.Value         = "display:none";
                            this.overtime.Style.Value     = "display:none";
                            this.noreserve.Style.Value    = "display:none";
                            this.Nonenough.Style.Value    = "display:none";
                            this.ConnectError.Style.Value = "display:none";
                            this.AgaginError.Style.Value  = "display:none";
                        }
                    }
                    catch (Exception ex)
                    {
                        Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                        trans.Rollback();
                        this.Div1.Style.Value         = "";
                        this.nonecenter.Style.Value   = "display:none";
                        this.overtime.Style.Value     = "display:none";
                        this.noreserve.Style.Value    = "display:none";
                        this.Nonenough.Style.Value    = "display:none";
                        this.ConnectError.Style.Value = "display:none";
                        this.AgaginError.Style.Value  = "display:none";
                        //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('網路連線異常 , 請重新作業');", true);
                    }
                    finally
                    {
                        trans.Dispose();
                        conn.Close();
                    }
                    break;

                case "againreserve":
                    this.AgaginError.Style.Value  = "";
                    this.Div1.Style.Value         = "display:none";
                    this.overtime.Style.Value     = "display:none";
                    this.nonecenter.Style.Value   = "display:none";
                    this.Nonenough.Style.Value    = "display:none";
                    this.ConnectError.Style.Value = "display:none";
                    this.noreserve.Style.Value    = "display:none";
                    break;

                case "noreserve":
                    this.noreserve.Style.Value    = "";
                    this.Div1.Style.Value         = "display:none";
                    this.overtime.Style.Value     = "display:none";
                    this.nonecenter.Style.Value   = "display:none";
                    this.Nonenough.Style.Value    = "display:none";
                    this.ConnectError.Style.Value = "display:none";
                    this.AgaginError.Style.Value  = "display:none";
                    break;
                }
            }
            else
            {
                this.AgaginError.Style.Value  = "";
                this.Div1.Style.Value         = "display:none";
                this.overtime.Style.Value     = "display:none";
                this.nonecenter.Style.Value   = "display:none";
                this.Nonenough.Style.Value    = "display:none";
                this.ConnectError.Style.Value = "display:none";
                this.noreserve.Style.Value    = "display:none";
            }
        }
        CultureInfo cii = new CultureInfo("zh-TW");
        Thread.CurrentThread.CurrentCulture = cii;
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string _selectdate = selectDate.Text;

        if (Session["player"] != null && Request.QueryString["center_code"] != null && Request.QueryString["center_code"] != "" && Request.QueryString["date"] != null && Request.QueryString["date"] != "")
        {
            if (Lib.SysSetting.CheckYear(Convert.ToDateTime(selectDate.Text)))
            {
                CultureInfo ci_en = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentCulture = ci_en;
                Dictionary <string, object> d = new Dictionary <string, object>();
                DateTime        reserveDate   = Convert.ToDateTime(Request.QueryString["date"].ToString().Trim());
                DateTime        Checkover     = reserveDate.AddDays(-30);
                Lib.DataUtility du            = new Lib.DataUtility();
                d.Add("id", ((Lib.Player)Session["player"]).ID);
                d.Add("reserveDate", reserveDate);
                d.Add("checkover", Checkover);
                DataTable dt_again = du.getDataTableByText("select count(id) as count from result where id = @id and status = '205' AND date BETWEEN @checkover AND @reserveDate", d);
                if (Convert.ToInt32(dt_again.Rows[0]["count"].ToString()) == 0)
                {
                    DateTime     newreserveDate = Lib.SysSetting.ToWorldDate(_selectdate);
                    DateTime     newCheckover   = newreserveDate.AddDays(-30);
                    DateTime     firstday       = new DateTime(newreserveDate.Year, 1, 1);
                    DateTime     lastday        = new DateTime(newreserveDate.Year, 12, 31);
                    DateTime     Start          = new DateTime(newreserveDate.Year, newreserveDate.Month, 1);
                    DateTime     End            = Start.AddMonths(1).AddDays(-1);
                    SqlParameter _p1            = new SqlParameter("message", SqlDbType.NVarChar, 50);
                    SqlParameter _p2            = new SqlParameter("id", ((Lib.Player)Session["player"]).ID);
                    SqlParameter _p3            = new SqlParameter("reserveDate", newreserveDate);
                    SqlParameter _p4            = new SqlParameter("start", Start);
                    SqlParameter _p5            = new SqlParameter("end", End);
                    SqlParameter _p6            = new SqlParameter("checkover", newCheckover);
                    SqlParameter _p7            = new SqlParameter("firstday", firstday);
                    SqlParameter _p8            = new SqlParameter("lastday", lastday);
                    _p1.Direction = ParameterDirection.Output;
                    List <SqlParameter> list = new List <SqlParameter>();
                    list.Add(_p1);
                    list.Add(_p2);
                    list.Add(_p3);
                    list.Add(_p4);
                    list.Add(_p5);
                    list.Add(_p6);
                    list.Add(_p7);
                    list.Add(_p8);
                    SqlParameter[] sqls = list.ToArray();
                    du.executeNonQueryBysp("ChangePlayerBySelfRep", sqls);
                    switch (_p1.Value.ToString())
                    {
                    case "canreserve":
                        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDB"].ConnectionString);
                        conn.Open();
                        SqlCommand     comm = conn.CreateCommand();
                        SqlTransaction trans;
                        trans            = conn.BeginTransaction("mytrans");
                        comm.Connection  = conn;
                        comm.Transaction = trans;
                        DataTable dt = new DataTable();
                        try
                        {
                            comm.Parameters.Clear();
                            SqlParameter p1 = new SqlParameter("date", Convert.ToDateTime(Request.QueryString["date"].ToString().Trim()));
                            SqlParameter p2 = new SqlParameter("center_code", Request.QueryString["center_code"].ToString().Trim());
                            SqlParameter p3 = new SqlParameter("op_id", ((Lib.Player)Session["player"]).ID);
                            comm.Parameters.Add(p1);
                            comm.Parameters.Add(p2);
                            comm.Parameters.Add(p3);
                            comm.CommandType = CommandType.Text;
                            comm.CommandText = "select sid,birth from Result where date = @date and center_code = @center_code and id = @op_id and status = '000'";
                            dt.Load(comm.ExecuteReader());
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                comm.Parameters.Clear();
                                comm.Parameters.Add("age", Lib.SysSetting.ConvertAge(Convert.ToDateTime(dt.Rows[i]["birth"]), Lib.SysSetting.ToWorldDate(_selectdate)));
                                comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                                comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                comm.Parameters.Add("op_id", ((Lib.Player)Session["player"]).ID);
                                comm.Parameters.Add("sid", dt.Rows[i]["sid"].ToString());
                                comm.CommandType = CommandType.Text;
                                comm.CommandText = "UPDATE Result SET age = @age, date = @date, center_code = @center_code where sid = @sid and id = @op_id ";
                                comm.ExecuteNonQuery();
                            }
                            DataTable dt_reserved = new DataTable();
                            comm.Parameters.Clear();
                            comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                            comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                            comm.CommandType = CommandType.StoredProcedure;
                            comm.CommandText = "Ex102_GetCenterLimit";

                            //comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                            //comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_selectdate));
                            //comm.CommandText = "select count (id) as reserved,(select limit from center where center_code = @center_code) as limit from result where center_code = @center_code and date = @date";
                            dt_reserved.Load(comm.ExecuteReader());
                            //if (((Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString())) >= 0))
                            if (Convert.ToInt32(dt_reserved.Rows[0]["allow"]) >= 0)
                            {
                                //if ((Convert.ToInt32(oldcount.Text) <= (Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString()))))
                                trans.Commit();
                                newcenter.Text                     = cneterSel.SelectedItem.Text;
                                newcount.Text                      = oldcount.Text;
                                newdate.Text                       = _selectdate;
                                this.Result.Style.Value            = "";
                                this.ReturnStep1.Style.Value       = "";
                                this.OrderStep1.Style.Value        = "display:none";
                                this.SureTimeAndPlace.Style.Value  = "display:none";
                                this.Nonenough.Style.Value         = "display:none";
                                this.thisyearnevertest.Style.Value = "display:none";
                                this.AgaginError.Style.Value       = "display:none";
                                this.noreserve.Style.Value         = "display:none";
                                this.Div1.Style.Value              = "display:none";
                                #region 通知受測人員變更報進
                                MailMessage  _MailToUser        = new MailMessage();
                                StreamReader _MailContentToUser = new StreamReader(Server.MapPath(Request.ApplicationPath) + "\\Mail\\UpdateSelfReserve.txt");
                                _MailToUser.Body = _MailContentToUser.ReadToEnd();
                                _MailToUser.Body = _MailToUser.Body.Replace("%olddate%", olddate.Text);
                                _MailToUser.Body = _MailToUser.Body.Replace("%oldlocation%", oldcenter.Text);
                                _MailToUser.Body = _MailToUser.Body.Replace("%newdate%", newdate.Text);
                                _MailToUser.Body = _MailToUser.Body.Replace("%newlocation%", newcenter.Text);
                                Lib.SysSetting.SaveLetter(((Lib.Player)Session["player"]).Mail + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "報進變更通知信", "00");
                                Lib.SysSetting.AddLog("替代項目變更報進", ((Lib.Player)Session["player"]).ID, "變更報進 , 日期:" + newdate.Text + " , 地點:" + newcenter.Text, System.DateTime.Now);
                                #endregion
                            }
                            else
                            {
                                trans.Rollback();
                                this.Nonenough.Style.Value         = "";
                                this.thisyearnevertest.Style.Value = "display:none";
                                this.AgaginError.Style.Value       = "display:none";
                                this.noreserve.Style.Value         = "display:none";
                                this.Div1.Style.Value = "display:none";
                                //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('餘額不足 , 無法預約');", true);
                            }
                        }
                        catch (Exception ex)
                        {
                            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                            trans.Rollback();
                            this.Div1.Style.Value = "";
                            this.thisyearnevertest.Style.Value = "display:none";
                            this.AgaginError.Style.Value       = "display:none";
                            this.noreserve.Style.Value         = "display:none";
                            this.Nonenough.Style.Value         = "display:none";
                            //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('網路連線異常 , 請重新作業');", true);
                        }
                        finally
                        {
                            trans.Dispose();
                            conn.Close();
                        }
                        break;

                    case "noreserve":
                        this.noreserve.Style.Value         = "";
                        this.thisyearnevertest.Style.Value = "display:none";
                        this.AgaginError.Style.Value       = "display:none";
                        this.Div1.Style.Value      = "display:none";
                        this.Nonenough.Style.Value = "display:none";
                        break;

                    case "againreserve":
                        this.AgaginError.Style.Value       = "";
                        this.thisyearnevertest.Style.Value = "display:none";
                        this.noreserve.Style.Value         = "display:none";
                        this.Div1.Style.Value      = "display:none";
                        this.Nonenough.Style.Value = "display:none";
                        break;

                    case "thisyearnevertest":
                        this.thisyearnevertest.Style.Value = "";
                        this.AgaginError.Style.Value       = "display:none";
                        this.noreserve.Style.Value         = "display:none";
                        this.Div1.Style.Value      = "display:none";
                        this.Nonenough.Style.Value = "display:none";
                        break;
                    }
                }
                else
                {
                    this.AgaginError.Style.Value       = "";
                    this.thisyearnevertest.Style.Value = "display:none";
                    this.noreserve.Style.Value         = "display:none";
                    this.Div1.Style.Value      = "display:none";
                    this.Nonenough.Style.Value = "display:none";
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('此年度目前不開放報進 , 開放時系統將會公告');", true);
            }
        }
        CultureInfo cii = new CultureInfo("zh-TW");
        Thread.CurrentThread.CurrentCulture = cii;
        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
    }
Exemplo n.º 24
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Account a = (Account)Session["account"];

        if (a.Role != ((int)SysSetting.Role.admin_hq).ToString())
        {
            Response.Redirect("~/index.aspx");
        }
        else
        {
            //ch1 = cbl_WeekCheck.Items[0].Selected;
            //ch2 = cbl_WeekCheck.Items[1].Selected;
            //ch3 = cbl_WeekCheck.Items[2].Selected;
            //ch4 = cbl_WeekCheck.Items[3].Selected;
            //ch5 = cbl_WeekCheck.Items[4].Selected;
            //ch6 = cbl_WeekCheck.Items[5].Selected;
            //ch7 = cbl_WeekCheck.Items[6].Selected;
            ch1 = cb_Monday.Checked;
            ch2 = cb_Tuesday.Checked;
            ch3 = cb_Wednesday.Checked;
            ch4 = cb_Thursday.Checked;
            ch5 = cb_Friday.Checked;
            ch6 = cb_Saturday.Checked;
            ch7 = cb_Sunday.Checked;

            int year_addone = System.DateTime.Now.Year + 1 - 1911;
            year.Text = "民國" + year_addone.ToString() + "年度";
            Year      = System.DateTime.Now.Year + 1;//西元明年

            wk = new Lib.WorkWeek(System.DateTime.Now.Year + 1);
            lab_LastYear.Text = "(民國" + year_addone.ToString() + "年)";
            if (wk.isSetYear == true)
            {
                lab_SetStatus.Text        = "已設定";
                lab_SetStatus.ForeColor   = Color.Blue;
                btn_SetWorkWeek.Text      = "更新";
                btn_SetWorkWeek.ForeColor = Color.Blue;
                btn_SetWorkWeek.BackColor = Color.Aquamarine;
                //cbl_WeekCheck.Items[0].Selected = wk.DicWeek[DayOfWeek.Monday];
                //cbl_WeekCheck.Items[1].Selected = wk.DicWeek[DayOfWeek.Tuesday];
                //cbl_WeekCheck.Items[2].Selected = wk.DicWeek[DayOfWeek.Wednesday];
                //cbl_WeekCheck.Items[3].Selected = wk.DicWeek[DayOfWeek.Thursday];
                //cbl_WeekCheck.Items[4].Selected = wk.DicWeek[DayOfWeek.Friday];
                //cbl_WeekCheck.Items[5].Selected = wk.DicWeek[DayOfWeek.Saturday];
                //cbl_WeekCheck.Items[6].Selected = wk.DicWeek[DayOfWeek.Sunday];
                cb_Monday.Checked    = wk.DicWeek[DayOfWeek.Monday];
                cb_Tuesday.Checked   = wk.DicWeek[DayOfWeek.Tuesday];
                cb_Wednesday.Checked = wk.DicWeek[DayOfWeek.Wednesday];
                cb_Thursday.Checked  = wk.DicWeek[DayOfWeek.Thursday];
                cb_Friday.Checked    = wk.DicWeek[DayOfWeek.Friday];
                cb_Saturday.Checked  = wk.DicWeek[DayOfWeek.Saturday];
                cb_Sunday.Checked    = wk.DicWeek[DayOfWeek.Sunday];
            }
            else
            {
                lab_SetStatus.Text        = "未設定";
                lab_SetStatus.ForeColor   = Color.Red;
                btn_SetWorkWeek.Text      = "設定";
                btn_SetWorkWeek.ForeColor = Color.Red;
                btn_SetWorkWeek.BackColor = Color.Pink;
                //cbl_WeekCheck.Items[0].Selected = false;
                //cbl_WeekCheck.Items[1].Selected = false;
                //cbl_WeekCheck.Items[2].Selected = false;
                //cbl_WeekCheck.Items[3].Selected = false;
                //cbl_WeekCheck.Items[4].Selected = false;
                //cbl_WeekCheck.Items[5].Selected = false;
                //cbl_WeekCheck.Items[6].Selected = false;
                cb_Monday.Checked    = false;
                cb_Tuesday.Checked   = false;
                cb_Wednesday.Checked = false;
                cb_Thursday.Checked  = false;
                cb_Friday.Checked    = false;
                cb_Saturday.Checked  = false;
                cb_Sunday.Checked    = false;
            }



            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            d.Add("year", System.DateTime.Now.Year + 1);
            DataTable dt = du.getDataTableByText("select * from year where year = @year", d);
            if (dt.Rows.Count == 1)
            {
                if (Convert.ToBoolean(dt.Rows[0]["islock"]))
                {
                    year_status.Text      = "關閉報進";
                    year_status.ForeColor = Color.Red;
                    Button1.Text          = "開放";
                    Button1.ForeColor     = Color.Green;
                    Button1.BackColor     = Color.PaleGreen;
                    isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                }
                else
                {
                    year_status.Text      = "開放報進";
                    year_status.ForeColor = Color.Green;
                    Button1.Text          = "關閉";
                    Button1.ForeColor     = Color.Red;
                    Button1.BackColor     = Color.Pink;
                    isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                }
            }


            if (IsPostBack)
            {
                //int year_addone = System.DateTime.Now.Year + 1 - 1911;
                year.Text = "民國" + year_addone.ToString() + "年度";
                d.Clear();
                d.Add("year", System.DateTime.Now.Year + 1);
                dt = du.getDataTableByText("select * from year where year = @year", d);
                if (dt.Rows.Count == 1)
                {
                    if (Convert.ToBoolean(dt.Rows[0]["islock"]))
                    {
                        year_status.Text      = "關閉報進";
                        year_status.ForeColor = Color.Red;
                        Button1.Text          = "開放";
                        Button1.ForeColor     = Color.Green;
                        Button1.BackColor     = Color.PaleGreen;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                    }
                    else
                    {
                        year_status.Text      = "開放報進";
                        year_status.ForeColor = Color.Green;
                        Button1.Text          = "關閉";
                        Button1.ForeColor     = Color.Red;
                        Button1.BackColor     = Color.Pink;
                        isopen = Convert.ToBoolean(dt.Rows[0]["islock"]);
                    }
                }
                //前端已經先關好站了,再來處理關站刪除
                if (HF_CheckDel.Value == "ok")
                {
                    HF_CheckDel.Value = "no";
                    //逐筆寄信後刪除
                    string date        = txb_InqDate.Text;
                    string center_name = DropDownList1.SelectedItem.Text;
                    string reason      = txb_Reason.Text;//關站原因
                    for (int i = 0; i < GridView2.Rows.Count; i++)
                    {
                        string sid  = GridView2.Rows[i].Cells[0].Text;
                        string id   = GridView2.Rows[i].Cells[2].Text;
                        string mail = GridView2.Rows[i].Cells[8].Text;


                        //檢查信箱欄位,有的才寄信
                        //信件文字檔案夾位置
                        string       dd = Server.MapPath(Request.ApplicationPath);
                        StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\OffStation.txt");
                        //先寄信
                        if (!string.IsNullOrEmpty(mail) & mail != "&nbsp;")//表格空字串會變成「&nbsp;」
                        {
                            MailMessage _MailToUser = new MailMessage();
                            _MailToUser.Body = _MailContentToUser.ReadToEnd();
                            _MailToUser.Body = _MailToUser.Body.Replace("%reason%", reason);
                            _MailToUser.Body = _MailToUser.Body.Replace("%id%", (id.Substring(0, id.Length - 3) + "***"));
                            _MailToUser.Body = _MailToUser.Body.Replace("%date%", date);
                            _MailToUser.Body = _MailToUser.Body.Replace("%location%", center_name);
                            Lib.SysSetting.SaveLetter(mail + "@webmail.mil.tw", "國軍體能鑑測中心", _MailToUser.Body, "臨時關站取消報名通知信", "00");
                        }

                        //再刪報名
                        du.executeNonQueryBysp("Ex107_DelResultbySid", "sid", sid);
                    }
                    Lib.SysSetting.AddLog("臨時關站", "admin", "臨時關站取消報名 , 日期:" + date + " , 地點:" + center_name, System.DateTime.Now);
                    GridView2.DataSource = null;
                    GridView2.DataBind();
                    CloseEnter();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('鑑測站已關閉,報名資料已刪除。');", true);

                    //重新整理網頁
                    //Response.Redirect(Request.FilePath);
                }
            }
        }
    }
Exemplo n.º 25
0
    protected void AddAcc_Click(object sender, EventArgs e)
    {
        Lib.Account a = (Lib.Account)Session["account"];
        if (a.Role == "2")
        {
            if (password.Text.Length > 0 && acc_random.Text.Length > 0)
            {
                try
                {
                    Lib.DataUtility du = new Lib.DataUtility();
                    DataTable       dt = du.getDataTableBysp("CheckAccExist", "acc", acc.Text + acc_random.Text);
                    if (dt.Rows[0][0].ToString() == "0")
                    {
                        Dictionary <string, object> d = new Dictionary <string, object>();
                        //Lib.DataUtility du = new Lib.DataUtility();
                        int         index = GridView1.SelectedIndex;
                        GridViewRow row   = GridView1.Rows[index];
                        d.Add("sid", sid.Text);
                        d.Add("account", acc.Text + acc_random.Text);
                        d.Add("acc", a.AccountName);
                        d.Add("password", password.Text);
                        du.executeNonQueryBysp("InsertAccByAsk", d);
                        d.Clear();
                        d.Add("sid", sid.Text);
                        du.executeNonQueryByText("delete from AskAccount where sid = @sid", d);
                        d.Clear();
                        d.Add("acc", acc.Text + acc_random.Text);
                        d.Add("optionCode", "1");
                        du.executeNonQueryBysp("AddOptions", d);

                        #region 通知申請者
                        string       cwd                = System.IO.Directory.GetCurrentDirectory();
                        string       dd                 = Server.MapPath(Request.ApplicationPath);
                        MailMessage  _MailToUser        = new MailMessage();
                        StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\CheckAdvancedUser.txt");
                        //_MailToUser.Body = _MailContent.ReadToEnd().Replace("%detail%", _detailtable);
                        _MailToUser.Body = _MailContentToUser.ReadToEnd();
                        _MailToUser.Body = _MailToUser.Body.Replace("%account%", acc.Text + acc_random.Text);
                        _MailToUser.Body = _MailToUser.Body.Replace("%password%", password.Text);
                        Lib.SysSetting.SaveLetter(mail.Text + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "團體報進負責人申請成功通知信", "00");
                        Lib.SysSetting.AddLog("審核帳號", a.AccountName, "新增團體報進帳號:" + acc.Text + acc_random.Text, DateTime.Now);
                        #endregion

                        acc.Text        = "";
                        acc_random.Text = "";
                        password.Text   = "";
                        sid.Text        = "";
                        id.Text         = "";
                        unit_code.Text  = "";
                        name.Text       = "";
                        rank_code.Text  = "";
                        tel.Text        = "";
                        mail.Text       = "";
                        cellphone.Text  = "";
                        ip.Text         = "";
                        GridView1.DataBind();
                        this.accexist.Style.Value = "display:none";
                        this.error.Style.Value    = "display:none";
                        this.success.Style.Value  = "";
                    }
                    else
                    {
                        this.accexist.Style.Value = "";
                        this.error.Style.Value    = "display:none";
                        this.success.Style.Value  = "display:none";
                    }
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                    acc.Text        = "";
                    password.Text   = "";
                    acc_random.Text = "";
                    sid.Text        = "";
                    id.Text         = "";
                    unit_code.Text  = "";
                    name.Text       = "";
                    rank_code.Text  = "";
                    tel.Text        = "";
                    mail.Text       = "";
                    cellphone.Text  = "";
                    ip.Text         = "";
                }
            }
            else
            {
                this.error.Style.Value    = "";
                this.success.Style.Value  = "display:none";
                this.accexist.Style.Value = "display:none";
            }
        }
    }
Exemplo n.º 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["account"] != null)
        {
            Account a = (Account)Session["account"];
            if (a.Role != ((int)SysSetting.Role.admin_hq).ToString())
            {
                Response.Redirect("~/index.aspx");
            }
            else
            {
                Check_memo = false;
                Sid        = Request.QueryString["sid"].ToString();
                if (Page.IsPostBack == false)//剛開始載入頁面
                {
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    Lib.DataUtility             du = new Lib.DataUtility();
                    d.Add("sid", Sid);
                    DataTable dt = du.getDataTableBysp("Ex108_GetResultDataBySid", d);
                    if (dt.Rows.Count > 0)
                    {
                        //個人基本資料
                        if (!string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()))
                        {
                            Id = dt.Rows[0]["id"].ToString();
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["name"].ToString()))
                        {
                            Name             = dt.Rows[0]["name"].ToString();
                            txb_Name.Text    = Name;
                            Old_Name         = Name;
                            lab_OldName.Text = "(" + Old_Name + ")";
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["birth"].ToString()))
                        {
                            Birth             = dt.Rows[0]["birth"].ToString();
                            txb_Birth.Text    = Birth;
                            Old_Birth         = Birth;
                            lab_OldBirth.Text = "(" + Old_Birth + ")";
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["age"].ToString()))
                        {
                            Age             = dt.Rows[0]["age"].ToString();
                            txb_Age.Text    = Age;
                            Old_Age         = Age;
                            lab_OldAge.Text = "(" + Age + ")";
                        }
                        //檢查項次欄位
                        if (!string.IsNullOrEmpty(dt.Rows[0]["memo"].ToString()))
                        {
                            Check_memo = true;
                            Memo       = dt.Rows[0]["memo"].ToString();
                        }

                        //項次名稱
                        //項次1
                        if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups_name"].ToString()))
                        {
                            ItemName1           = dt.Rows[0]["sit_ups_name"].ToString();
                            lab_ItemScore1.Text = "(5)" + ItemName1 + "(成績)";
                            if (Check_memo == true)
                            {
                                if (Memo.Substring(0, 1) == "F" || Memo.Substring(0, 1) == "G" || Memo.Substring(0, 1) == "J")
                                {
                                    lab_Item1.Text = "(4)" + ItemName1 + Sec;
                                }
                                else
                                {
                                    lab_Item1.Text = "(4)" + ItemName1 + Count;
                                }
                            }
                            else
                            {
                                lab_Item1.Text = "(4)" + ItemName1 + "(次/秒數)";
                            }
                        }
                        //項次2
                        if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups_name"].ToString()))
                        {
                            ItemName2           = dt.Rows[0]["push_ups_name"].ToString();
                            lab_ItemScore2.Text = "(7)" + ItemName2 + "(成績)";
                            if (Check_memo == true)
                            {
                                if (Memo.Substring(1, 1) == "F" || Memo.Substring(1, 1) == "G" || Memo.Substring(1, 1) == "J")
                                {
                                    lab_Item2.Text = "(6)" + ItemName2 + Sec;
                                }
                                else
                                {
                                    lab_Item2.Text = "(6)" + ItemName2 + Count;
                                }
                            }
                            else
                            {
                                lab_Item2.Text = "(6)" + ItemName2 + "(次/秒數)";
                            }
                        }
                        //項次3
                        if (!string.IsNullOrEmpty(dt.Rows[0]["run_name"].ToString()))
                        {
                            ItemName3           = dt.Rows[0]["run_name"].ToString();
                            lab_ItemScore3.Text = "(9)" + ItemName3 + "(成績)";
                            if (Check_memo == true)
                            {
                                if (Memo.Substring(2, 1) == "0" || Memo.Substring(2, 1) == "F" || Memo.Substring(2, 1) == "G" || Memo.Substring(2, 1) == "J")
                                {
                                    lab_Item3.Text = "(8)" + ItemName3 + Sec;
                                }
                                else
                                {
                                    lab_Item3.Text = "(8)" + ItemName3 + Count;
                                }
                            }
                            else
                            {
                                lab_Item3.Text = "(8)" + ItemName3 + "(次/秒數)";
                            }
                        }
                        //項次次數及成績
                        //項次1
                        if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups_score"].ToString()))
                        {
                            ItemScore1     = dt.Rows[0]["sit_ups_score"].ToString();
                            Old_ItemScore1 = ItemScore1;
                            if (ItemScore1 == "999")
                            {
                                lab_OldItem1.Text      = "(未完測)";
                                lab_OldItemScore1.Text = "(未完測)";
                            }
                            else
                            {
                                Old_ItemScore1         = ItemScore1;
                                txb_ItemScore1.Text    = ItemScore1;
                                lab_OldItemScore1.Text = "(" + Old_ItemScore1 + ")";
                            }
                            //項次1次/秒數
                            if (!string.IsNullOrEmpty(dt.Rows[0]["sit_ups"].ToString()))
                            {
                                Item1             = dt.Rows[0]["sit_ups"].ToString();
                                Old_Item1         = Item1;
                                txb_Item1.Text    = Item1;
                                lab_OldItem1.Text = "(" + Old_Item1 + ")";
                            }
                            else
                            {
                                Item1     = string.Empty;
                                Old_Item1 = string.Empty;
                            }
                        }
                        else
                        {
                            ItemScore1             = string.Empty;
                            Old_ItemScore1         = string.Empty;
                            Item1                  = string.Empty;
                            Old_Item1              = string.Empty;
                            lab_OldItem1.Text      = "(未測驗)";
                            lab_OldItemScore1.Text = "(未測驗)";
                        }

                        //項次2
                        if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups_score"].ToString()))
                        {
                            ItemScore2     = dt.Rows[0]["push_ups_score"].ToString();
                            Old_ItemScore2 = ItemScore2;
                            if (ItemScore2 == "999")
                            {
                                lab_OldItem2.Text      = "(未完測)";
                                lab_OldItemScore2.Text = "(未完測)";
                            }
                            else
                            {
                                Old_ItemScore2         = ItemScore2;
                                txb_ItemScore2.Text    = ItemScore2;
                                lab_OldItemScore2.Text = "(" + Old_ItemScore2 + ")";
                            }
                            //項次2次/秒數
                            if (!string.IsNullOrEmpty(dt.Rows[0]["push_ups"].ToString()))
                            {
                                Item2             = dt.Rows[0]["push_ups"].ToString();
                                Old_Item2         = Item2;
                                txb_Item2.Text    = Item2;
                                lab_OldItem2.Text = "(" + Old_Item2 + ")";
                            }
                            else
                            {
                                Item2     = string.Empty;
                                Old_Item2 = string.Empty;
                            }
                        }
                        else
                        {
                            ItemScore2             = string.Empty;
                            Old_ItemScore2         = string.Empty;
                            Item2                  = string.Empty;
                            Old_Item2              = string.Empty;
                            lab_OldItem2.Text      = "(未測驗)";
                            lab_OldItemScore2.Text = "(未測驗)";
                        }
                        //項次3
                        if (!string.IsNullOrEmpty(dt.Rows[0]["run_score"].ToString()))
                        {
                            ItemScore3     = dt.Rows[0]["run_score"].ToString();
                            Old_ItemScore3 = ItemScore3;
                            if (ItemScore3 == "9999")
                            {
                                lab_OldItem3.Text      = "(未完測)";
                                lab_OldItemScore3.Text = "(未完測)";
                            }
                            else
                            {
                                Old_ItemScore3         = ItemScore3;
                                txb_ItemScore3.Text    = ItemScore3;
                                lab_OldItemScore3.Text = "(" + Old_ItemScore3 + ")";
                            }
                            //項次3次/秒數
                            if (!string.IsNullOrEmpty(dt.Rows[0]["run"].ToString()))
                            {
                                Item3             = dt.Rows[0]["run"].ToString();
                                Old_Item3         = Item3;
                                txb_Item3.Text    = Item3;
                                lab_OldItem3.Text = "(" + Old_Item3 + ")";
                            }
                            else
                            {
                                Item3     = string.Empty;
                                Old_Item3 = string.Empty;
                            }
                        }
                        else
                        {
                            ItemScore3             = string.Empty;
                            Old_ItemScore3         = string.Empty;
                            Item3                  = string.Empty;
                            Old_Item3              = string.Empty;
                            lab_OldItem3.Text      = "(未測驗)";
                            lab_OldItemScore3.Text = "(未測驗)";
                        }

                        //總評
                        if (!string.IsNullOrEmpty(dt.Rows[0]["status"].ToString()))
                        {
                            Status = dt.Rows[0]["status"].ToString();
                            if (Status == "202")
                            {
                                ddl_Status.SelectedIndex = 0;
                            }
                            else
                            {
                                ddl_Status.SelectedIndex = 1;
                            }
                            Old_Status         = Status;
                            lab_OldStatus.Text = (Status == "202") ? "(合格)" : "(不合格)";
                        }
                    }
                }
                else//提交資料後回傳
                {
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    Lib.DataUtility             du = new Lib.DataUtility();
                    Name  = txb_Name.Text.Trim();
                    Birth = txb_Birth.Text.Trim();
                    Age   = txb_Age.Text.Trim();
                    d.Add("sid", Sid);
                    d.Add("name", Name);
                    d.Add("birth", Birth);
                    d.Add("age", Age);
                    //項次1次/秒數
                    if (!string.IsNullOrEmpty(txb_Item1.Text))
                    {
                        Item1 = txb_Item1.Text.Trim();
                        d.Add("sit_ups", Item1);
                    }
                    else
                    {
                        Item1 = string.Empty;
                        d.Add("sit_ups", DBNull.Value);
                    }
                    //項次1成績
                    if (!string.IsNullOrEmpty(txb_ItemScore1.Text))
                    {
                        ItemScore1 = txb_ItemScore1.Text.Trim();
                        d.Add("sit_ups_score", ItemScore1);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Old_ItemScore1) && Old_ItemScore3 == "999")
                        {
                            ItemScore1 = Old_ItemScore1;
                            d.Add("sit_ups_score", ItemScore1);
                        }
                        else
                        {
                            ItemScore1 = string.Empty;
                            d.Add("sit_ups_score", DBNull.Value);
                        }
                    }
                    //項次2次/秒數
                    if (!string.IsNullOrEmpty(txb_Item2.Text))
                    {
                        Item2 = txb_Item2.Text.Trim();
                        d.Add("push_ups", Item2);
                    }
                    else
                    {
                        Item2 = string.Empty;
                        d.Add("push_ups", DBNull.Value);
                    }
                    //項次2成績
                    if (!string.IsNullOrEmpty(txb_ItemScore2.Text))
                    {
                        ItemScore2 = txb_ItemScore2.Text.Trim();
                        d.Add("push_ups_score", ItemScore2);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Old_ItemScore2) && Old_ItemScore2 == "999")
                        {
                            ItemScore2 = Old_ItemScore2;
                            d.Add("push_ups_score", ItemScore2);
                        }
                        else
                        {
                            ItemScore2 = string.Empty;
                            d.Add("push_ups_score", DBNull.Value);
                        }
                    }
                    //項次3次/秒數
                    if (!string.IsNullOrEmpty(txb_Item3.Text))
                    {
                        Item3 = txb_Item3.Text.Trim();
                        d.Add("run", Item3);
                    }
                    else
                    {
                        Item3 = string.Empty;
                        d.Add("run", DBNull.Value);
                    }
                    //項次3成績
                    if (!string.IsNullOrEmpty(txb_ItemScore3.Text))
                    {
                        ItemScore3 = txb_ItemScore3.Text.Trim();
                        d.Add("run_score", ItemScore3);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(Old_ItemScore3) && Old_ItemScore3 == "9999")
                        {
                            ItemScore3 = Old_ItemScore3;
                            d.Add("run_score", ItemScore3);
                        }
                        else
                        {
                            ItemScore3 = string.Empty;
                            d.Add("run_score", DBNull.Value);
                        }
                    }
                    //總評
                    if (ddl_Status.SelectedIndex == 0)
                    {
                        Status = "202";
                    }
                    else if (ddl_Status.SelectedIndex == 1)
                    {
                        Status = "203";
                    }
                    else
                    {
                        Status = Old_Status;
                    }
                    d.Add("status", Status);

                    try
                    {
                        //更新資料
                        du.executeNonQueryBysp("Ex108_UpdateResultData", d);
                        //寫入log
                        UpdateLog = string.Empty;
                        if (!string.IsNullOrEmpty(Sid))
                        {
                            UpdateLog += "sid-" + Sid + ',';
                        }
                        if (!string.IsNullOrEmpty(Id))
                        {
                            UpdateLog += "id-" + Id + ',';
                        }
                        if (Old_Name != Name)
                        {
                            UpdateLog += "名[" + Old_Name + "," + Name + "]";
                        }
                        if (Old_Birth != Birth)
                        {
                            UpdateLog += "生[" + Old_Birth + "," + Birth + "]";
                        }
                        if (Old_Age != Age)
                        {
                            UpdateLog += "歲[" + Old_Age + "," + Age + "]";
                        }
                        UpdateLog += "項1[" + Old_ItemScore1 + "," + ItemScore1 + "]項2[" + Old_ItemScore2 + "," + ItemScore2 + "]項3[" + Old_ItemScore3 + "," + ItemScore3 + "]總[" + ((Old_Status == "202") ? "合格" : "不合格") + "," + ((Status == "202") ? "合格" : "不合格") + "]";
                        SysSetting.AddLog("成績補正", a.AccountName, UpdateLog, DateTime.Now);
                        //回傳成功
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside_r('ok');window.close()", true);
                    }
                    catch (Exception ex)
                    {
                        //記錄錯誤訊息
                        SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                        //回傳失敗
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "window.opener.outside_r('Err');window.close()", true);
                    }
                }
            }
        }
        if (Session["account"] == null && Session["player"] == null)
        {
            Response.Redirect("~/Login.aspx");
        }
    }
Exemplo n.º 27
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Session["player"] != null)
        {
            if (selectDate.Text != "" && cneterSel.SelectedValue != "0")
            {
                if (Lib.SysSetting.CheckYear(Convert.ToDateTime(selectDate.Text)))
                {
                    try
                    {
                        string                      _OP     = ((Lib.Player)Session["player"]).ID;
                        string                      _center = cneterSel.SelectedItem.Value.ToString();
                        string                      _date   = selectDate.Text;
                        Lib.DataUtility             dux     = new Lib.DataUtility();
                        Dictionary <string, object> d       = new Dictionary <string, object>();
                        d.Add("account", _OP);
                        DataTable _player = dux.getDataTableByText("select id,gender,CONVERT(VARCHAR(10),Player.birth, 111) AS birth,name,unit_code,rank_code,mail,oversea from Player where id = @account", d);

                        string _id     = _player.Rows[0]["id"].ToString();
                        string _gender = _player.Rows[0]["gender"].ToString();
                        string _birth  = _player.Rows[0]["birth"].ToString(); // _birth格式為yyyy/mm/dd
                        //DateTime ss = Convert.ToDateTime(_birth);
                        string _name      = _player.Rows[0]["name"].ToString();
                        string _unit_code = _player.Rows[0]["unit_code"].ToString();
                        string _rank_code = _player.Rows[0]["rank_code"].ToString();
                        string _mail      = _player.Rows[0]["mail"].ToString();
                        string _oversea   = _player.Rows[0]["oversea"].ToString();

                        CultureInfo ci_en = new CultureInfo("en-US");
                        Thread.CurrentThread.CurrentCulture = ci_en;  //資料庫中存放的datetime為西元時區,所以需將時區變更為en-US

                        DateTime     reserveDate = Lib.SysSetting.ToWorldDate(_date);
                        DateTime     firstday    = new DateTime(reserveDate.Year, 1, 1);
                        DateTime     lastday     = new DateTime(reserveDate.Year, 12, 31);
                        DateTime     Start       = new DateTime(reserveDate.Year, reserveDate.Month, 1);
                        DateTime     End         = Start.AddMonths(1).AddDays(-1);
                        DateTime     Checkover   = reserveDate.AddDays(-30);
                        SqlParameter p1          = new SqlParameter("message", SqlDbType.NVarChar, 50);
                        SqlParameter p2          = new SqlParameter("id", _id);                           //身份證號
                        SqlParameter p3          = new SqlParameter("gender", _gender);
                        SqlParameter p4          = new SqlParameter("birth", Convert.ToDateTime(_birth)); //生日
                        SqlParameter p5          = new SqlParameter("name", _name);
                        SqlParameter p6          = new SqlParameter("unit_code", _unit_code);
                        SqlParameter p7          = new SqlParameter("rank_code", _rank_code);
                        SqlParameter p8          = new SqlParameter("mail", _mail);
                        SqlParameter p9          = new SqlParameter("oversea", _oversea);
                        SqlParameter p10         = new SqlParameter("reserveDate", reserveDate);
                        SqlParameter p11         = new SqlParameter("center_code", _center);
                        SqlParameter p12         = new SqlParameter("op_id", _OP);
                        SqlParameter p13         = new SqlParameter("start", Start);
                        SqlParameter p14         = new SqlParameter("end", End);
                        SqlParameter p15         = new SqlParameter("checkover", Checkover);
                        SqlParameter p16         = new SqlParameter("firstday", firstday);
                        SqlParameter p17         = new SqlParameter("lastday", lastday);
                        p1.Direction = ParameterDirection.Output;
                        Lib.DataUtility     du   = new Lib.DataUtility();
                        List <SqlParameter> list = new List <SqlParameter>();
                        list.Add(p1);
                        list.Add(p2);
                        list.Add(p3);
                        list.Add(p4);
                        list.Add(p5);
                        list.Add(p6);
                        list.Add(p7);
                        list.Add(p8);
                        list.Add(p9);
                        list.Add(p10);
                        list.Add(p11);
                        list.Add(p12);
                        list.Add(p13);
                        list.Add(p14);
                        list.Add(p15);
                        list.Add(p16);
                        list.Add(p17);
                        SqlParameter[] sqls = list.ToArray();
                        du.executeNonQueryBysp("AddPlayerBySelf", sqls);

                        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDB"].ConnectionString);
                        conn.Open();
                        SqlCommand     comm = conn.CreateCommand();
                        SqlTransaction trans;
                        trans            = conn.BeginTransaction("mytrans");
                        comm.Connection  = conn;
                        comm.Transaction = trans;
                        DataTable dt_reserved = new DataTable();

                        string       cwd                = System.IO.Directory.GetCurrentDirectory();
                        string       dd                 = Server.MapPath(Request.ApplicationPath);
                        MailMessage  _MailToUser        = new MailMessage();
                        StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\SelfReserve.txt");

                        switch (p1.Value.ToString())
                        {
                        case "canreserve":
                            try
                            {
                                comm.Parameters.Clear();
                                SqlParameter _p2  = new SqlParameter("id", _id);
                                SqlParameter _p5  = new SqlParameter("name", _name);
                                SqlParameter _p4  = new SqlParameter("birth", Convert.ToDateTime(_birth));
                                SqlParameter _p3  = new SqlParameter("gender", _gender);
                                SqlParameter _p6  = new SqlParameter("unit_code", _unit_code);
                                SqlParameter _p7  = new SqlParameter("rank_code", _rank_code);
                                SqlParameter _p10 = new SqlParameter("reserveDate", reserveDate);
                                SqlParameter _p11 = new SqlParameter("center_code", _center);
                                SqlParameter _p12 = new SqlParameter("op_id", _OP);
                                comm.Parameters.Add(_p2);
                                comm.Parameters.Add(_p5);
                                comm.Parameters.Add("age", Lib.SysSetting.ConvertAge(Convert.ToDateTime(_birth), reserveDate));
                                comm.Parameters.Add(_p4);
                                comm.Parameters.Add(_p3);
                                comm.Parameters.Add(_p6);
                                comm.Parameters.Add(_p7);
                                comm.Parameters.Add(_p10);
                                comm.Parameters.Add(_p11);
                                comm.Parameters.Add(_p12);
                                comm.CommandType = CommandType.Text;
                                comm.CommandText = "insert into result (id,name,age,birth,gender,unit_code,rank_code,date,center_code,status,op_id,memo) values(@id,@name,@age,@birth,@gender,@unit_code,@rank_code,@reserveDate,@center_code,'000',@op_id,'999')";
                                comm.ExecuteNonQuery();

                                comm.Parameters.Clear();
                                //comm.Parameters.Add(_p11);
                                //comm.Parameters.Add(_p10);
                                //comm.CommandText = "select count (id) as reserved,(select limit from center where center_code = @center_code) as limit from result where center_code = @center_code and date = @reserveDate ";
                                comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_date));
                                comm.CommandType = CommandType.StoredProcedure;
                                comm.CommandText = "Ex102_GetCenterLimit";
                                dt_reserved.Load(comm.ExecuteReader());
                                //if (((Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString())) >= 0))
                                if (Convert.ToInt32(dt_reserved.Rows[0]["allow"]) >= 0)
                                {
                                    trans.Commit();
                                    this.canreserve.Style.Value   = "";
                                    this.Nonenough.Style.Value    = "display:none";
                                    this.ConnectError.Style.Value = "display:none";
                                    this.bereserve.Style.Value    = "display:none";
                                    this.noreserve.Style.Value    = "display:none";
                                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                                    #region 通知受測人員
                                    _MailToUser.Body = _MailContentToUser.ReadToEnd();
                                    _MailToUser.Body = _MailToUser.Body.Replace("%date%", selectDate.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%location%", cneterSel.SelectedItem.Text);
                                    Lib.SysSetting.SaveLetter(((Lib.Player)Session["player"]).Mail + "@webmail.mil.tw", "國軍體能鑑測中心", _MailToUser.Body, "報進成功通知信", "00");
                                    Lib.SysSetting.AddLog("替代項目報進", ((Lib.Player)Session["player"]).ID, "報進成功 , 日期:" + selectDate.Text + " , 地點:" + cneterSel.SelectedItem.Text, System.DateTime.Now);
                                    #endregion
                                }
                                else
                                {
                                    trans.Rollback();
                                    this.Nonenough.Style.Value    = "";
                                    this.ConnectError.Style.Value = "display:none";
                                    this.canreserve.Style.Value   = "display:none";
                                    this.bereserve.Style.Value    = "display:none";
                                    this.noreserve.Style.Value    = "display:none";
                                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                                }
                            }
                            catch (Exception ex)
                            {
                                Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                                trans.Rollback();
                            }
                            finally
                            {
                                trans.Dispose();
                                conn.Close();
                            }
                            break;

                        case "againreserve":
                            try
                            {
                                DataTable dt_again = new DataTable();
                                comm.Parameters.Clear();
                                SqlParameter _p10 = new SqlParameter("reserveDate", reserveDate);
                                SqlParameter _p2  = new SqlParameter("id", _id);
                                SqlParameter _p15 = new SqlParameter("checkover", Checkover);
                                comm.Parameters.Add(_p2);
                                comm.Parameters.Add(_p10);
                                comm.Parameters.Add(_p15);
                                comm.CommandType = CommandType.Text;
                                comm.CommandText = "select top(1) id,center_code from result where (id = @id) AND (status = '205') AND (date BETWEEN @checkover AND @reserveDate) ORDER BY date DESC";
                                dt_again.Load(comm.ExecuteReader());
                                SqlParameter _p11 = new SqlParameter("center_code", dt_again.Rows[0]["center_code"].ToString());
                                comm.Parameters.Add("age", Lib.SysSetting.ConvertAge(Convert.ToDateTime(_birth), reserveDate));
                                comm.CommandText = "insert into result (id,name,age,birth,gender,unit_code,rank_code,date,center_code,result,status,memo,op_id,sit_ups,sit_ups_score,push_ups,push_ups_score,run,run_score)"
                                                   + "select top(1) r.id,r.name,@age,r.birth,r.gender,r.unit_code,r.rank_code,@reserveDate,r.center_code,r.result,'000',r.memo,r.id,r.sit_ups,r.sit_ups_score,r.push_ups,r.push_ups_score,r.run,r.run_score from result r where (r.id = @id) AND (r.status = '205') AND (r.date BETWEEN @checkover AND @reserveDate) ORDER BY r.date DESC ";
                                comm.ExecuteNonQuery();
                                //comm.Parameters.Add(_p11);
                                //comm.CommandText = "select count (id) as reserved,(select limit from center where center_code = @center_code) as limit from result where center_code = @center_code and date = @reserveDate ";
                                comm.Parameters.Clear();
                                comm.Parameters.Add("center_code", cneterSel.SelectedValue.ToString());
                                comm.Parameters.Add("date", Lib.SysSetting.ToWorldDate(_date));
                                comm.CommandType = CommandType.StoredProcedure;
                                comm.CommandText = "Ex102_GetCenterLimit";
                                dt_reserved.Load(comm.ExecuteReader());
                                //if (((Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString())) >= 0))
                                if (Convert.ToInt32(dt_reserved.Rows[0]["allow"]) >= 0)
                                {
                                    trans.Commit();
                                    this.againreserve.Style.Value = "";
                                    this.Nonenough.Style.Value    = "display:none";
                                    this.ConnectError.Style.Value = "display:none";
                                    this.bereserve.Style.Value    = "display:none";
                                    this.noreserve.Style.Value    = "display:none";
                                    this.Div2.Style.Value         = "display:none";
                                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                                    #region 通知受測人員
                                    _MailToUser.Body = _MailContentToUser.ReadToEnd();
                                    _MailToUser.Body = _MailToUser.Body.Replace("%date%", selectDate.Text);
                                    _MailToUser.Body = _MailToUser.Body.Replace("%location%", cneterSel.SelectedItem.Text);
                                    Lib.SysSetting.SaveLetter(((Lib.Player)Session["player"]).Mail + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "報進成功通知信", "00");
                                    #endregion
                                }
                                else
                                {
                                    trans.Rollback();
                                    this.Nonenough.Style.Value    = "";
                                    this.ConnectError.Style.Value = "display:none";
                                    this.canreserve.Style.Value   = "display:none";
                                    this.bereserve.Style.Value    = "display:none";
                                    this.noreserve.Style.Value    = "display:none";
                                    this.Div2.Style.Value         = "display:none";
                                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                                }
                            }
                            catch (Exception ex)
                            {
                                Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                                trans.Rollback();
                            }
                            finally
                            {
                                trans.Dispose();
                                conn.Close();
                            }
                            break;

                        case "bereserve":
                            this.bereserve.Style.Value    = "";
                            this.ConnectError.Style.Value = "display:none";
                            this.canreserve.Style.Value   = "display:none";
                            this.againreserve.Style.Value = "display:none";
                            this.Nonenough.Style.Value    = "display:none";
                            this.Div2.Style.Value         = "display:none";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                            break;

                        case "beok":
                            this.ConnectError.Style.Value = "display:none";
                            this.beok.Style.Value         = "";
                            this.canreserve.Style.Value   = "display:none";
                            this.againreserve.Style.Value = "display:none";
                            this.Nonenough.Style.Value    = "display:none";
                            this.Div2.Style.Value         = "display:none";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                            break;

                        case "noreserve":
                            this.noreserve.Style.Value    = "";
                            this.ConnectError.Style.Value = "display:none";
                            this.canreserve.Style.Value   = "display:none";
                            this.againreserve.Style.Value = "display:none";
                            this.Nonenough.Style.Value    = "display:none";
                            this.Div2.Style.Value         = "display:none";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                            break;

                        case "noenough":
                            this.Nonenough.Style.Value    = "";
                            this.ConnectError.Style.Value = "display:none";
                            this.canreserve.Style.Value   = "display:none";
                            this.againreserve.Style.Value = "display:none";
                            this.Div2.Style.Value         = "display:none";
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                            break;

                        default:
                            break;
                        }
                        GridView2.DataBind();
                        CultureInfo cii = new CultureInfo("zh-TW");
                        Thread.CurrentThread.CurrentCulture = cii;
                    }
                    catch (Exception ex)
                    {
                        Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                        CultureInfo cii = new CultureInfo("zh-TW");
                        Thread.CurrentThread.CurrentCulture = cii;
                        this.ConnectError.Style.Value       = "";
                        this.Div2.Style.Value = "display:none";
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('此年度目前不開放報進 , 開放時系統將會公告');", true);
                }
            }
            else
            {
                this.Div2.Style.Value = "";
            }
        }
    }
Exemplo n.º 28
0
    protected void update_Click(object sender, EventArgs e)
    {
        Account a = (Account)Session["account"];

        if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
        {
            try
            {
                int            index = GridView1.EditIndex;
                GridViewRow    row   = GridView1.Rows[index];
                FileUpload     t     = (FileUpload)row.FindControl("FileUpload1");
                TextBox        turl  = (TextBox)row.FindControl("url");
                HttpPostedFile file  = t.PostedFile;

                if (t.HasFile && file.ContentLength < 524300 && Lib.SysSetting.IsImage(file) == true)
                {
                    string dd = Server.MapPath(Request.ApplicationPath);
                    Bitmap s = new Bitmap(file.InputStream, true);
                    int    x, y;
                    string filename = (index + 1).ToString();
                    x = s.Width;
                    y = s.Height;
                    if (x == 160 && y == 40)
                    {
                        file.SaveAs(dd + "\\images\\Linkimage\\" + filename + ".jpg");
                        Lib.DataUtility             du = new Lib.DataUtility();
                        Dictionary <string, object> d  = new Dictionary <string, object>();
                        d.Add("sid", row.Cells[0].Text);
                        d.Add("url", turl.Text);
                        d.Add("path", "~/images/Linkimage/" + filename + ".jpg");
                        du.executeNonQueryBysp("updateRelatedLink", d);
                        Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "網站連接資料更新圖檔", DateTime.Now);
                        GridView1.DataBind();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('圖檔需符合(140 * 60)像素');", true);
                    }
                }
                else if (t.HasFile == false)
                {
                    Lib.DataUtility             du = new Lib.DataUtility();
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    d.Add("sid", row.Cells[0].Text);
                    d.Add("url", turl.Text);
                    du.executeNonQueryByText("update RelatedLink set url = @url where sid = @sid", d);
                    Lib.SysSetting.AddLog("系統", ((Lib.Account)(Session["account"])).AccountName, "網站連接資料更新超連結", DateTime.Now);
                    GridView1.DataBind();
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('系統只接受小於512KB的圖檔');", true);
                }
            }
            catch (Exception ex)
            {
                Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                Response.Redirect("~/Index.aspx");
            }
        }
    }
Exemplo n.º 29
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        int Reserver_Count = 0;

        if (FileUpload1.HasFile)
        {
            if (Session["account"] != null)
            {
                if (Lib.SysSetting.CheckYear(Convert.ToDateTime(datehide.Value)))
                {
                    DateTime checkDay = Lib.SysSetting.ToWorldDate(datehide.Value);
                    if (checkDay.DayOfWeek == DayOfWeek.Friday || checkDay.DayOfWeek == DayOfWeek.Saturday || checkDay.DayOfWeek == DayOfWeek.Sunday)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('星期五、六、日預設關站日,無法報進!!');", true);
                    }
                    else
                    {
                        string                      _OP   = ((Lib.Account)Session["account"]).AccountName;
                        string                      _date = datehide.Value;
                        Lib.DataUtility             dux   = new Lib.DataUtility();
                        Dictionary <string, object> d     = new Dictionary <string, object>();
                        d.Add("account", _OP);
                        d.Add("center_name", centerhide.Value);
                        DataTable           unit_code  = dux.getDataTableByText("select unit_code,(select c.center_code from Center c where c.center_name = @center_name) as center_code from Account where account = @account", d);
                        string              _unit_code = unit_code.Rows[0]["unit_code"].ToString();
                        string              _center    = unit_code.Rows[0]["center_code"].ToString();
                        HttpPostedFile      file       = FileUpload1.PostedFile;
                        StreamReader        reader     = new StreamReader(file.InputStream);
                        Lib.DataUtility     du         = new Lib.DataUtility();
                        int                 count      = 0;
                        List <SqlParameter> list       = new List <SqlParameter>();
                        #region 宣告 DataTable()
                        DataTable CanAccess   = new DataTable();
                        DataTable DenyAccess  = new DataTable();
                        DataTable AgainAccess = new DataTable();
                        DataTable NoSameUnit  = new DataTable();
                        DataTable Qualified   = new DataTable();
                        DataTable BeReserved  = new DataTable();
                        #endregion
                        #region 宣告CanAccess資料表欄位
                        //insert into result (id,name,age,birth,gender,unit_code,rank_code,date,center_code,status,op_id)
                        CanAccess.Columns.Add("身份證");
                        CanAccess.Columns.Add("姓名");
                        CanAccess.Columns.Add("生日");
                        CanAccess.Columns.Add("性別");
                        CanAccess.Columns.Add("單位代碼");
                        CanAccess.Columns.Add("軍階代碼");
                        CanAccess.Columns.Add("預約日期");
                        CanAccess.Columns.Add("鑑測站代碼");
                        CanAccess.Columns.Add("Mail");
                        CanAccess.Columns.Add("海外人員");
                        CanAccess.Columns.Add("團報者帳號");
                        #endregion
                        #region 宣告DenyAccess資料表欄位
                        DenyAccess.Columns.Add("身份證");
                        DenyAccess.Columns.Add("姓名");
                        DenyAccess.Columns.Add("生日");
                        DenyAccess.Columns.Add("性別");
                        DenyAccess.Columns.Add("單位代碼");
                        DenyAccess.Columns.Add("軍階代碼");
                        DenyAccess.Columns.Add("預約日期");
                        DenyAccess.Columns.Add("鑑測站代碼");
                        DenyAccess.Columns.Add("Mail");
                        DenyAccess.Columns.Add("海外人員");
                        DenyAccess.Columns.Add("團報者帳號");
                        DenyAccess.Columns.Add("報進失敗說明");
                        #endregion
                        #region 宣告AgainAccess資料表欄位
                        AgainAccess.Columns.Add("身份證");
                        AgainAccess.Columns.Add("姓名");
                        AgainAccess.Columns.Add("生日");
                        AgainAccess.Columns.Add("性別");
                        AgainAccess.Columns.Add("單位代碼");
                        AgainAccess.Columns.Add("軍階代碼");
                        AgainAccess.Columns.Add("預約日期");
                        AgainAccess.Columns.Add("鑑測站代碼");
                        AgainAccess.Columns.Add("Mail");
                        AgainAccess.Columns.Add("海外人員");
                        AgainAccess.Columns.Add("團報者帳號");
                        #endregion
                        #region 宣告NoSameUnit資料表欄位
                        NoSameUnit.Columns.Add("身份證");
                        NoSameUnit.Columns.Add("姓名");
                        NoSameUnit.Columns.Add("生日");
                        NoSameUnit.Columns.Add("性別");
                        NoSameUnit.Columns.Add("單位代碼");
                        NoSameUnit.Columns.Add("軍階代碼");
                        NoSameUnit.Columns.Add("預約日期");
                        NoSameUnit.Columns.Add("鑑測站代碼");
                        NoSameUnit.Columns.Add("Mail");
                        NoSameUnit.Columns.Add("海外人員");
                        NoSameUnit.Columns.Add("團報者帳號");
                        #endregion
                        #region 宣告Qualified資料表欄位
                        Qualified.Columns.Add("身份證");
                        Qualified.Columns.Add("姓名");
                        Qualified.Columns.Add("生日");
                        Qualified.Columns.Add("性別");
                        Qualified.Columns.Add("單位代碼");
                        Qualified.Columns.Add("軍階代碼");
                        Qualified.Columns.Add("預約日期");
                        Qualified.Columns.Add("鑑測站代碼");
                        Qualified.Columns.Add("Mail");
                        Qualified.Columns.Add("海外人員");
                        Qualified.Columns.Add("團報者帳號");
                        #endregion
                        #region 宣告BeReserved資料表欄位
                        BeReserved.Columns.Add("身份證");
                        BeReserved.Columns.Add("姓名");
                        BeReserved.Columns.Add("生日");
                        BeReserved.Columns.Add("性別");
                        BeReserved.Columns.Add("單位代碼");
                        BeReserved.Columns.Add("軍階代碼");
                        BeReserved.Columns.Add("預約日期");
                        BeReserved.Columns.Add("鑑測站代碼");
                        BeReserved.Columns.Add("Mail");
                        BeReserved.Columns.Add("海外人員");
                        BeReserved.Columns.Add("團報者帳號");
                        #endregion

                        CultureInfo ci_en = new CultureInfo("en-US");
                        Thread.CurrentThread.CurrentCulture = ci_en;  //資料庫中存放的datetime為西元時區,所以需將時區變更為en-US

                        DateTime reserveDate = Lib.SysSetting.ToWorldDate(datehide.Value);
                        DateTime firstday    = new DateTime(reserveDate.Year, 1, 1);
                        DateTime lastday     = new DateTime(reserveDate.Year, 12, 31);
                        DateTime Start       = new DateTime(reserveDate.Year, reserveDate.Month, 1);
                        DateTime End         = Start.AddMonths(1).AddDays(-1);
                        DateTime Checkover   = reserveDate.AddDays(-30);
                        try
                        {
                            while (reader.Peek() >= 0)
                            {
                                Reserver_Count++;
                                string result = reader.ReadLine();
                                try
                                {
                                    string[] operater = { "," };
                                    string[] info     = result.Split(operater, StringSplitOptions.None);
                                    if (info[0] != "身分證字號")
                                    {
                                        //string
                                        string _gender = "";
                                        char[] _id     = info[0].ToCharArray();
                                        if (_id[1] == '1')
                                        {
                                            _gender = "M";
                                        }
                                        if (_id[1] == '2')
                                        {
                                            _gender = "F";
                                        }
                                        #region New SqlParameter
                                        SqlParameter p1  = new SqlParameter("message", SqlDbType.NVarChar, 50);
                                        SqlParameter p2  = new SqlParameter("id", info[0]);
                                        SqlParameter p3  = new SqlParameter("gender", _gender);
                                        SqlParameter p4  = new SqlParameter("birth", Lib.SysSetting.ToWorldDate(info[2]));
                                        SqlParameter p5  = new SqlParameter("name", info[1]);
                                        SqlParameter p6  = new SqlParameter("unit_code", info[4]);
                                        SqlParameter p7  = new SqlParameter("rank_code", info[5]);
                                        SqlParameter p8  = new SqlParameter("mail", info[3]);
                                        SqlParameter p9  = new SqlParameter("oversea", "0");
                                        SqlParameter p10 = new SqlParameter("reserveDate", reserveDate);
                                        SqlParameter p11 = new SqlParameter("center_code", _center);
                                        SqlParameter p12 = new SqlParameter("op_id", _OP);
                                        SqlParameter p13 = new SqlParameter("start", Start);
                                        SqlParameter p14 = new SqlParameter("end", End);
                                        SqlParameter p15 = new SqlParameter("checkover", Checkover);
                                        SqlParameter p16 = new SqlParameter("firstday", firstday);
                                        SqlParameter p17 = new SqlParameter("lastday", lastday);
                                        #endregion
                                        p1.Direction = ParameterDirection.Output;
                                        int age_check = Lib.SysSetting.ConvertAge(Lib.SysSetting.ToWorldDate(info[2]), reserveDate);
                                        if (info[0].Length == 10)
                                        {
                                            if (info[4] == _unit_code)
                                            {
                                                if (age_check >= 18)
                                                {
                                                    list.Clear();
                                                    #region List.Add SqlParameter
                                                    list.Add(p1);
                                                    list.Add(p2);
                                                    list.Add(p3);
                                                    list.Add(p4);
                                                    list.Add(p5);
                                                    list.Add(p6);
                                                    list.Add(p7);
                                                    list.Add(p8);
                                                    list.Add(p9);
                                                    list.Add(p10);
                                                    list.Add(p11);
                                                    list.Add(p12);
                                                    list.Add(p13);
                                                    list.Add(p14);
                                                    list.Add(p15);
                                                    list.Add(p16);
                                                    list.Add(p17);
                                                    #endregion

                                                    SqlParameter[] sqls = list.ToArray();
                                                    du.executeNonQueryBysp("AddPlayerByTeam", sqls);
                                                    if (p1.Value.ToString() == "canreserve")
                                                    {
                                                        CanAccess.Rows.Add(info[0], info[1], Lib.SysSetting.ToWorldDate(info[2]), _gender, info[4], info[5], reserveDate, _center, info[3], "0", _OP);
                                                    }
                                                    if (p1.Value.ToString() == "noreserve")
                                                    {
                                                        DenyAccess.Rows.Add(info[0], info[1], Lib.SysSetting.ToWorldDate(info[2]), _gender, info[4], info[5], reserveDate, _center, info[3], "0", _OP, "此月份已測驗,請報進其他月份");
                                                    }
                                                    if (p1.Value.ToString() == "againreserve")
                                                    {
                                                        DenyAccess.Rows.Add(info[0], info[1], Lib.SysSetting.ToWorldDate(info[2]), _gender, info[4], info[5], reserveDate, _center, info[3], "0", _OP, "您為30天內補測人員,請使用個人報進");
                                                    }
                                                    if (p1.Value.ToString() == "bereserve")
                                                    {
                                                        DenyAccess.Rows.Add(info[0], info[1], Lib.SysSetting.ToWorldDate(info[2]), _gender, info[4], info[5], reserveDate, _center, info[3], "0", _OP, "您已有1筆預約,本次報進失敗");
                                                    }
                                                    if (p1.Value.ToString() == "beok")
                                                    {
                                                        DenyAccess.Rows.Add(info[0], info[1], Lib.SysSetting.ToWorldDate(info[2]), _gender, info[4], info[5], reserveDate, _center, info[3], "0", _OP, "您已經是合格人員,本次報進失敗");
                                                    }
                                                }
                                                else
                                                {
                                                    DenyAccess.Rows.Add(info[0], info[1], Lib.SysSetting.ToWorldDate(info[2]), _gender, info[4], info[5], reserveDate, _center, info[3], "0", _OP, "生日請使用民國格式");
                                                }
                                            }
                                            else
                                            {
                                                DenyAccess.Rows.Add(info[0], info[1], Lib.SysSetting.ToWorldDate(info[2]), _gender, info[4], info[5], reserveDate, _center, info[3], "0", _OP, "單位代碼錯誤");
                                            }
                                        }
                                        else
                                        {
                                            error_format.Text = error_format.Text + info[0] + "," + info[1] + "<br/>";
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                                    error_format.Text = error_format.Text + result + "<br/>";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('資料格式不符 , 請重新檢查');", true);
                        }
                        #region 控制資料表的顯示,且將允許報名的資料做報名的動作

                        ci_en = new CultureInfo("en-US");
                        Thread.CurrentThread.CurrentCulture = ci_en;  //資料庫中存放的datetime為西元時區,所以需將時區變更為en-US
                        if (CanAccess.Rows.Count > 0)
                        {
                            list.Clear();
                            Lib.DataUtility _du = new Lib.DataUtility();
                            string          _v  = CanAccess.Rows[0]["預約日期"].ToString();
                            SqlParameter    pp1 = new SqlParameter("message", SqlDbType.NVarChar, 50);
                            SqlParameter    pp2 = new SqlParameter("center_code", _center);
                            SqlParameter    pp3 = new SqlParameter("date", Convert.ToDateTime(_v));
                            SqlParameter    pp4 = new SqlParameter("wanted", CanAccess.Rows.Count);
                            list.Add(pp1);
                            list.Add(pp2);
                            list.Add(pp3);
                            list.Add(pp4);
                            SqlParameter[] sqlss = list.ToArray();
                            pp1.Direction = ParameterDirection.Output;
                            _du.executeNonQueryBysp("CheckCenterLimit", sqlss);
                            if (pp1.Value.ToString() == "No")
                            {
                                Re_Success_Count.Text = "0人";
                                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('餘額不足 , 無法預約');", true);
                            }
                            else if (pp1.Value.ToString() == "Yes") //pp1.Value.ToString() == "Yes"
                            {
                                Lib.DataUtility _DataUtility = new Lib.DataUtility();
                                SqlConnection   conn         = new SqlConnection(ConfigurationManager.ConnectionStrings["MainDB"].ConnectionString);
                                conn.Open();
                                SqlCommand     comm = conn.CreateCommand();
                                SqlTransaction trans;
                                trans            = conn.BeginTransaction("mytrans");
                                comm.Connection  = conn;
                                comm.Transaction = trans;
                                try
                                {
                                    for (int i = 0; i < CanAccess.Rows.Count; i++)
                                    {
                                        try
                                        {
                                            comm.Parameters.Clear();
                                            SqlParameter _p1  = new SqlParameter("id", CanAccess.Rows[i]["身份證"]);
                                            SqlParameter _p2  = new SqlParameter("gender", CanAccess.Rows[i]["性別"]);
                                            SqlParameter _p3  = new SqlParameter("birth", Convert.ToDateTime(CanAccess.Rows[i]["生日"])); //不能複蓋
                                            SqlParameter _p4  = new SqlParameter("name", CanAccess.Rows[i]["姓名"]);                      //不能覆蓋
                                            SqlParameter _p5  = new SqlParameter("unit_code", CanAccess.Rows[i]["單位代碼"]);
                                            SqlParameter _p6  = new SqlParameter("rank_code", CanAccess.Rows[i]["軍階代碼"]);
                                            SqlParameter _p7  = new SqlParameter("mail", CanAccess.Rows[i]["Mail"]);//不能覆蓋
                                            SqlParameter _p8  = new SqlParameter("oversea", CanAccess.Rows[i]["海外人員"]);
                                            SqlParameter _p9  = new SqlParameter("reserveDate", Convert.ToDateTime(CanAccess.Rows[i]["預約日期"]));
                                            SqlParameter _p10 = new SqlParameter("center_code", CanAccess.Rows[i]["鑑測站代碼"]);
                                            SqlParameter _p11 = new SqlParameter("op_id", CanAccess.Rows[i]["團報者帳號"]);
                                            SqlParameter _p12 = new SqlParameter("age", Lib.SysSetting.ConvertAge(Convert.ToDateTime(CanAccess.Rows[i]["生日"]), Convert.ToDateTime(CanAccess.Rows[i]["預約日期"])));

                                            comm.Parameters.Add(_p1);
                                            comm.Parameters.Add(_p2);
                                            //如果改Rresult不依據player資料則上面二個不mark
                                            comm.Parameters.Add(_p3);
                                            comm.Parameters.Add(_p4);
                                            comm.Parameters.Add(_p5);
                                            comm.Parameters.Add(_p6);
                                            comm.Parameters.Add(_p7);
                                            comm.Parameters.Add(_p8);
                                            comm.Parameters.Add(_p9);
                                            comm.Parameters.Add(_p10);
                                            comm.Parameters.Add(_p11);
                                            comm.Parameters.Add(_p12);

                                            //2016-12-8最終大改版 一隻sp作掉
                                            comm.CommandType = CommandType.StoredProcedure;
                                            comm.CommandText = "Ex106_TeamReserve";
                                            comm.ExecuteNonQuery();
                                            //以上大改版,三行解決


                                            //comm.CommandType = CommandType.Text;
                                            //comm.CommandTyp = CommandType.StoredProcedure;


                                            //-----------版本1:團報時Result依照player資料為主------------
                                            //2016-12-6,測試把player的資料放到result
                                            //comm.Parameters.AddWithValue("id", CanAccess.Rows[i]["身份證"].ToString());
                                            //comm.CommandText = "select top 1 id,name,birth from player where id=@id";
                                            //DataTable dt1 = new DataTable();
                                            //dt1.Load(comm.ExecuteReader());
                                            //if (dt1.Rows.Count > 0)//有此id,更新資料
                                            //{
                                            //    comm.CommandText = "update Player set unit_code=@unit_code,rank_code=@rank_code,oversea=@oversea";
                                            //    comm.ExecuteNonQuery();
                                            //    //更新player資料測試
                                            //    if (!string.IsNullOrEmpty(dt1.Rows[0]["birth"].ToString()))//值不是空的才把player資料覆蓋過來
                                            //    _p3 = new SqlParameter("birth", Convert.ToDateTime(dt1.Rows[0]["birth"]));//不能複蓋
                                            //    if (!string.IsNullOrEmpty(dt1.Rows[0]["name"].ToString()))//值不是空的才把player資料覆蓋過來
                                            //        _p4 = new SqlParameter("name", dt1.Rows[0]["name"]);//不能覆蓋
                                            //    comm.Parameters.Add(_p3);
                                            //    comm.Parameters.Add(_p4);

                                            //}
                                            //else//無此id,直接新增
                                            //{
                                            //    comm.Parameters.Add(_p3);
                                            //    comm.Parameters.Add(_p4);
                                            //    comm.CommandText = "insert into player (id,gender,birth,name,unit_code,rank_code,mail,oversea) values (@id,@gender,@birth,@name,@unit_code,@rank_code,@mail,@oversea)";
                                            //    comm.ExecuteNonQuery();
                                            //}
                                            //-----------------以上為版本1---------------------


                                            //------------版本2:Result資料依照團報資料,Player一樣不覆蓋--------
                                            ////先mark,測試如果player有資料就直接抓來用
                                            ////2016-9-5更新較佳的方法(IF EXISTS ELSE)
                                            ////直接用sql判斷是否有該比資料,如果有就只更新單位、級職代碼,若沒有就新增一筆帳號。
                                            //comm.CommandText = "IF EXISTS (select * from Player where id=@id) update Player set unit_code=@unit_code,rank_code=@rank_code where id=@id ELSE insert into Player (id,name,gender,birth,mail,unit_code,rank_code,oversea) values(@id,@name,@gender,@birth,@mail,@unit_code,@rank_code,@oversea)";
                                            //comm.ExecuteNonQuery();
                                            ////以上先mark


                                            //原本處理Player表格方式先刪除資料再重新塞入資料(舊版-先mark)
                                            //comm.CommandText = "delete from player where id = @id";
                                            //comm.ExecuteNonQuery();
                                            //comm.CommandText = "insert into player (id,gender,birth,name,unit_code,rank_code,mail,oversea) values (@id,@gender,@birth,@name,@unit_code,@rank_code,@mail,@oversea)";
                                            //comm.ExecuteNonQuery();
                                            //----------------以上為版本2--------------------


                                            //處理Result表格(保留)
                                            //comm.CommandText = "delete from result where id = @id and date = @reserveDate";
                                            //comm.ExecuteNonQuery();
                                            //comm.CommandText = "insert into result (id,name,age,birth,gender,unit_code,rank_code,date,center_code,status,op_id) values(@id,@name,@age,@birth,@gender,@unit_code,@rank_code,@reserveDate,@center_code,'000',@op_id) ";
                                            //comm.ExecuteNonQuery();
                                        }
                                        catch (Exception ex)
                                        {
                                            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                                            error_format.Text = error_format.Text + CanAccess.Rows[i]["身份證"] + "," + CanAccess.Rows[i]["姓名"] + "<br/>";
                                            CanAccess.Rows.RemoveAt(i);
                                            i--;
                                        }
                                    }
                                    list.Clear();
                                    string    _vv         = CanAccess.Rows[0]["預約日期"].ToString();
                                    DataTable dt_reserved = new DataTable();
                                    comm.Parameters.Clear();
                                    comm.Parameters.Add("center_code", _center);
                                    comm.Parameters.Add("date", Convert.ToDateTime(_vv));
                                    comm.CommandType = CommandType.StoredProcedure;
                                    comm.CommandText = "Ex102_GetCenterLimit";
                                    dt_reserved.Load(comm.ExecuteReader());
                                    //comm.CommandText = "select count (id) as reserved,(select limit from center where center_code = @center_code) as limit from result where center_code = @center_code and date = @date";
                                    //dt_reserved.Load(comm.ExecuteReader());
                                    //if (((Convert.ToInt32(dt_reserved.Rows[0]["limit"].ToString()) - Convert.ToInt32(dt_reserved.Rows[0]["reserved"].ToString())) >= 0))
                                    if (Convert.ToInt32(dt_reserved.Rows[0]["allow"]) >= 0)
                                    {
                                        trans.Commit();
                                        trans.Dispose();
                                        conn.Close();
                                        #region  寫Log
                                        CultureInfo ci = new CultureInfo("zh-TW");
                                        Thread.CurrentThread.CurrentCulture = ci;
                                        #endregion
                                        //寫入Result
                                        //使用迴圈一筆一筆寫入
                                        //資料來源為CanAccess

                                        #region 通知受測人員
                                        string cwd          = System.IO.Directory.GetCurrentDirectory();
                                        string dd           = Server.MapPath(Request.ApplicationPath);
                                        string _detailtable = "";
                                        for (int i = 0; i < CanAccess.Rows.Count; i++)
                                        {
                                            _detailtable = _detailtable + "<tr><td>" + CanAccess.Rows[i]["姓名"] + "</td><td>" + CanAccess.Rows[i]["身份證"] + "</td><td>" + Lib.SysSetting.ToRocDateFormat(CanAccess.Rows[i]["生日"].ToString().Remove(9)) + "</td><td>" + CanAccess.Rows[i]["軍階代碼"] + "</td><td>" + CanAccess.Rows[i]["Mail"] + "</td></tr>";

                                            MailMessage  _MailToUser        = new MailMessage();
                                            StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\TeamReserveUser.txt");
                                            //_MailToUser.Body = _MailContent.ReadToEnd().Replace("%detail%", _detailtable);
                                            _MailToUser.Body = _MailContentToUser.ReadToEnd();
                                            _MailToUser.Body = _MailToUser.Body.Replace("%date%", datehide.Value);
                                            _MailToUser.Body = _MailToUser.Body.Replace("%location%", centerhide.Value);
                                            Lib.SysSetting.SaveLetter(CanAccess.Rows[i]["Mail"] + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "報進成功通知信", "00");
                                        }
                                        #endregion

                                        #region 通知團報負責人
                                        MailMessage  _Mail        = new MailMessage();
                                        StreamReader _MailContent = new StreamReader(dd + "\\Mail\\TeamReserveManger.txt");
                                        _Mail.Body = _MailContent.ReadToEnd().Replace("%detail%", _detailtable);
                                        _Mail.Body = _Mail.Body.Replace("%date%", datehide.Value);
                                        _Mail.Body = _Mail.Body.Replace("%location%", centerhide.Value);
                                        _Mail.Body = _Mail.Body.Replace("%total%", CanAccess.Rows.Count.ToString());
                                        Lib.SysSetting.SaveLetter(((Lib.Account)Session["account"]).Mail + "@webmail.mil.tw", "國軍基本體能鑑測網", _Mail.Body, "報進成功通知信", "00");
                                        Lib.SysSetting.AddLog("團體報進", _OP, "報進成功 , 日期:" + datehide.Value + " , 地點:" + centerhide.Value + " , 預約人數" + CanAccess.Rows.Count + "人", System.DateTime.Now);
                                        #endregion

                                        CanAccess.Columns.Remove("鑑測站代碼");
                                        CanAccess.Columns.Remove("海外人員");
                                        CanAccess.Columns.Remove("團報者帳號");
                                        CanAccess.Columns.Remove("預約日期");
                                        GridView1.DataSource = CanAccess;
                                        GridView1.DataBind();
                                        GridView1.Visible     = true;
                                        Re_Success_Count.Text = CanAccess.Rows.Count.ToString() + "人";
                                    }
                                    else
                                    {
                                        trans.Rollback();
                                        trans.Dispose();
                                        conn.Close();
                                        Re_Success_Count.Text = "0人";
                                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('餘額不足 , 無法預約');", true);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
                                    trans.Rollback();
                                    trans.Dispose();
                                    conn.Close();
                                    Re_Success_Count.Text = "0人";
                                }
                            }
                        }

                        DenyAccess.Columns.Remove("鑑測站代碼");
                        DenyAccess.Columns.Remove("海外人員");
                        DenyAccess.Columns.Remove("團報者帳號");
                        DenyAccess.Columns.Remove("預約日期");
                        GridView3.DataSource = DenyAccess;
                        GridView3.DataBind();
                        GridView3.Visible = true;
                        CultureInfo cii = new CultureInfo("zh-TW");
                        Thread.CurrentThread.CurrentCulture = cii;
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "$.unblockUI();$('#aspnetForm')[0].submit();", true);
                        Re_fail_Count.Text = DenyAccess.Rows.Count.ToString() + "人";
                        Re_Count.Text      = (Reserver_Count - 1).ToString();
                        this.SuccessDetails.Style.Value   = "";
                        this.failDatails.Style.Value      = "";
                        this.OrderStep1.Style.Value       = "display:none";
                        this.SureOrder.Style.Value        = "display:none";
                        this.SureTimeAndPlace.Style.Value = "display:none";
                        this.Result.Style.Value           = "";
                        this.Div2.Style.Value             = "";
                        this.ReturnStep1.Style.Value      = "";
                        Re_surecenter.Text = centerhide.Value;
                        Re_suredate.Text   = datehide.Value;
                        #endregion
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('此年度目前不開放報進 , 開放時系統將會公告');", true);
                }
            }
        }
    }
Exemplo n.º 30
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 = "";
        }
    }