Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Lib.SysSetting.CurrentSystemMode() == Lib.SysSetting.SystemMode.Race)
        {
            Lib.DataUtility du = new Lib.DataUtility();
            DataTable       dt = new DataTable();
            if (Request.QueryString["unit_code"] != null && Request.QueryString["status"] != null)
            {
                Dictionary <string, object> list = new Dictionary <string, object>();
                list.Add("unit_code", Request.QueryString["unit_code"].ToString());
                list.Add("status", Request.QueryString["status"].ToString());
                dt = du.getDataTableBysp("Race_DetailStatusByUnit", list);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                pageTitle.Text = "團體組各單位競賽狀態名單";
                DataTable dt2 = new DataTable();
                dt2          = du.getDataTableByText("select unit_title from unit where unit_code = '" + list["unit_code"] + "'");
                Label1.Text  = dt2.Rows[0][0].ToString() + "<br />";
                Label1.Text += "共 " + dt.Rows.Count.ToString() + " 員";
            }

            if (Request.QueryString["team"] != null && Request.QueryString["status"] != null)
            {
                Dictionary <string, object> list = new Dictionary <string, object>();
                list.Add("team", Request.QueryString["team"].ToString());
                list.Add("status", Request.QueryString["status"].ToString());
                dt = du.getDataTableBysp("Race_DetailStatusByPerson", list);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                pageTitle.Text = "個人組分組競賽狀態名單";
                Label1.Text    = "共 " + dt.Rows.Count.ToString() + " 員";
            }
        }
    }
Ejemplo n.º 2
0
        public static bool CheckYear(DateTime _date)
        {
            int year = _date.Year;

            Lib.DataUtility             du = new DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();

            d.Add("year", year);
            DataTable dt = du.getDataTableByText("select islock from Year where year = @year", d);

            if (dt.Rows.Count == 1)
            {
                if (Convert.ToBoolean(dt.Rows[0][0]))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false); //不可預約此年度
            }
        }
Ejemplo n.º 3
0
    public DataTable Re_DownLoadResult(string center_code)//2017-11-8手動重覆下載
    {
        Lib.DataUtility main     = new Lib.DataUtility();
        DateTime        _date    = DateTime.Now.Date.AddDays(1);                                 //當天日期+1天
        DateTime        deadline = _date.AddHours((-Lib.SysSetting.reserveTimeUnit.TotalHours)); //再減12小時,指當天中午12點
        DataTable       dt       = new DataTable();

        if (DateTime.Now < deadline)//如果在當天中午12點前就是以當天為主,如果過了12點就是以明天日期為主
        {
            _date = DateTime.Now.Date;
        }
        try
        {
            dt           = main.getDataTableByText("select sid, id, name, gender, birth, age, unit_code, rank_code, date, center_code, op_id, sit_ups, sit_ups_score, push_ups, push_ups_score, run, run_score, memo from result where center_code = @center_code and status in ('000','999') and date = '" + _date.ToString("yyyy/MM/dd") + "'", "center_code", center_code);
            dt.TableName = "download";
            if (dt.Rows.Count != 0)
            {
                main.executeNonQueryByText("update result set status = '999' where center_code = @center_code and status = '000' and date ='" + _date.ToString("yyyy/MM/dd") + "'", "center_code", center_code);
            }

            return(dt);
        }
        catch (Exception ex)
        {
            dt.TableName = "download";
            return(dt);
        }
    }
Ejemplo n.º 4
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Lib.DataUtility             du   = new Lib.DataUtility();
        Dictionary <string, object> list = new Dictionary <string, object>();

        if (txtName.Text != "")
        {
            //list.Add("@title", txtName.Text.Trim());
            DataTable dt     = new DataTable();
            string    sqlcmd = string.Empty;
            sqlcmd = "select unit_code [單位代碼], unit_title [單位全銜], [上級單位], parent_unit_code [上級單位代碼] from [VIEW_UNIT_CODE] ";
            string[] keywords = txtName.Text.Split(new string[] { " " }, StringSplitOptions.None);
            for (int i = 0; i < keywords.Length; i++)
            {
                if (i == 0)
                {
                    sqlcmd += "where [unit_title] like '%" + keywords[i] + "%' ";
                }
                if (i == (keywords.Length - 1) && i != 0)
                {
                    sqlcmd += "and [unit_title] like '%" + keywords[i] + "%' order by [單位代碼]";
                }
                else
                {
                    sqlcmd += "and [unit_title] like '%" + keywords[i] + "%' ";
                }
            }
            dt = du.getDataTableByText(sqlcmd);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
Ejemplo n.º 5
0
 private static string ProcessResult(string[] info, string byAcc)
 {
     try
     {
         Lib.DataUtility             du = new Lib.DataUtility();
         DataTable                   dt = du.getDataTableByText("select account from account where account = @acc", "acc", info[0]);
         Dictionary <string, object> d  = new Dictionary <string, object>();
         if (dt.Rows.Count == 0)
         {
             d.Add("account", info[0]);
             d.Add("password", info[1]);
             d.Add("role_code", "3");
             d.Add("unit_code", info[2]);
             d.Add("ip", info[3]);
             d.Add("byacc", byAcc);
             du.executeNonQueryByText("insert into account (account, password, role_code, unit_code, ip, byacc) values (@account, @password, @role_code, @unit_code, @ip, @byacc)", d);
             du.executeNonQueryByText("insert into optioncode values (@acc,'1')", "acc", info[0]);
             return("新增成功");
         }
         else
         {
             return("帳號重複");
         }
     }
     catch (Exception ex)
     {
         Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, "HQ_UserAccMag.aspx");
         return(ex.Message);
     }
 }
Ejemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["account"] != null)
     {
         if (!Page.IsPostBack)
         {
             Account a = (Account)Session["account"];
             if (a.Role == ((int)SysSetting.Role.admin_hq).ToString())
             {
                 Lib.DataUtility             du = new Lib.DataUtility();
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 DataTable dt = new DataTable();
                 dt = du.getDataTableByText("select info from Contact");
                 if (dt.Rows.Count == 1)  //表示登入者的身分為鑑測站資訊管理者
                 {
                     information.Text = dt.Rows[0]["info"].ToString();
                 }
                 else
                 {
                 }
             }
         }
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
Ejemplo n.º 7
0
    protected void confirm_Click(object sender, EventArgs e)
    {
        Dictionary <string, object> d = new Dictionary <string, object>();

        d.Add("head", head.Text.Trim());
        d.Add("date", DateTime.Now);
        Lib.DataUtility du = new Lib.DataUtility();
        try
        {
            du.executeNonQueryByText("insert into discussion (head,date) values (@head,@date)", d);
            d.Clear();
            DataTable dt       = du.getDataTableByText("select sid from discussion where head = @head", "head", head.Text.Trim());
            string    _head_id = dt.Rows[0]["sid"].ToString();
            d.Add("head_sid", _head_id);
            d.Add("text", FTB_text.Text);
            d.Add("player", ((Lib.Player)(Session["player"])).ID);
            d.Add("date", DateTime.Now);
            du.executeNonQueryByText("insert into discussiondetail values (@head_sid,@text,@player,@date)", d);
            d.Clear();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('新增成功');", true);
        }
        catch (Exception ex)
        {
            Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('" + ex.Message + "');", true);
        }
    }
Ejemplo n.º 8
0
    protected void Button8_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable                   dt = new DataTable();
            Lib.DataUtility             du = new Lib.DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();
            if (TextBox3.Text.Trim().Length == 10)
            {
                d.Add("id", TextBox3.Text.Trim());
                dt = du.getDataTableByText(@"select top 1 id [身分證字號], name [姓名], dbo.F_GetUnitTitle(unit_code) [單位], dbo.F_GetStatusMeaning(status) [狀態], clothesNum [背號], dbo.F_GetROCDate(date) [鑑測日期],
                (case when substring(memo,1,1) = '0' then (case when sit_ups is null then '未測' else CONVERT(nvarchar(10),sit_ups)end)
			  when substring(memo,1,1) != '0'then (select rep_title from repment where sid = substring(memo,1,1)) + (case when sit_ups is not null then [dbo].[F_GetReplMentFormate] (substring(memo,1,1),sit_ups) when sit_ups is null then '未測' else '' end) end) as [仰臥起坐],
                (case when substring(memo,2,1) = '0' then (case when push_ups is null then '未測' else CONVERT(nvarchar(10),push_ups)end)
			  when substring(memo,2,1) != '0'then (select rep_title from repment where sid = substring(memo,2,1)) + (case when push_ups is not null then [dbo].[F_GetReplMentFormate] (substring(memo,2,1),push_ups) when push_ups is null then '未測' else '' end) end) as [伏地挺身],
                (case when substring(memo,3,1) = '0' then (case when run is null and (run_score = 9999 or run_score is null) then '未測' when run = 9999 and (run_score = 9999 or run_score is null) then '-' else CONVERT(nvarchar(10),run/60)+':'+CONVERT(nvarchar(10),run%60) end)
			  when substring(memo,3,1) != '0'then (select rep_title from repment where sid = substring(memo,3,1)) + (case when run is not null then[dbo].[F_GetReplMentFormate] (substring(memo,3,1),run) when run is null then '未測' else '' end) end) as [三千公尺], result from result where id = @id"            , d);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                image1.ImageUrl = @"~/ImageHandler.ashx?id=" + TextBox3.Text.Trim() + @"&date=" + dt.Rows[0][5].ToString().Replace('.', '/');
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('身分證字號長度錯誤');", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "');", true);
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["player"] != null)
     {
         if (Request.QueryString["date"] != null && Request.QueryString["date"] != "" && Request.QueryString["center_code"] != null && Request.QueryString["center_code"] != "")
         {
             try
             {
                 Lib.DataUtility             du = new Lib.DataUtility();
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 d.Add("center_code", Request.QueryString["center_code"].ToString());
                 DataTable dt = du.getDataTableByText("select center_name from Center where center_code = @center_code", d);
                 date.Text   = Request.QueryString["date"].ToString();
                 center.Text = dt.Rows[0]["center_name"].ToString();
                 SqlDataSource1.SelectParameters["date"].DefaultValue        = Convert.ToDateTime(date.Text).ToShortDateString();
                 SqlDataSource1.SelectParameters["op_id"].DefaultValue       = ((Lib.Player)Session["player"]).ID;
                 SqlDataSource1.SelectParameters["center_code"].DefaultValue = Request.QueryString["center_code"].ToString();
             }
             catch (Exception ex)
             {
                 Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
             }
         }
     }
     else
     {
         Response.Redirect("Login.aspx");
     }
 }
Ejemplo n.º 10
0
 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     Lib.Account a = (Lib.Account)Session["account"];
     if (a.Role == "2")
     {
         try
         {
             int         index = GridView1.SelectedIndex;
             GridViewRow row   = GridView1.Rows[index];
             sid.Text       = row.Cells[0].Text;
             acc.Text       = row.Cells[3].Text;
             id.Text        = row.Cells[1].Text;
             unit_code.Text = row.Cells[3].Text;
             name.Text      = row.Cells[2].Text;
             rank_code.Text = row.Cells[4].Text;
             tel.Text       = row.Cells[6].Text;
             mail.Text      = row.Cells[5].Text;
             cellphone.Text = row.Cells[7].Text;
             ip.Text        = row.Cells[8].Text;
             Lib.DataUtility             du = new Lib.DataUtility();
             Dictionary <string, object> d  = new Dictionary <string, object>();
             d.Add("unit_code", row.Cells[3].Text.Trim());
             d.Add("rank_code", row.Cells[4].Text.Trim());
             DataTable dt = du.getDataTableByText("select unit_title,(select rank_title from Rank where rank_code = @rank_code) As rank_title from Unit where unit_code = @unit_code", d);
             unit_code_name.Text = dt.Rows[0]["unit_title"].ToString();
             rank_code_name.Text = dt.Rows[0]["rank_title"].ToString();
         }
         catch (Exception ex)
         {
             Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, this.ToString());
         }
     }
 }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["center_code"] != null && Request.QueryString["date"] != null)
        {
            if (!Page.IsPostBack)
            {
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                d.Add("center_code", Request.QueryString["center_code"].ToString().Trim());
                d.Add("date", Convert.ToDateTime(Request.QueryString["date"].ToString().Trim()));
                d.Add("op_id", ((Lib.Player)Session["player"]).ID);
                DataTable dt = du.getDataTableByText("select count(id) as count,(select center_name from Center where center_code = @center_code) as center_name from result where center_code = @center_code and date = @date and id =@op_id", d);
                oldcount.Text  = dt.Rows[0]["count"].ToString();
                oldcenter.Text = dt.Rows[0]["center_name"].ToString();
                olddate.Text   = (Convert.ToInt32(Request.QueryString["date"].ToString().Trim().Substring(0, Request.QueryString["date"].ToString().Trim().Length - 6)) - 1911).ToString() + Request.QueryString["date"].ToString().Trim().Substring(4, Request.QueryString["date"].ToString().Trim().Length - 4);

                Calendar1.Visible = false;
                dateDiv.Visible   = false;
            }
            else
            {
                Calendar1.Visible = true;
                TaiwanCalendar tc = new TaiwanCalendar();
                CultureInfo    ci = new CultureInfo("zh-TW");
                ci.DateTimeFormat.Calendar          = tc;
                ci.DateTimeFormat.YearMonthPattern  = "民國yy年MM月";
                ci.DateTimeFormat.FirstDayOfWeek    = DayOfWeek.Sunday;
                Thread.CurrentThread.CurrentCulture = ci;
                dateDiv.Visible = true;
            }
        }
        else
        {
        }
    }
Ejemplo n.º 12
0
    public DataTable UnitData()
    {
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = du.getDataTableByText("select * from unit");

        dt.TableName = "unit";
        return(dt);
    }
Ejemplo n.º 13
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (!String.IsNullOrEmpty(TB_id.Text.Trim()))
         {
             Dictionary <string, object> d  = new Dictionary <string, object>();
             Lib.DataUtility             du = new Lib.DataUtility();
             d.Add("id", TB_id.Text.Trim());
             d.Add("date", System.DateTime.Today);
             DataTable dt = du.getDataTableByText(@"select status,memo from result where id = @id and date = @date", d);
             if (dt.Rows.Count == 1)
             {
                 string status = string.Empty;
                 string memo1  = string.Empty;
                 if (!string.IsNullOrEmpty(dt.Rows[0]["status"].ToString()))
                 {
                     status = dt.Rows[0]["status"].ToString();
                 }
                 if (!string.IsNullOrEmpty(dt.Rows[0]["memo"].ToString()))
                 {
                     memo1 = dt.Rows[0]["memo"].ToString();
                 }
                 else
                 {
                     memo1 = "000";
                 }
                 if (!string.IsNullOrEmpty(status) & status != "000" & status != "999" & status.Substring(0, 1) != "2")
                 {
                     DropDownList1.SelectedValue = dt.Rows[0]["memo"].ToString().Substring(0, 1);
                     DropDownList2.SelectedValue = dt.Rows[0]["memo"].ToString().Substring(1, 1);
                     DropDownList3.SelectedValue = dt.Rows[0]["memo"].ToString().Substring(2, 1);
                     DropDownList4.SelectedValue = dt.Rows[0]["memo"].ToString().Substring(0, 1);
                     DropDownList5.SelectedValue = dt.Rows[0]["memo"].ToString().Substring(1, 1);
                     DropDownList6.SelectedValue = dt.Rows[0]["memo"].ToString().Substring(2, 1);
                 }
                 else
                 {
                     ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('該員尚未完成檢錄或成績已上傳,不可變更鑑測項目');", true);
                     Re_Select();
                 }
             }
             else
             {
                 ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('查無今日受測資料');", true);
                 Re_Select();
             }
         }
         else
         {
             ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('請輸入身分證字號');", true);
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "');", true);
     }
 }
Ejemplo n.º 14
0
    protected void btn_Upload_105_666_Click(object sender, EventArgs e)//105補測成績上傳(現報)
    {
        //DialogResult dialogResult = MessageBox.Show("確認批次上傳「補測」成績(現報)?", "確認Yes/No", MessageBoxButtons.YesNo);
        //if (dialogResult == DialogResult.Yes)
        //{
        lab_Count.Text = null;
        string data_count = "1";

        data_count = txb_P_count.Text;                                                                                                                                                                                                                   //上傳筆數
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = du.getDataTableByText("select top " + data_count + " * from result where status = @status and result = '666' and date between '" + txb_StartTime.Text + "' and '" + txb_EndTime.Text + "' order by date", "status", "105"); // 105 未上傳補測

        if (dt.Rows.Count == 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有「補測」成績(現報)');", true);
        }
        else
        {
            //上傳更新總部資料
            dt.TableName = "upload";
            MainWS.WebService MainWs = new MainWS.WebService();
            string            msg    = MainWs.UploadResult(dt, "present");
            if (msg == "done")
            {
                List <Dictionary <string, object> > list_u = new List <Dictionary <string, object> >();
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d_u = new Dictionary <string, object>();
                    d_u.Add("id", row["id"]);
                    list_u.Add(d_u);
                }
                try
                {
                    // 更新鑑測站資料狀態
                    du.executeNonQueryByText("update result set status = '205' , result = '777' where id = @id and result = '666' ", list_u);
                    dt.Dispose();
                    list_u.Clear();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('上傳補測成績成功(現報)');", true);
                    lab_Count.Text = "成功上傳補測成績(現報)共計「" + dt.Rows.Count + "」筆";
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + msg + "\");", true);
            }
        }
        btn_no_upload_Click(btn_no_upload, e);
        //}
        //else if (dialogResult == DialogResult.No)
        //{
        //    //do something else
        //}
    }
Ejemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MainWS.WebService m  = new MainWS.WebService();
        Lib.DataUtility   du = new Lib.DataUtility();
        DataTable         dt = du.getDataTableByText("select unit_title from unit where parent_unit_code = @code", "code", "10001");

        dt.TableName = "toAdd";
        string toget = m.Datatable(dt);
    }
Ejemplo n.º 16
0
    protected void upload_OnClick(object sender, EventArgs e)
    {
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = du.getDataTableByText("select * from result where status = @status and result = '111' ", "status", "102"); // 102 未上傳合格

        if (dt.Rows.Count == 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有成績');", true);
            GridView3.DataBind();
        }
        else
        {
            dt.TableName = "upload";
            MainScoreWS.WebService2 MainWs = new MainScoreWS.WebService2();
            string msg = MainWs.UploadResult(dt, "present");
            if (msg == "done")
            {
                //Lib.DataUtility main = new Lib.DataUtility(Lib.DataUtility.ConnectionType.MainDB);
                //List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
                List <Dictionary <string, object> > list_u = new List <Dictionary <string, object> >();
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d_u = new Dictionary <string, object>();
                    d_u.Add("id", row["id"]);
                    list_u.Add(d_u);
                }
                try
                {
                    //    // 上傳更新總部資料
                    //    main.executeNonQueryByText("update result set height = @height, weight=@weight, BMI = @BMI, bodyfat = @bodyfat, sit_ups = @sit_ups, sit_ups_score = @sit_ups_score, push_ups = @push_ups, push_ups_score = @push_ups_score, run = @run, run_score = @run_score, status = @status where sid = @sid", list);
                    // 更新鑑測站資料狀態
                    du.executeNonQueryByText("update result set status = '202' , result = '222' where id = @id and result = '111' and status = '102' ", list_u);
                    Dictionary <string, object> d_log = new Dictionary <string, object>();
                    d_log.Add("acc", ((Lib.Center.Account_c)Session["account"]).Account);
                    d_log.Add("name", ((Lib.Center.Account_c)Session["account"]).Name);
                    d_log.Add("log", "上傳合格成績 " + dt.Rows.Count.ToString() + " 筆");
                    d_log.Add("date", DateTime.Now);
                    du.executeNonQueryByText("insert into log values (@acc,@name,@log,@date)", d_log);
                    dt.Dispose();
                    //list.Clear();
                    list_u.Clear();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('上傳合格成績成功');", true);
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + msg + "\");", true);
            }
            GridView3.DataBind();
        }
    }
Ejemplo n.º 17
0
    protected void Button7_Click(object sender, EventArgs e)
    {
        try
        {
            //string script = @"<script language='JavaScript'>window.location.reload();</script>";

            string memo = DropDownList1.SelectedValue + DropDownList2.SelectedValue + DropDownList3.SelectedValue;
            if (DropDownList1.SelectedItem.ToString() != DropDownList2.SelectedItem.ToString() && DropDownList2.SelectedItem.ToString() != DropDownList3.SelectedItem.ToString() && DropDownList1.SelectedItem.ToString() != DropDownList3.SelectedItem.ToString())
            {
                if (TB_id.Text != "")
                {
                    Dictionary <string, object> d  = new Dictionary <string, object>();
                    Lib.DataUtility             du = new Lib.DataUtility();
                    d.Add("id", TB_id.Text.Trim());
                    d.Add("date", System.DateTime.Today);
                    DataTable dt = du.getDataTableByText(@"select status, memo from result where id = @id and date = @date", d);
                    if (dt.Rows.Count == 1)
                    {
                        if (dt.Rows[0]["status"].ToString().Substring(0, 1) != "2")
                        {
                            Account_c acc = (Account_c)Session["account"];
                            Lib.SysSetting.AddLog("設定鑑測項目", acc.Account, @"設定對象 : " + TB_id.Text.Trim() + "原鑑測項目 : " + dt.Rows[0]["memo"].ToString() + " 新鑑測項目 : " + memo, DateTime.Now);
                            d.Add("memo", memo);
                            new Lib.DataUtility().executeNonQueryByText("update result set memo = @memo where id = @id and date = @date", d);


                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('設定鑑測項目完畢');", true);
                            TB_id.Text = string.Empty;
                            Re_Select();
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('此人員受測資料已上傳,不可變更鑑測項目');", true);
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('查無今日受測資料');", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('請輸入身分證字號');", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('鑑測項目不可重覆 , 請重設鑑測項目');", true);
            }
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "alert('" + ex.Message + "');", true);
        }
    }
Ejemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SqlDataSource1.SelectParameters["date"].DefaultValue = System.DateTime.Today.ToShortDateString();
            if (Session["account"] != null)
            {
                Lib.Account acc = Session["account"] as Lib.Account;
                if (acc.OptionCode != null)
                {
                    foreach (KeyValuePair <string, string> pair in acc.OptionCode)
                    {
                        if (pair.Key == "意見管理")
                        {
                            Lib.DataUtility du = new Lib.DataUtility();
                            DataTable       dt = du.getDataTableByText("select answer, answer2, answer3 from suggestion where acc = @acc", "acc", acc.Unit_Code);
                            if (dt.Rows.Count != 0)
                            {
                                foreach (DataRow row in dt.Rows)
                                {
                                    if (acc.Unit_Code == "00001")
                                    {
                                        if (row["answer3"].ToString() == "")
                                        {
                                            isNeedAlert = true;
                                        }
                                    }
                                    if (acc.Unit_Code == "10007" || acc.Unit_Code == "07001" || acc.Unit_Code == "91A00" || acc.Unit_Code == "60002" || acc.Unit_Code == "81A00" || acc.Unit_Code == "40001")
                                    {
                                        if (row["answer2"].ToString() == "")
                                        {
                                            isNeedAlert = true;
                                        }
                                    }
                                    if (acc.Unit_Code == "19204" || acc.Unit_Code == "19901" || acc.Unit_Code == "93A06" ||
                                        acc.Unit_Code == "33I01" || acc.Unit_Code == "18600" || acc.Unit_Code == "19401" || acc.Unit_Code == "75096" || acc.Unit_Code == "175J5")
                                    {
                                        if (row["answer"].ToString() == "")
                                        {
                                            isNeedAlert = true;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (isNeedAlert)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('您有意見待回覆!!!');", true);
                }
            }
        }
    }
Ejemplo n.º 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (Session["account"] != null)
        //{
        //    if (!Page.IsPostBack)
        //    {
        //        Account a = (Account)Session["account"];
        //        if (a.Role == ((int)SysSetting.Role.user_hg).ToString())
        //        {
        Lib.DataUtility             du = new Lib.DataUtility("Data Source=192.168.0.29;Initial Catalog=Main;User ID=myap;Password=proview");
        Dictionary <string, object> d  = new Dictionary <string, object>();
        DataTable dt1 = new DataTable();
        DataTable dt2 = new DataTable();

        //d.Add("unit_code", a.Unit_Code);
        d.Add("unit_code", "00001");
        //dt = du.getDataTableByText("select information,imagepath from Center where unit_code = @unit_code", d);
        //查詢最新鑑測官簽章
        dt1 = du.getDataTableByText(@"select top 1 * from Center_Seal where unit_code='00001' and rank_code='1'order by start_date desc", d);
        //查詢最新鑑測主任簽章
        dt2 = du.getDataTableByText(@"select top 1 * from Center_Seal where unit_code='00001' and rank_code='2' order by start_date desc", d);
        if (dt1.Rows.Count == 1)               //表示登入者的身分為鑑測站資訊管理者
        {
            //Image1.ImageUrl = dt.Rows[0]["imagepath"].ToString();
            //information.Text = dt.Rows[0]["information"].ToString();
            Image1b.ImageUrl = dt1.Rows[0]["seal_img"].ToString();
            Label7b.Text     = "圖片更新時間:" + Convert.ToDateTime(dt2.Rows[0]["start_date"].ToString()).ToString("yyyy年MM月dd日 HH時mm分)");
        }
        else
        {
            Label7b.Text = "目前單位尚未上傳鑑測官簽章圖檔!!";
        }
        if (dt2.Rows.Count == 1)
        {
            Image2b.ImageUrl = dt2.Rows[0]["seal_img"].ToString();
            Label8b.Text     = "(圖片更新時間:" + Convert.ToDateTime(dt1.Rows[0]["start_date"].ToString()).ToString("yyyy年MM月dd日 HH時mm分)");
        }
        else
        {
            Label7b.Text = "目前單位尚未上傳鑑測主任簽章圖檔!!";
        }
    }
Ejemplo n.º 20
0
        public static void ExceptionLog(string type, string log, string page)
        {
            Lib.DataUtility             du = new DataUtility();
            Dictionary <string, object> d  = new Dictionary <string, object>();

            d.Add("type", type);
            d.Add("content", log);
            d.Add("date", DateTime.Now);
            d.Add("page", page);
            du.getDataTableByText("insert into exlog values (@date,@content,@type,@page)", d);
        }
Ejemplo n.º 21
0
    public DataSet GetDataSetTest()
    {
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = new DataTable();

        dt = du.getDataTableByText("select * from unit");
        DataSet ds = new DataSet();

        ds.Tables.Add(dt);
        return(ds);
    }
Ejemplo n.º 22
0
    protected void NoneUpload_OnClick(object sender, EventArgs e)
    {
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = du.getDataTableByText("select * from result where status = @status and result = '666'", "status", "104"); // 未上傳免測

        if (dt.Rows.Count == 0)
        {
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('目前沒有成績');", true);
        }
        else
        {
            dt.TableName = "upload";
            MainWS.WebService MainWs = new MainWS.WebService();
            string            msg    = MainWs.UploadResult(dt, "present");
            if (msg == "done")
            {
                List <Dictionary <string, object> > list_u = new List <Dictionary <string, object> >();
                foreach (DataRow row in dt.Rows)
                {
                    Dictionary <string, object> d_u = new Dictionary <string, object>();
                    d_u.Add("id", row["id"]);
                    list_u.Add(d_u);
                }
                try
                {
                    // 上傳更新總部資料
                    //main.executeNonQueryByText("update result set status = @status where sid = @sid", list);
                    // 更新鑑測站資料狀態
                    du.executeNonQueryByText("update result set status = '204', result = '777' where id = @id and result = '666' and status = '104'", list_u);
                    Dictionary <string, object> d_log = new Dictionary <string, object>();
                    d_log.Add("acc", ((Lib.Center.Account_c)Session["account"]).Account);
                    d_log.Add("name", ((Lib.Center.Account_c)Session["account"]).Name);
                    d_log.Add("log", "上傳免測成績 " + dt.Rows.Count.ToString() + " 筆");
                    d_log.Add("date", DateTime.Now);
                    du.executeNonQueryByText("insert into log values (@acc,@name,@log,@date)", d_log);
                    dt.Dispose();
                    //list.Clear();
                    list_u.Clear();
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert('上傳免測成績成功');", true);
                }
                catch (Exception ex)
                {
                    Lib.SysSetting.ExceptionLog(ex.GetType().ToString(), ex.Message, sender.ToString());
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + ex.Message + "\");", true);
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "alert(\"" + msg + "\");", true);
            }
            GridView4.DataBind();
            TabContainer1.ActiveTabIndex = 2;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ArrayList alist = new ArrayList();

        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();

        //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", "window.close();", true);
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            System.Web.UI.WebControls.CheckBox cbb = (System.Web.UI.WebControls.CheckBox)GridView1.Rows[i].FindControl("ch1");
            if (cbb.Checked == true)
            {
                int id = Convert.ToInt32(GridView1.Rows[i].Cells[1].Text);
                alist.Add(id);
            }
        }

        string _detailtable = "";
        string cwd          = System.IO.Directory.GetCurrentDirectory();
        string dd           = Server.MapPath(Request.ApplicationPath);

        if (Session["player"] != null)
        {
            if (Request.QueryString["center_code"] != null && Request.QueryString["date"] != null)
            {
                string _OP = "";
                _OP = ((Lib.Player)Session["player"]).ID;
                for (int j = 0; j < alist.Count; j++)
                {
                    d.Add("sid", alist[j]);
                    DataTable dt = du.getDataTableByText("Select p.name ,p.id ,p.birth ,p.rank_code ,p.mail from result r , player p where r.sid = @sid and r.id = p.id", d);
                    _detailtable = _detailtable + "<tr><td>" + dt.Rows[0]["name"] + "</td><td>" + dt.Rows[0]["id"] + "</td><td>" + Lib.SysSetting.ToRocDateFormat(dt.Rows[0]["birth"].ToString().Remove(9)) + "</td><td>" + dt.Rows[0]["rank_code"] + "</td><td>" + dt.Rows[0]["mail"] + "</td></tr>";
                    //移除Result
                    du.executeNonQueryByText("Delete from Result where sid = @sid", d);
                    d.Clear();

                    #region 通知受測人員取消報進
                    MailMessage  _MailToUser        = new MailMessage();
                    StreamReader _MailContentToUser = new StreamReader(dd + "\\Mail\\CancelTeamReserveUser.txt");
                    _MailToUser.Body = _MailContentToUser.ReadToEnd();
                    _MailToUser.Body = _MailToUser.Body.Replace("%date%", date.Text);
                    _MailToUser.Body = _MailToUser.Body.Replace("%location%", center.Text);
                    Lib.SysSetting.SaveLetter(dt.Rows[0]["mail"] + "@webmail.mil.tw", "國軍基本體能鑑測網", _MailToUser.Body, "報進取消通知信", "00");
                    Lib.SysSetting.AddLog("替代項目取消報進", ((Lib.Player)Session["player"]).ID, "取消報進 , 日期:" + Lib.SysSetting.ToRocDateFormat(date.Text) + " , 地點:" + center.Text, System.DateTime.Now);
                    #endregion
                }
            }
        }
        GridView1.DataBind();
        TabContainer1.ActiveTabIndex = 0;
    }
Ejemplo n.º 24
0
 public Player(string id, DateTime birth)
 {
     try
     {
         Lib.DataUtility du = new DataUtility();
         DataTable       dt = new DataTable();
         dt = du.getDataTableByText("select id,gender,CONVERT(VARCHAR(10),player.birth, 111) AS birth,name,unit_code,rank_code,mail,oversea,password from player where id = @id", "id", id);
         if (dt.Rows.Count == 1)
         {
             if (Convert.ToDateTime(dt.Rows[0]["birth"]) == birth)
             {
                 _isValid   = true;
                 _id        = dt.Rows[0]["id"].ToString();
                 _gender    = dt.Rows[0]["gender"].ToString();
                 _birth     = Convert.ToDateTime(dt.Rows[0]["birth"]);
                 _name      = dt.Rows[0]["name"].ToString();
                 _unit_Code = dt.Rows[0]["unit_code"].ToString();
                 _rank_code = dt.Rows[0]["rank_code"].ToString();
                 _mail      = dt.Rows[0]["mail"].ToString();
                 _oversea   = (dt.Rows[0]["oversea"].ToString() == "1" ? true : false);
                 _password  = dt.Rows[0]["password"].ToString();
                 _isExist   = true;
                 if (string.IsNullOrEmpty(_password))
                 {
                     _isCanReSetPassword  = true;
                     _isMustReSetPassword = true;
                 }
                 else
                 {
                     _isCanReSetPassword  = false;
                     _isMustReSetPassword = false;
                 }
             }
             else
             {
                 _isExist = true;
                 _isValid = false;
             }
         }
         if (dt.Rows.Count == 0)
         {
             _isExist = false;
         }
         else if (dt.Rows.Count > 1)
         {
             throw new Exception("more than one ID record !!!");
         }
     }
     catch (Exception ex)
     { }
 }
Ejemplo n.º 25
0
    protected void Page_Load(object sender, EventArgs e)
    {
	//ShowSystemMode();
        if (!Page.IsPostBack)
        {
            Lib.DataUtility du = new Lib.DataUtility();
            DataTable dt = new DataTable();
            dt = du.getDataTableByText("select item, value from sysvalue");
            string checkV = dt.Rows[1][1].ToString();
            if (checkV == "local")
            {
                CheckBoxList1.Items[0].Selected = true;
                CheckBoxList1.Items[1].Selected = false;
            }
            else
            {
                CheckBoxList1.Items[1].Selected = true;
                CheckBoxList1.Items[0].Selected = false;
            }
            checkV = dt.Rows[2][1].ToString();
            txtRemoteIP.Text = checkV;
        }

        Account_c acc = (Account_c)Session["account"];
        if (acc != null)
        {
            if (acc.Role == User_Role.Administrator)
            {
                ClearResult.Visible = true;
                ClearResult.Enabled = true;
                btnSwitch.Visible = true;
                btnSwitch.Enabled = true;
                Button1.Visible = true;
                Button1.Enabled = true;
            }
            else
            {
                ClearResult.Visible = false;
                ClearResult.Enabled = false;
                btnSwitch.Visible = false;
                btnSwitch.Enabled = false;
                Button1.Visible = false;
                Button1.Enabled = false;
            }
            ShowSystemMode();
        }
        else
        {
            ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "", "javascript:alert('逾時登出,請重新登入');window.location='./Login.aspx';", true);
        }
    }
Ejemplo n.º 26
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Dictionary <string, object> d = new Dictionary <string, object>();

        Lib.DataUtility du = new Lib.DataUtility();
        //SqlDataSource1.SelectParameters["date"].DefaultValue = System.DateTime.Today.ToShortDateString();
        try
        {
            d.Clear();
            //d.Add("date", System.DateTime.Today.ToShortDateString());
            //DataTable dt_Bulletin = du.getDataTableByText(@"select b.head, b.start,b.sid,b.deadline,(select unit_title from unit u where u.unit_code = a.unit_code) as unit_title from Account a ,Bulletin b where b.acc = a.account and b.deadline >= @date order by b.deadline DESC ", d);
            //GridView1.DataSource = dt_Bulletin;
            //GridView1.DataBind();


            d.Clear();
            d.Add("start", DateTime.Today);
            //2016-5-4家銘原版
            //System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title from bulletin b, Account a, Unit u where b.acc = a.account and a.unit_code = u.unit_code order by insertDate  desc", d);
            //2015-5-4修訂版,公告最上面消息只顯示國防部
            //System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title from bulletin b, Account a, Unit u where b.acc = a.account and a.unit_code = '00001' and deadline>=@start order by insertDate  desc", d);
            //System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title from bulletin b, Account a, Unit u where b.unit_name = '國防部' and deadline>=@start order by insertDate  desc", d);
            System.Data.DataTable dt = du.getDataTableByText("select top(1) b.sid, b.shorttext, b.head , u.unit_title,b.unit_name from bulletin b, Account a, Unit u where b.unit_name = '國防部' and deadline>=@start order by insertDate  desc", d);
            if (dt.Rows.Count == 1)
            {
                LB_head.Text     = dt.Rows[0]["head"].ToString();
                LB_text.Text     = dt.Rows[0]["shorttext"].ToString();
                LB_unit.Text     = dt.Rows[0]["unit_name"].ToString();
                this.newid.Value = dt.Rows[0]["sid"].ToString();
            }
            else
            {
                LB_head.Text     = "目前無公告內容";
                LB_text.Text     = "目前無公告內容";
                LB_unit.Text     = "國防部";
                this.newid.Value = null;
            }

            //this.Total.InnerText = " (" + GridView1.Rows.Count.ToString() + ")";
            //d.Clear();
            //d.Add("date", System.DateTime.Today.ToShortDateString());
            //dt = du.getDataTableByText(@"select count(b.sid) as total from Bulletin b where b.deadline > @date", d);
            //if (dt.Rows.Count == 1)
            //{
            //    this.Total.InnerText = " (" + dt.Rows[0]["total"].ToString() + ")";
            //}
        }
        catch (Exception ex)
        {
        }
    }
Ejemplo n.º 27
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Request.Params["sid"] != null)
         {
             Lib.DataUtility du = new Lib.DataUtility();
             DataTable       dt = du.getDataTableByText("select * from account where sid = @sid", "sid", Request.Params["sid"]);
             if (dt.Rows.Count == 1)
             {
                 acc.Text       = dt.Rows[0]["account"].ToString();
                 pwd.Text       = dt.Rows[0]["password"].ToString();
                 name.Text      = dt.Rows[0]["name"].ToString();
                 id.Text        = dt.Rows[0]["id"].ToString();
                 unit_code.Text = dt.Rows[0]["unit_code"].ToString();
                 rank_code.Text = dt.Rows[0]["rank_code"].ToString();
                 tel.Text       = dt.Rows[0]["tel"].ToString();
                 cell.Text      = dt.Rows[0]["cellphone"].ToString();
                 email.Text     = dt.Rows[0]["mail"].ToString();
                 ip.Text        = dt.Rows[0]["ip"].ToString();
                 DataTable options = du.getDataTableByText("select * from optioncode where accname = @acc", "acc", dt.Rows[0]["account"].ToString());
                 if (options.Rows.Count != 0)
                 {
                     foreach (DataRow row in options.Rows)
                     {
                         foreach (ListItem item in CheckBoxList1.Items)
                         {
                             if (row["optioncode"].ToString() == item.Value)
                             {
                                 item.Selected = true;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
    public string center_name = string.Empty; //發佈單位名稱
    protected void Page_Load(object sender, EventArgs e)
    {
        Lib.DataUtility             du = new Lib.DataUtility();
        Dictionary <string, object> d  = new Dictionary <string, object>();
        DataTable dt = new DataTable();

        d.Add("account", ((Lib.Account)Session["account"]).AccountName);

        dt = du.getDataTableByText("select center_code from Account where account=@account", d);
        if (dt.Rows.Count > 0 & !string.IsNullOrEmpty(dt.Rows[0]["center_code"].ToString()))
        {
            center_code = dt.Rows[0]["center_code"].ToString();
            if (center_code == "000")//國防部
            {
                center_name = "國防部";
            }
            else if (center_code == "111")//國防部陸軍司令部部本部
            {
                center_name = "國防部陸軍司令部部本部";
            }
            else if (center_code == "444")//國防部海軍司令部部本部
            {
                center_name = "國防部海軍司令部部本部";
            }
            else if (center_code == "666")//國防部空軍司令部部本部
            {
                center_name = "國防部空軍司令部部本部";
            }
            else//取出鑑測站代碼再找出對應名稱
            {
                Lib.DataUtility             du1 = new Lib.DataUtility();
                Dictionary <string, object> d1  = new Dictionary <string, object>();
                DataTable dt1 = new DataTable();
                d1.Add("center_code", center_code);
                dt1 = du1.getDataTableByText("select center_name from Center where center_code=@center_code", d1);
                if (dt1.Rows.Count > 0)
                {
                    center_name = dt1.Rows[0]["center_name"].ToString();
                }
            }
        }
        if (!string.IsNullOrEmpty(center_name))
        {
            Label1.Text = center_name;
        }
        else
        {
            Label1.Text = null;
        }
    }
Ejemplo n.º 29
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Lib.DataUtility             du   = new Lib.DataUtility();
        Dictionary <string, object> list = new Dictionary <string, object>();

        if (txtCode.Text != "")
        {
            list.Add("@unit_code", txtCode.Text.Trim());
            DataTable dt = new DataTable();
            dt = du.getDataTableByText("select unit_code [單位代碼], unit_title [單位全銜], [上級單位], parent_unit_code [上級單位代碼] from [VIEW_UNIT_CODE] where [unit_code] = @unit_code or [parent_unit_code] = @unit_code order by [單位代碼]", list);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
Ejemplo n.º 30
0
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        tabconatiner.ActiveTabIndex = 1;
        Lib.DataUtility du = new Lib.DataUtility();
        DataTable       dt = du.getDataTableByText("select * from account_c where account = @account", "account", DropDownList1.SelectedValue);

        _txtName.Text = dt.Rows[0]["name"].ToString();
        _txtID.Text   = dt.Rows[0]["id"].ToString();
        _txtPwd.Text  = dt.Rows[0]["password"].ToString();
        //_txtUnit.Text = dt.Rows[0]["unit_code"].ToString();
        _txtRank.Text = dt.Rows[0]["rank_code"].ToString();
        _txtTel.Text  = dt.Rows[0]["tel"].ToString();
        _txtMail.Text = dt.Rows[0]["mail"].ToString();
        _txtCell.Text = dt.Rows[0]["cellphone"].ToString();
        _txtIP.Text   = dt.Rows[0]["ip"].ToString();
    }