示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            JuicDao dao    = new JuicDao("MENU");
            var     user   = dao.GetUser(this.User.Identity.Name.ToString());
            string  usname = user.Rows[0]["username"].ToString().Trim();



            if (!IsPostBack)
            {
                TextBox3.Text = usname;
                Label22.Text  = "%" + usname + "%";
            }

            //檢查是否有財會核決權限
            var check = dao.checkcontrol(User.Identity.Name.ToString(), 24);//待新增

            //有核決權限,識別碼OK
            if (check.Rows.Count != 0)
            {
                checkma.Text = "OK";
            }
            //檢查是否有查他人請款單權限
            var check2 = dao.checkcontrol(User.Identity.Name.ToString(), 25);//待新增

            //有核決權限,可以性名方式搜尋
            if (check2.Rows.Count != 0)
            {
                TextBox3.ReadOnly = false;
            }
        }
示例#2
0
        protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            JuicDao dao      = new JuicDao("MENU");
            var     name     = dao.GetUser(Page.User.Identity.Name.ToString());
            string  username = "";

            if (name.Rows.Count > 0)
            {
                username = name.Rows[0]["username"].ToString();
            }

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Cells[1].ForeColor = System.Drawing.Color.Red;
                e.Row.Cells[2].ForeColor = System.Drawing.Color.Red;



                if (e.Row.Cells[3].Text.Trim() == username.Trim() || checkma.Text == "OK")
                {
                    Button btn = (Button)e.Row.FindControl("del");
                    btn.Visible = true;
                    Button btn2 = (Button)e.Row.FindControl("back");
                    btn2.Visible = true;
                }
            }
        }
示例#3
0
        protected void service_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            JuicDao dao    = new JuicDao("MENU");
            var     user   = dao.GetUser(this.User.Identity.Name.ToString());
            string  usname = user.Rows[0]["username"].ToString().Trim();

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //1070531;jesse;資材需求 增加支付對象  根據欄位順序6以後需要調整
                if (e.Row.Cells[3].Text.Trim() == usname && e.Row.Cells[9].Text.Trim() == "N")
                {
                    Button btn = (Button)e.Row.FindControl("remove");
                    btn.Visible = true;
                    //Button btn2 = (Button)e.Row.FindControl("edit");
                    //btn2.Visible = true;
                }
                if (checkma.Text == "OK" && e.Row.Cells[9].Text.Trim() == "N")
                {
                    //Button btn = (Button)e.Row.FindControl("check");
                    //btn.Visible = true;
                }
                if (e.Row.Cells[7].Text.Trim() == "零用金")
                {
                    Button btn = (Button)e.Row.FindControl("print1");
                    btn.Visible = true;
                }
                else
                {
                    Button btn = (Button)e.Row.FindControl("print2");
                    btn.Visible = true;
                }
                if (e.Row.Cells[3].Text.Trim() == usname && e.Row.Cells[9].Text.Trim() == "Y")
                {
                    //Button btn = (Button)e.Row.FindControl("giveup");
                    //btn.Visible = true;
                }
                //美金顯示小數點
                //if  (e.Row.Cells[4].Text.Trim() == "USD" )
                //{
                //    e.Row.Cells[5].Text = "123";
                //}
            }
        }
示例#4
0
        protected void service_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            JuicDao dao    = new JuicDao("MENU");
            var     user   = dao.GetUser(this.User.Identity.Name.ToString());
            string  usname = user.Rows[0]["username"].ToString().Trim();

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[2].Text.Trim() == usname)
                {
                    Button btn = (Button)e.Row.FindControl("remove");
                    btn.Visible = true;
                    //Button btn2 = (Button)e.Row.FindControl("edit");
                    //btn2.Visible = true;
                }
                Button btn2 = (Button)e.Row.FindControl("print1");
                btn2.Visible = true;
            }
        }
示例#5
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            string   datest1;
            string   datest2;
            DateTime date1;
            DateTime date2;

            if (Calendar1.SelectedDate.ToString("yyyy") != "0001")
            {
                datest1 = Calendar1.SelectedDate.ToString("yyyy/MM/dd") + " " + Drptime1.SelectedItem.Text + ":" + Drptime2.SelectedItem.Text;
                datest2 = Calendar1.SelectedDate.ToString("yyyy/MM/dd") + " " + Drptime3.SelectedItem.Text + ":" + Drptime4.SelectedItem.Text;
                date1   = DateTime.Parse((Calendar1.SelectedDate.ToString("yyyy/MM/dd") + " " + Drptime1.SelectedItem.Text + ":" + Drptime2.SelectedItem.Text));
                date2   = DateTime.Parse((Calendar1.SelectedDate.ToString("yyyy/MM/dd") + " " + Drptime3.SelectedItem.Text + ":" + Drptime4.SelectedItem.Text));
            }
            else
            {
                datest1 = DateTime.Now.ToString("yyyy/MM/dd") + " " + Drptime1.SelectedItem.Text + ":" + Drptime2.SelectedItem.Text;
                datest2 = DateTime.Now.ToString("yyyy/MM/dd") + " " + Drptime3.SelectedItem.Text + ":" + Drptime4.SelectedItem.Text;
                date1   = DateTime.Parse((DateTime.Now.ToString("yyyy/MM/dd") + " " + Drptime1.SelectedItem.Text + ":" + Drptime2.SelectedItem.Text));
                date2   = DateTime.Parse((DateTime.Now.ToString("yyyy/MM/dd") + " " + Drptime3.SelectedItem.Text + ":" + Drptime4.SelectedItem.Text));
            }


            //判斷是否已有人預約
            string strConn = ConfigurationManager.ConnectionStrings["MENU"].ConnectionString;

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                //String QQ = "select * from TB_Carrent where (startrent BETWEEN '" + (datestart.Text + " " + DropDownList2.SelectedItem.Text + ":" + DropDownList3.SelectedItem.Text) + "' AND  '" + (dateend.Text + " " + DropDownList4.SelectedItem.Text + ":" + DropDownList5.SelectedItem.Text) + "') or (endrent BETWEEN  '" + (datestart.Text + " " + DropDownList2.SelectedItem.Text + ":" + DropDownList3.SelectedItem.Text) + "' AND  '" + (dateend.Text + " " + DropDownList4.SelectedItem.Text + ":" + DropDownList5.SelectedItem.Text) + "') and (car_no='" + DropDownList1.SelectedValue + "')";
                String QQ = "select * from TB_Conference where (((starttime BETWEEN '" + datest1 + "' AND  '" + datest2 + "') and(starttime <>'" + datest2 + "')) or ((endtime BETWEEN  '" + datest1 + "' AND  '" + datest2 + "')and(endtime <>'" + datest1 + "')) or (starttime < '" + datest1 + "' AND endtime> '" + datest2 + "')) and (Roomid='" + DropDownList1.SelectedValue + "')";

                SqlDataAdapter da = new SqlDataAdapter(QQ, conn);
                DataSet        ds = new DataSet();
                da.Fill(ds);
                if (ds.Tables[0].Rows.Count != 0)
                {
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        conn.Close();
                        string strJS = "alert('此時段已有人預約');";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true);
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strJS, true);
                        return;
                    }
                }
            }

            //取得申請者姓名
            JuicDao dao      = new JuicDao("MENU");
            var     name     = dao.GetUser(Page.User.Identity.Name.ToString());
            string  username = "******";

            if (name.Rows.Count > 0)
            {
                username = name.Rows[0]["username"].ToString();
            }

            using (SqlConnection conn = new SqlConnection(strConn))
            {
                string strCmd = "Insert into TB_Conference(Roomid,Roomname,rentdate,starttime,endtime,userid,username,purpose,water,people,PS)values(@Roomid,@Roomname,@rentdate,@starttime,@endtime,@userid,@username,@purpose,@water,@people,@PS)";
                using (SqlCommand cmd = new SqlCommand(strCmd, conn))
                {
                    cmd.Parameters.AddWithValue("@Roomid", DropDownList1.SelectedValue);
                    cmd.Parameters.AddWithValue("@Roomname", DropDownList1.SelectedItem.Text);
                    cmd.Parameters.AddWithValue("@rentdate", Calendar1.SelectedDate.ToString("yyyy/MM/dd"));
                    cmd.Parameters.AddWithValue("@starttime", date1);
                    cmd.Parameters.AddWithValue("@endtime", date2);
                    cmd.Parameters.AddWithValue("@userid", User.Identity.Name.ToString());
                    cmd.Parameters.AddWithValue("@username", username);
                    cmd.Parameters.AddWithValue("@purpose", TextBoxwhy1.Text);
                    cmd.Parameters.AddWithValue("@water", Drpwater1.SelectedItem.Text);
                    cmd.Parameters.AddWithValue("@people", Drpman1.SelectedItem.Text);
                    cmd.Parameters.AddWithValue("@PS", TextBoxPS1.Text);

                    string message = "";

                    try
                    {
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        message = "預約成功";
                    }
                    catch (Exception ex)
                    {
                        message = ex.Message;
                        string strJS = "alert('" + message + "');location.href = ('Conferenceroom.aspx');";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true);
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strJS, true);
                    }
                    finally
                    {
                        conn.Close();
                        string strJS = "alert('" + message + "');location.href = ('Conferenceroom.aspx');";
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true);
                        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strJS, true);
                    }
                }
            }
        }
示例#6
0
        protected void pzbtn_Click(object sender, EventArgs e)
        {
            string   datest1;
            string   datest2;
            DateTime date1;
            DateTime date2;

            datest1 = pztex0.Text + " " + pzdrp2.SelectedItem.Text + ":" + pzdrp3.SelectedItem.Text;
            datest2 = pztex0.Text + " " + pzdrp4.SelectedItem.Text + ":" + pzdrp5.SelectedItem.Text;
            date1   = DateTime.Parse(datest1);
            date2   = DateTime.Parse(datest2);

            int plusday = 1;

            int.TryParse(pztex1.Text, out plusday);
            int count = 1;

            int.TryParse(pztex2.Text, out count);

            //判斷是否有人預約功能暫時保留
            //for (int i = 0; i < count; i++)
            //{
            //    //判斷是否已有人預約
            //    string strConn = ConfigurationManager.ConnectionStrings["MENU"].ConnectionString;
            //    using (SqlConnection conn = new SqlConnection(strConn))
            //    {

            //        //String QQ = "select * from TB_Carrent where (startrent BETWEEN '" + (datestart.Text + " " + DropDownList2.SelectedItem.Text + ":" + DropDownList3.SelectedItem.Text) + "' AND  '" + (dateend.Text + " " + DropDownList4.SelectedItem.Text + ":" + DropDownList5.SelectedItem.Text) + "') or (endrent BETWEEN  '" + (datestart.Text + " " + DropDownList2.SelectedItem.Text + ":" + DropDownList3.SelectedItem.Text) + "' AND  '" + (dateend.Text + " " + DropDownList4.SelectedItem.Text + ":" + DropDownList5.SelectedItem.Text) + "') and (car_no='" + DropDownList1.SelectedValue + "')";
            //        String QQ = "select * from TB_Conference where (((starttime BETWEEN '" + datest1 + "' AND  '" + datest2 + "') and(starttime <>'" + datest2 + "')) or ((endtime BETWEEN  '" + datest1 + "' AND  '" + datest2 + "')and(endtime <>'" + datest1 + "')) or (starttime < '" + datest1 + "' AND endtime> '" + datest2 + "')) and (Roomid='" + DropDownList1.SelectedValue + "')";

            //        SqlDataAdapter da = new SqlDataAdapter(QQ, conn);
            //        DataSet ds = new DataSet();
            //        da.Fill(ds);
            //        if (ds.Tables[0].Rows.Count != 0)
            //        {
            //            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            //            {
            //                conn.Close();
            //                string strJS = "alert('此時段已有人預約');";
            //                //Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true);
            //                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strJS, true);
            //                return;
            //            }
            //        }

            //    }
            //}



            //取得申請者姓名
            JuicDao dao      = new JuicDao("MENU");
            var     name     = dao.GetUser(Page.User.Identity.Name.ToString());
            string  username = "******";

            if (name.Rows.Count > 0)
            {
                username = name.Rows[0]["username"].ToString();
            }

            string strConn = ConfigurationManager.ConnectionStrings["MENU"].ConnectionString;

            for (int i = 0; i < count; i++)
            {
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    string strCmd = "Insert into TB_Conference(Roomid,Roomname,rentdate,starttime,endtime,userid,username,purpose,water,people,PS)values(@Roomid,@Roomname,@rentdate,@starttime,@endtime,@userid,@username,@purpose,@water,@people,@PS)";
                    using (SqlCommand cmd = new SqlCommand(strCmd, conn))
                    {
                        cmd.Parameters.AddWithValue("@Roomid", pzdrp1.SelectedValue);
                        cmd.Parameters.AddWithValue("@Roomname", pzdrp1.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@rentdate", date1.AddDays(plusday * i).Date);
                        cmd.Parameters.AddWithValue("@starttime", date1.AddDays(plusday * i));
                        cmd.Parameters.AddWithValue("@endtime", date2.AddDays(plusday * i));
                        cmd.Parameters.AddWithValue("@userid", User.Identity.Name.ToString());
                        cmd.Parameters.AddWithValue("@username", username);
                        cmd.Parameters.AddWithValue("@purpose", pztex3.Text);
                        cmd.Parameters.AddWithValue("@water", pzdrp6.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@people", pzdrp7.SelectedItem.Text);
                        cmd.Parameters.AddWithValue("@PS", pztex4.Text);

                        string message = "";

                        try
                        {
                            conn.Open();
                            cmd.ExecuteNonQuery();
                            message = "預約成功";
                        }
                        catch (Exception ex)
                        {
                            message = ex.Message;
                            string strJS = "alert('" + message + "');location.href = ('Conferenceroom.aspx');";
                            //Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true);
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strJS, true);
                        }
                        finally
                        {
                            conn.Close();
                            string strJS = "alert('" + message + "');location.href = ('Conferenceroom.aspx');";
                            //Page.ClientScript.RegisterStartupScript(this.GetType(), "", strJS, true);
                            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "", strJS, true);
                        }
                    }
                }
            }
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (HttpContext.Current.User.Identity.IsAuthenticated == false)
            //{
            //    Response.Redirect("~/Login.aspx");
            //}

            //MenuItem menuItem2 = new MenuItem
            //{


            //    Value = "123",
            //    Text = "公告",
            //    NavigateUrl = "~/Pages/JuicWMS2.aspx",

            //};
            //Menu2.Items.Clear();
            //Menu2.Items.Add(menuItem2);



            if (!this.IsPostBack)
            {
                JuicDao dao = new JuicDao("MENU");
                try
                {
                    var name = dao.GetUser(Page.User.Identity.Name.ToString());
                    if (name.Rows.Count > 0)
                    {
                        Label1.Text = "目前使用者:" + name.Rows[0]["username"].ToString();
                    }
                    else
                    {
                        Label1.Text = "訪客可用guest/1234登入";
                    }



                    //DataTable dt = dao.GetMenus(0);
                    //以下為方便自己使用˙ˇ˙
                    if (Page.User.Identity.Name.ToString() == "04779" || Page.User.Identity.Name.ToString() == "4779")
                    {
                        DataTable dt = dao.GetMenus(0);
                        PopulateMenu(dt, 0, null);
                    }
                    //else if(Page.User.Identity.Name.ToString() == "04761" || Page.User.Identity.Name.ToString() == "09487")
                    //{


                    //DataTable dt = dao.GetMenusbycontrol(0,Page.User.Identity.Name.ToString());
                    //PopulateMenu(dt, 0, null);
                    //}
                    else
                    {
                        //判斷ID是否存在
                        string strConn1 = ConfigurationManager.ConnectionStrings["MENU"].ConnectionString;
                        using (SqlConnection conn = new SqlConnection(strConn1))
                        {
                            String QQ = "select userid from TB_MenusControl where userid='" + Page.User.Identity.Name.ToString() + "'";

                            SqlDataAdapter da = new SqlDataAdapter(QQ, conn);
                            DataSet        ds = new DataSet();
                            da.Fill(ds);
                            if (ds.Tables[0].Rows.Count != 0)
                            {
                                DataTable dt = dao.GetMenusbycontrol(0, Page.User.Identity.Name.ToString());
                                PopulateMenu(dt, 0, null);
                            }
                            else
                            {
                                guestbool = true;
                                DataTable dt = dao.GetMenusbycontrol(0, guest);
                                PopulateMenu(dt, 0, null);
                            }
                            ds.Clear();
                        }
                    }
                }
                finally
                {
                    dao = null;
                }
            }
        }