Beispiel #1
0
 private void fillGrid(DataSet ds)
 {
     GridView_All.DataSource = ds.Tables[0];
     GridView_All.DataBind();
 }
Beispiel #2
0
        private void ShowCalender() //顯示行事曆
        {
            try
            {
                Session["PickDate"] = TextBox_DatePick.Text; //取得目前日期
                string[] PickDate = Session["PickDate"].ToString().Split('-');

                #region 顯示日期

                Session["Days"] = 0;

                int days = GetDaysInMonth(Convert.ToInt32(PickDate[1]), Convert.ToInt32(PickDate[0])); //依照天數創建表格

                DataTable dt = new DataTable();
                DataRow   drow;
                //DataColumn dcol1 = new DataColumn("Column1", typeof(string));
                //dt.Columns.Add(dcol1);

                for (int i = 1; i <= days; i++)
                {
                    drow = dt.NewRow();
                    dt.Rows.Add(drow);
                }

                #endregion

                DataSet CalenderDs = new DataSet();

                string Tsql = "";

                if (Session["PPermission"].ToString() == "1" || Session["SPermission"].ToString() == "1")
                {
                    for (int i = 1; i <= days; i++)
                    {
                        Tsql += "SELECT ProjectID, MissionID, MType, Creator, Title, Description, StartDate AS StartDate, EndDate, CreatDate, ResponsibleName, Complete, CompleteDate FROM PMMission WHERE (ProjectID = '" + DropDownList_Project.SelectedValue.ToString() + "') AND (DATEPART(MM, StartDate) = '" + PickDate[1] + "') AND (DATEPART(yyyy, StartDate) = '" + PickDate[0] + "') AND (DATEPART(dd, StartDate) = '" + i + "') AND (Alive = '1');";
                    }
                }
                else
                {
                    #region 取得使用者擁有的任務代號

                    string  LTsql         = "SELECT MissionID FROM PMMMember WHERE (ProjectID = '" + DropDownList_Project.SelectedValue.ToString() + "') AND (UserID = '" + Session["UserID"].ToString() + "') AND (Alive = '1') ORDER BY MissionID";
                    DataSet MMerberList   = SS.GetSqlTable(LTsql);
                    string  UserMissionID = "";

                    if (MMerberList.Tables[0].Rows.Count > 0)
                    {
                        UserMissionID = "AND (MissionID = '" + MMerberList.Tables[0].Rows[0]["MissionID"].ToString() + "'";

                        for (int i = 1; i < MMerberList.Tables[0].Rows.Count; i++)
                        {
                            UserMissionID += " OR MissionID = '" + MMerberList.Tables[0].Rows[i]["MissionID"].ToString() + "'";
                        }

                        UserMissionID += ")";

                        for (int i = 1; i <= days; i++)
                        {
                            Tsql += "SELECT ProjectID, MissionID, MType, Creator, Title, Description, StartDate AS StartDate, EndDate, CreatDate, ResponsibleName, Complete, CompleteDate FROM PMMission WHERE (ProjectID = '" + DropDownList_Project.SelectedValue.ToString() + "') AND (DATEPART(MM, StartDate) = '" + PickDate[1] + "') AND (DATEPART(yyyy, StartDate) = '" + PickDate[0] + "') AND (DATEPART(dd, StartDate) = '" + i + "') AND (Alive = '1')" + UserMissionID + ";";
                        }
                    }

                    #endregion
                }

                CalenderDs            = SS.GetSqlTable(Tsql);
                Session["CalenderDs"] = CalenderDs;

                GridView_All.DataSource = dt;
                GridView_All.DataBind();
            }
            catch
            {
                Relogin(1, 0);
            }
        }