コード例 #1
0
        /**  事假  **/
        private DataTable twotable()
        {
            tenten(context);
            string sql;

            username = context.Request["Alternative_user"] != null ? context.Request["Alternative_user"].ToString().Length == 5 ? context.Request["Alternative_user"].ToString().Substring(1) : context.Request["Alternative_user"].ToString() : username;

            sql  = "SELECT sum(pa60011)/60 as pa60011 ";
            sql += "FROM [hrs_mis].[dbo].[WPA60] ";
            sql += "where PA60001='" + Enterprise.ConStr_produceline + "' AND PA60004 = '2' and PA60002 = '" + username + "' and PA60006 like '%" + DateTime.Now.ToString("yyyy") + "%'";

            DataSet ds = new DataSet();

            using (SqlConnection conn = new SqlConnection(hrs))
            {
                SqlDataAdapter da = new SqlDataAdapter(sql, conn);
                da.Fill(ds);
            }

            //TBI_HRS 的事假時數總和
            sql = @"SELECT SUM(PA60011) total_ 
FROM[TBI_HRS].[dbo].[PA123]
WHERE PA60001 = '" + Enterprise.ConStr_produceline + @"'
AND pa60043 is null
AND PA60002 = '" + username + @"'
AND PA60004 = '2' /* 2 = 事假 */
AND PA60039 in(1,2,3,4)
";

            int sum1 = 0;
            int sum2 = 0;

            DataTable temptable1 = BOSSQL.TBIHRSExecuteQuery(sql);

            //TBI_HRS 時數
            if (temptable1.Rows[0]["total_"] != DBNull.Value)
            {
                sum1 = int.Parse(temptable1.Rows[0]["total_"].ToString());
            }

            //HRS_MIS 時數
            if (ds.Tables[0].Rows[0]["PA60011"] != DBNull.Value)
            {
                sum2 = int.Parse(ds.Tables[0].Rows[0]["PA60011"].ToString());
            }

            //合併
            ds.Tables[0].Rows[0]["PA60011"] = (sum1 + sum2) / 60;

            return(ds.Tables.Count > 0 ? ds.Tables[0] : new DataTable());
        }
コード例 #2
0
        public void deathtwice(HttpContext context)
        {
            tenten(context);

            username = context.Request["Alternative_user"] != null ? context.Request["Alternative_user"].ToString() : username;
            string        y    = now.Substring(0, 4);
            string        o    = now.Substring(4, 2);
            string        p    = now.Substring(6, 2);
            string        z    = DateTime.Parse(now.Substring(0, 4) + "-" + now.Substring(4, 2) + "-" + now.Substring(6, 2)).ToString("yyyy-MM-dd HH:mm:ss.fff");
            DateTime      a    = DateTime.Parse(z);
            SqlConnection conn = new SqlConnection(tbiHRS);

            conn.Open();
            string    sql2 = "select top 1 type,theEnd from TBI_HRS.dbo.HRS08 where username = '******' and timeleft != '0' order by ID desc";
            DataTable db   = BOSSQL.TBIHRSExecuteQuery(sql2);

            if (db.Rows.Count > 0)                                     //判斷HRS08是否有剩餘時數,有的話代表還有喪假的週期尚未結束
            {
                DateTime b = DateTime.Parse(db.Rows[0][1].ToString()); //第一百天
                if (a < b)                                             //登入日小於第一百天,才進行選項上鎖
                {
                    string type = db.Rows[0][0].ToString().Trim();
                    context.Response.Write(type);
                }
            }
            else
            {
                string sql = "select pa60004,pa60043,pa60044,pa60047 from [TBI_HRS].[dbo].[PA123] ";
                sql += "where pa60002 = '" + username + "' and pa60004 = '8' and pa60039 != '0' and pa60039 != '5' and pa60043 is null and pa60044 is not null ";
                sql += "and pa60007 > '" + MonthEarly + "'";
                DataTable dt = BOSSQL.TBIHRSExecuteQuery(sql);
                if (dt.Rows.Count > 0)
                {
                    DateTime b = DateTime.Parse(dt.Rows[0][3].ToString());
                    DateTime c = b.AddDays(100);
                    if (a < c)//登入日小於第一百天,才進行選項上鎖
                    {
                        string pa60044 = dt.Rows[0][2].ToString();
                        context.Response.Write(pa60044);
                    }
                }
            }
        }
コード例 #3
0
        public void DeathDateType(HttpContext context)
        {
            tenten(context);
            string   user = context.Request["user"].ToString();
            int      hrsum = Convert.ToInt32(context.Request["hrsum"]);
            string   death = context.Request["death"].ToString().Trim();
            string   Dstart = context.Request["Dstart"].ToString();
            string   sql, sql2;
            string   z = DateTime.Parse(now.Substring(0, 4) + "-" + now.Substring(4, 2) + "-" + now.Substring(6, 2)).ToString("yyyy-MM-dd HH:mm:ss.fff");
            DateTime a = DateTime.Parse(z);//登入日

            //判斷該天數別是否還有剩餘時數&百日
            sql = "select top 1 * from [TBI_HRS].[dbo].[HRS08] where username = '******' and type = '" + death + "' order by ID desc";
            DataTable db = BOSSQL.TBIHRSExecuteQuery(sql);

            if (db.Rows.Count > 0)
            {
                string   timeleft       = db.Rows[0][5].ToString().Trim();//剩餘時數
                int      timeleftNumber = Convert.ToInt32(timeleft);
                string   b      = db.Rows[0][4].ToString();
                DateTime theEnd = DateTime.Parse(b); //第一百天
                DateTime start  = DateTime.Parse(Dstart);
                if (a > theEnd)                      //如果登入日期大於百日,一律新增
                {
                    context.Response.Write("HRS insert");
                }
                else
                {
                    if (timeleft == "0")//給予新週期(insert)
                    {
                        context.Response.Write("HRS insert");
                    }
                    //else if (start > theEnd)//百日判斷
                    //{
                    //    context.Response.Write("100");
                    //}
                    else//扣舊週期(update)
                    {
                        if (hrsum > timeleftNumber && timeleft != "0")//請假時數大於剩餘時數
                        {
                            context.Response.Write("igt lefttime");//is greater than
                        }
                        else
                        {
                            context.Response.Write("HRS update");
                        }
                    }
                }
            }
            else
            {
                sql2  = "select top 1 pa60002,pa60003,pa60004,pa60043,pa60044,pa60047 from [TBI_HRS].[dbo].[PA123] where pa60002 = '" + user + "' ";
                sql2 += "and pa60004 = '8' and pa60043 is null and PA60039 != '5' and pa60044 like '" + death + "%' ";
                sql2 += "and pa60007 > '" + MonthEarly + "' order by pa60007 desc";
                DataTable dc = BOSSQL.TBIHRSExecuteQuery(sql2);
                string    x  = DateTime.Parse(dc.Rows[0][5].ToString()).AddDays(100).ToString("yyyy-MM-dd 23:59:59.000");
                DateTime  b  = DateTime.Parse(x); //第一百天
                if (a > b)                        //如果
                {
                    context.Response.Write("HRS insert");
                }
                else
                {
                    string pa6044        = dc.Rows[0][4].ToString().Substring(0, 1); //天數別
                    int    pa6044TypeAll = Convert.ToInt32(pa6044) * 8 * 60;         //所選天數別總時數
                    if (hrsum > pa6044TypeAll)                                       //選取總數超過他所選的天數總數
                    {
                        context.Response.Write("hrsum");
                    }
                    else //沒有剩餘時數 == 給予時數
                    {
                        context.Response.Write("HRS insert");
                    }
                }
            }
        }
コード例 #4
0
        public void DeathIgtupdate(HttpContext context)
        {
            tenten(context);
            string   sql1, sql2;
            string   type     = context.Request["type"].ToString();
            string   water    = context.Request["water"].ToString();
            double   hr       = Convert.ToInt32(context.Request["hr"]);
            string   z        = DateTime.Parse(now.Substring(0, 4) + "-" + now.Substring(4, 2) + "-" + now.Substring(6, 2)).ToString("yyyy-MM-dd HH:mm:ss.fff");
            DateTime a        = DateTime.Parse(z);
            int      typetime = Convert.ToInt32(type) * 8; //天數別總時數

            if (hr > typetime)                             //單筆大於天數別總時數
            {
                context.Response.Write("igt");
            }
            else
            {
                sql2 = "select top 1 timeleft,theEnd from TBI_HRS.dbo.HRS08 where username = '******' and type = '" + type + "' and timeleft != '0' order by ID desc";
                DataTable db = BOSSQL.TBIHRSExecuteQuery(sql2);
                if (db.Rows.Count > 0)//比較單筆時數是否超過剩餘時數(抓HRS08)
                {
                    DateTime b = DateTime.Parse(db.Rows[0][1].ToString());
                    if (a < b)//登入日小於喪假第一百天,才進行剩餘時數防呆
                    {
                        sql1  = "select sum(PA60011)as pa60011 from TBI_HRS.dbo.PA123 ";
                        sql1 += "where pa60002 = '" + username + "' and pa60003 != '" + water + "' and pa60004 = '8' and pa60039 != '0' and pa60039 != '5' and pa60044 = '" + type + "' and pa60043 is null ";
                        sql1 += "and pa60007 > '" + MonthEarly + "'";
                        DataTable dc = BOSSQL.TBIHRSExecuteQuery(sql1);
                        if (dc.Rows[0][0].ToString() != "")
                        {
                            double timeleft = Convert.ToInt32(db.Rows[0][0]) / 60 - Convert.ToInt32(dc.Rows[0][0]) / 60;
                            if (timeleft == 0)
                            {
                                context.Response.Write("typeover");
                            }
                            else if (hr > timeleft)
                            {
                                context.Response.Write("timeleft over1");
                            }
                            else
                            {
                                context.Response.Write("true");
                            }
                        }
                        else
                        {
                            if (hr > Convert.ToInt32(db.Rows[0][0]))
                            {
                                context.Response.Write("timeleft over1");
                            }
                            else
                            {
                                context.Response.Write("true");
                            }
                        }
                    }
                    else
                    {
                        context.Response.Write("true");
                    }
                }
                else
                {
                    sql1  = "select sum(PA60011)as pa60011 from TBI_HRS.dbo.PA123 ";
                    sql1 += "where pa60002 = '" + username + "' and pa60003 != '" + water + "' and pa60004 = '8' and pa60039 != '0' and pa60039 != '5' and pa60044 = '" + type + "' and pa60043 is null ";
                    sql1 += "and pa60007 > '" + MonthEarly + "'";
                    DataTable dc = BOSSQL.TBIHRSExecuteQuery(sql1);
                    if (dc.Rows[0][0].ToString() != "")
                    {
                        double timeleft2 = typetime - Convert.ToInt32(dc.Rows[0][0]) / 60; //目前可請時數
                        if (timeleft2 == 0)                                                //如果待審中的喪假已經到達該天數別的上限
                        {
                            context.Response.Write("typeover");
                        }
                        else if (hr > timeleft2)//該假單時數大於目前剩餘可請時數
                        {
                            context.Response.Write("timeleft over2");
                        }
                        else
                        {
                            context.Response.Write("true");
                        }
                    }
                    else
                    {
                        context.Response.Write("true");
                    }
                }
            }
        }
コード例 #5
0
        public void DeathIgt(HttpContext context)
        {
            tenten(context);
            string   sql1, sql2;
            string   type     = context.Request["type"].ToString();
            double   hr       = Convert.ToDouble(context.Request["hr"]);
            string   z        = context.Request["from"];   // DateTime.Parse(process.now.Substring(0, 4) + "-" + process.now.Substring(4, 2) + "-" + process.now.Substring(6, 2)).ToString("yyyy-MM-dd HH:mm:ss.fff");
            DateTime a        = DateTime.Parse(z);
            int      typetime = Convert.ToInt32(type) * 8; //天數別總時數
            string   Hundred  = context.Request["Hundred"];

            if (hr > typetime)//單筆大於天數別總時數
            {
                context.Response.Write("igt");
            }
            else
            {
                sql2 = "select top 1 timeleft,theEnd from TBI_HRS.dbo.HRS08 where username = '******' and type = '" + type + "' and timeleft != '0' order by ID desc";
                DataTable db = BOSSQL.TBIHRSExecuteQuery(sql2);
                if (db.Rows.Count > 0)//比較單筆時數是否超過剩餘時數(抓HRS08)
                {
                    DateTime b = DateTime.Parse(db.Rows[0][1].ToString());
                    if (a < b)//登入日小於喪假第一百天,才進行剩餘時數防呆
                    {
                        sql1  = "select sum(PA60011)as pa60011 from TBI_HRS.dbo.PA123 ";
                        sql1 += "where pa60002 = '" + username + "' and pa60004 = '8' and pa60039 != '0' and pa60039 != '5' and pa60044 = '" + type + "' and pa60043 is null ";
                        sql1 += "and pa60007 >'" + MonthEarly + "'";
                        DataTable dc = BOSSQL.TBIHRSExecuteQuery(sql1);
                        if (dc.Rows[0][0].ToString() != "")
                        {
                            double timeleft = Convert.ToInt32(db.Rows[0][0]) / 60 - Convert.ToInt32(dc.Rows[0][0]) / 60;
                            if (timeleft == 0)
                            {
                                context.Response.Write("typeover");
                            }
                            else if (hr > timeleft)
                            {
                                context.Response.Write("timeleft over1");
                            }
                            else
                            {
                                context.Response.Write("true");
                            }
                        }
                        else
                        {
                            if (hr > Convert.ToInt32(db.Rows[0][0]))
                            {
                                context.Response.Write("timeleft over1");
                            }
                            else
                            {
                                context.Response.Write("true");
                            }
                        }
                    }
                    else
                    {
                        context.Response.Write("true");
                    }
                }
                else
                {
                    // 前端訃聞日期沒有取得時
                    if (Hundred.ToUpper() == "NULL")
                    {
                        string sql_Death_GetLastestDate = @"SELECT top 1 SUM(pa60011) 目前使用時數,(PA60044*8*60)總時數,PA60047,pa60044
                                          FROM [TBI_HRS].[dbo].[PA123]
                                          where PA60002='" + username + @"'
                                          and PA60001='" + Enterprise.ConStr_produceline + @"'
                                          and PA60043 is  null
                                          group by PA60047,pa60044
                                          having SUM(pa60011)<=(PA60044*8*60)
                                          order by pa60047";

                        sql_Death_GetLastestDate = sql_Death_GetLastestDate.Replace("\r\n", "").Replace("\t", "");

                        DataTable dt_Death_GetLastestDate = BOSSQL.TBIHRSExecuteQuery(sql_Death_GetLastestDate);


                        Hundred = dt_Death_GetLastestDate.Rows[0]["PA60047"].ToString();
                    }
                    // 請假日期 超過 訃聞日期 100 日 就返回錯誤(超過100日錯誤)
                    if (a > DateTime.Parse(Hundred).AddDays(100))
                    {
                        context.Response.Write("hundredover");
                        context.Response.End();
                    }

                    sql1  = "select sum(PA60011)as pa60011 from TBI_HRS.dbo.PA123 ";
                    sql1 += "where pa60002 = '" + username + "' and pa60004 = '8' and pa60039 != '0' and pa60039 != '5' and pa60044 = '" + type + "' and pa60043 is null ";
                    sql1 += "and pa60007 > '" + MonthEarly + "'";
                    DataTable dc = BOSSQL.TBIHRSExecuteQuery(sql1);
                    if (dc.Rows[0][0].ToString() != "")
                    {
                        double timeleft2 = typetime - Convert.ToInt32(dc.Rows[0][0]) / 60; //目前可請時數
                        if (timeleft2 == 0)                                                //如果待審中的喪假已經到達該天數別的上限
                        {
                            context.Response.Write("typeover");
                        }
                        else if (hr > timeleft2)//該假單時數大於目前剩餘可請時數
                        {
                            context.Response.Write("timeleft over2");
                        }
                        else
                        {
                            context.Response.Write("true");
                        }
                    }
                    else
                    {
                        context.Response.Write("true");
                    }
                }
            }
        }
コード例 #6
0
        /**  取得目前此段時間屬於哪一個班表  **/
        private void Get_CurrentTime_ClsTime()
        {
            string Alternative = context.Request["user"].ToString();

            username = Alternative != "" && Alternative != null && Alternative != "null" ? Alternative.Length == 5 ? Alternative.Substring(1) : Alternative : username;

            //如果是現場&非排班人員不需要跑此段 Function
            if (Spot.IsSchedulePerson(username) == false)
            {
                //丟空值回前端
                context.Response.Write(JsonConvert.SerializeObject(new { }));

                return;
            }


            DateTime leavedate   = DateTime.Parse(context.Request["leavedate"]);
            DateTime toleavedate = DateTime.Parse(context.Request["toleavedate"]);

            string leavedate_t   = leavedate.ToString("yyyy/MM/dd");
            string toleavedate_t = toleavedate.ToString("yyyy/MM/dd");


            string SQL = @"/*PB29004 1=排班 3=排休*/
                         select WPB29.PB29002,WPB29.PB29003,WPB29.PB29004,WPB29.PB29005,WPA20.PA20003
                         from (select * from hrs_mis.dbo.WPB29
                         where pb29003='" + username + @"'
                         AND PB29001='" + Enterprise.ConStr_produceline + @"'
                         AND PB29002 between CAST('" + leavedate_t + @" 00:00' as datetime) and CAST('" + toleavedate_t + @" 00:00' as datetime)) WPB29
                         join (select * from  hrs_mis.dbo.WPA20 where PA20001='" + Enterprise.ConStr_produceline + "') WPA20 on WPB29.PB29005=WPA20.PA20002";

            SQL = SQL.Replace("\r\n", "").Replace("\t", "");

            DataTable dt = BOSSQL.hrsExecuteQuery(SQL);

            //如果沒資料
            if (dt.Rows.Count <= 0)
            {
                JArray error_array = new JArray();

                JObject obj = new JObject();
                obj.Add("Range", "此範圍無法申請");
                obj.Add("ClsName", "");

                error_array.Add(obj);

                //丟回前端
                context.Response.Write(JsonConvert.SerializeObject(error_array));

                return;
            }


            string start_time = dt.Rows[0]["PB29002"].ToString();

            string class_code = dt.Rows[0]["PB29005"].ToString();

            string class_time = dt.Rows[0]["PA20003"].ToString();

            JArray result = new JArray();

            //裁切當中不同的資料,存成一個 陣列
            foreach (DataRow i in dt.Rows)
            {
                //假如目前讀取的班別 代碼 跟現在不同 就執行
                if (i["PB29005"].ToString() != class_code)
                {
                    int last_time = dt.Rows.IndexOf(i) - 1;

                    JObject obj = new JObject();
                    obj.Add("Range", DateTime.Parse(start_time).ToString("yyyy/MM/dd") + "~" + DateTime.Parse(dt.Rows[last_time]["PB29002"].ToString()).ToString("yyyy/MM/dd"));
                    obj.Add("ClsName", dt.Rows[last_time]["PA20003"].ToString());
                    result.Add(obj);

                    start_time = i["PB29002"].ToString(); //將開始時間設定目前時間
                    class_code = i["PB29005"].ToString(); //將 TimeCode 設定目前的 TimeCode
                }

                //將最後一個丟進去 陣列
                if (dt.Rows.IndexOf(i) == dt.Rows.Count - 1)
                {
                    JObject obj = new JObject();
                    obj.Add("Range", DateTime.Parse(start_time).ToString("yyyy/MM/dd") + "~" + DateTime.Parse(i["PB29002"].ToString()).ToString("yyyy/MM/dd"));
                    obj.Add("ClsName", i["PA20003"].ToString());
                    result.Add(obj);

                    break;
                }
            }

            //丟回前端
            context.Response.Write(JsonConvert.SerializeObject(result));
        }
コード例 #7
0
        public void eightupdate(HttpContext context)
        {
            tenten(context);
            string   sql1, sql2;
            string   type     = context.Request["type"].ToString();
            string   water    = context.Request["water"].ToString();
            int      typetime = Convert.ToInt32(type) * 8;
            string   z        = DateTime.Parse(now.Substring(0, 4) + "-" + now.Substring(4, 2) + "-" + now.Substring(6, 2)).ToString("yyyy-MM-dd HH:mm:ss.fff");
            DateTime a        = DateTime.Parse(z);

            sql1  = "select top 1 PA60044 from TBI_HRS.dbo.PA123 ";
            sql1 += "where pa60002 = '" + username + "' and pa60003 != '" + water + "' and pa60004 = '8' and pa60039 != '0' and pa60039 != '5' and pa60044 = '" + type + "' ";
            sql1 += "and pa60043 is null and pa60007 > '" + MonthEarly + "' order by pa60007 desc";
            DataTable dt = BOSSQL.TBIHRSExecuteQuery(sql1);

            if (dt.Rows.Count > 0)//判斷是否有待審中的假單
            {
                sql1  = "select sum(PA60011)as pa60011 from TBI_HRS.dbo.PA123 ";
                sql1 += "where pa60002 = '" + username + "' and pa60003 != '" + water + "'  and pa60004 = '8' and pa60039 != '0' and pa60039 != '5' ";
                sql1 += "and pa60044 = '" + type + "' and pa60043 is null and pa60007 > '" + MonthEarly + "'";
                DataTable dc = BOSSQL.TBIHRSExecuteQuery(sql1);//將待審中的假單的時數加總起來

                sql2 = "select top 1 timeleft,theEnd from TBI_HRS.dbo.HRS08 where username = '******' and type = '" + type + "' and timeleft != '0' order by ID desc";
                DataTable db = BOSSQL.TBIHRSExecuteQuery(sql2);
                if (db.Rows.Count > 0)                                     //判斷HRS08是否有剩餘時數
                {
                    DateTime b = DateTime.Parse(db.Rows[0][1].ToString()); //第一百天
                    if (a > b)                                             //登入日超過第一百天,結束這次喪假週期
                    {
                        context.Response.Write("false");
                    }
                    else
                    {
                        double timeleft = Convert.ToInt32(db.Rows[0][0]) / 60 - Convert.ToInt32(dc.Rows[0][0]) / 60;//HRS08有剩餘時數的話,可請時數:HRS08-PA123待審假單總時數
                        context.Response.Write(timeleft);
                    }
                }
                else
                {
                    double timeleft2 = typetime - Convert.ToInt32(dc.Rows[0][0]) / 60;//HRS08沒有剩餘時數的話,可請時數:天數別總時數-PA123待審假單總時數
                    context.Response.Write(timeleft2);
                }
            }
            else
            {
                sql2 = "select top 1 timeleft,theEnd from TBI_HRS.dbo.HRS08 where username = '******' and type = '" + type + "' and timeleft != '0' order by ID desc";
                DataTable db = BOSSQL.TBIHRSExecuteQuery(sql2);
                if (db.Rows.Count > 0)//判斷HRS08是否有剩餘時數
                {
                    double   timeleft3 = Convert.ToInt32(db.Rows[0][0]) / 60;
                    DateTime b         = DateTime.Parse(db.Rows[0][1].ToString()); //第一百天
                    if (a > b)                                                     //登入日超過第一百天,結束這次喪假週期
                    {
                        context.Response.Write("false");
                    }
                    else
                    {
                        if (timeleft3 != 0)
                        {
                            context.Response.Write(timeleft3);
                        }
                        else
                        {
                            context.Response.Write("false");
                        }
                    }
                }
                else
                {
                    context.Response.Write("false");
                }
            }
        }
コード例 #8
0
        /**  事假  **/
        /**  特休累計  **/
        public void ninehr(HttpContext context)
        {
            tenten(context);

            username = context.Request["Alternative_user"] != null ? context.Request["Alternative_user"].ToString().Length == 5 ? context.Request["Alternative_user"].ToString().Substring(1) : context.Request["Alternative_user"].ToString() : username;

            string sql;

            //sql = @"select sum(PA86010) as PA86010, sum(PA86011) as PA86011
            //        from [hrs_mis].[dbo].[WPA86]
            //        where PA86002='" + leftleave.username + @"'
            //        and PA86001='001'
            //        and GETDATE() between PA86007 and PA86008".Replace("\r\n", "").Replace("\t", "");
            sql = @"select sum(PA86010) as PA86010, sum(PA86011) as PA86011 
                    from [hrs_mis].[dbo].[WPA86]
                    where PA86001='" + Enterprise.ConStr_produceline + "' AND PA86002='" + username + "'  and PA86004='" + DateTime.Now.ToString("yyyy") + "' and PA86007 <= getdate()".Replace("\r\n", "").Replace("\t", "");
            //sql = " select sum(PA86010) as PA86010, sum(PA86011) as PA86011 ";
            //sql += "from [hrs_mis].[dbo].[WPA86] ";
            //sql += "where PA86002 = '" + leftleave.username + "' and PA86004 = '" + DateTime.Now.ToString("yyyy-MM-dd").Substring(0, 4) + "' ";
            //sql += "and PA86007 <= '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and PA86001 = '001' ";

            //不用設定特休的終止日期 可以延用同年的特休假
            //sql += "and PA86008 >= '" + DateTime.Now.ToString("yyyy-MM-dd") + "'";

            DataTable dt = new DataTable();

            dt = BOSSQL.hrsExecuteQuery(sql);

            //if (dt.Rows[0][0].ToString() != "")
            //{
            //    int pa8610 = Convert.ToInt16(dt.Rows[0][0].ToString());
            //    int pa8611 = Convert.ToInt16(dt.Rows[0][1].ToString());
            //    int min = pa8610 - pa8611;
            //    if (min == 0)
            //    {
            //        sql = " select PA86010, PA86011, PA86007 ";
            //        sql += "from [hrs_mis].[dbo].[WPA86] ";
            //        sql += "where PA86002 = '" + leftleave.username + "' and PA86004 = '" + DateTime.Now.ToString("yyyy-MM-dd").Substring(0, 4) + "' ";
            //        sql += "and PA86007 > '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and PA86001 = '001' order by PA86007 ";

            //        dt = BOSSQL.hrsExecuteQuery(sql);

            //    }
            //}
            //else
            //{
            //    sql = " select PA86010, PA86011, PA86007 ";
            //    sql += "from [hrs_mis].[dbo].[WPA86] ";
            //    sql += "where PA86002 = '" + leftleave.username + "' and PA86004 = '" + DateTime.Now.ToString("yyyy-MM-dd").Substring(0, 4) + "' ";
            //    sql += "and PA86007 > '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and PA86001 = '001' order by PA86007 ";

            //    dt = BOSSQL.hrsExecuteQuery(sql);


            //}

            //------------------WPA60 特休時數 + WPA123 特休時數-----------------
            //dt_wpa123 [請假仿WPA60資料表] - 取得目前特休所有剩餘時數,並和WPA86已使用時數加總
            string user = username.TrimStart('0').PadLeft(4, '0');

            string sql_wpa123 = @"/*WPA73*/
                         SELECT *
                         FROM [TBI_HRS].[dbo].[PA123]
                         where PA60001='" + conStr + @"'
                         and PA60004=9
                         and PA60043 is null
                         and PA60039  not in (0,5)
                         and PA60002='" + user + "'";

            sql_wpa123 = sql_wpa123.Replace("\r\n", "").Replace("\t", "");

            DataTable dt_wpa123 = new DataTable();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["tbiHRSConnectionString"].ConnectionString))
            {
                using (SqlCommand comm = new SqlCommand())
                {
                    using (SqlDataAdapter adapter = new SqlDataAdapter(comm))
                    {
                        comm.Connection  = conn;
                        comm.CommandText = sql_wpa123;
                        conn.Open();
                        adapter.Fill(dt_wpa123);
                    }
                }
            }

            float cost_wpa123 = dt_wpa123.Rows.Cast <DataRow>().Sum(z => int.Parse(z["PA60011"].ToString()));

            //設定 ReadOnly 才可更改資料
            dt.Columns["PA86011"].ReadOnly = false;

            int usedTime = 0;

            if (dt.Rows[0]["PA86011"] != DBNull.Value)
            {
                usedTime = int.Parse(dt.Rows[0]["PA86011"].ToString());
            }

            dt.Rows[0]["PA86011"] = usedTime + cost_wpa123;

            //將未來啟用時間加入傳回資料項目中
            IsFutureHasDate(dt, user);

            string str_json = JsonConvert.SerializeObject(dt, Formatting.Indented);

            context.Response.Write(str_json);
        }