コード例 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
        
         hfschd.Value = getdt.getSchdID();
         getdt.setSchdID(null);
         hfID.Value = getdt.getID();
         getdt.setID(null);
         if (string.IsNullOrEmpty(hfschd.Value))
         {
             //ClientScript.RegisterStartupScript(typeof(Page), "closePage", "<script type='text/JavaScript'>window.close();</script>");
             Response.Redirect("~/UnauthorizedAccess.aspx");
         }
         else
         {
             BindQuestionQestions();                    
             DataTable dt = new DataTable();
             dt = getdt.getQuestions();                    
             if (dt.Rows.Count > 0)
             {
                 getData(dt);
                 toGetInfo tocheck = new toGetInfo();
                 tocheck.setStarted(true);
                 getdt.getQuestions().Clear();
             }
         }
     }
 }
コード例 #2
0
        protected void lnkbtnNewSurvey_Command(object sender, CommandEventArgs e)
        {
            toGetInfo getinfo = new toGetInfo();
            string schdid = e.CommandArgument.ToString();            
           
            string name = Page.User.Identity.Name;
            string userID = Membership.GetUser(name).ProviderUserKey.ToString();
            string sqlquerysiteID = " Select PD.Staff_ID, PD.SiteID From [ISBEPI_DEV].[dbo].[ProgramDirector] PD RIGHT JOIN " +
                                    "[ISBEPI_DEV].[dbo].Staff ST " +
                                    "ON PD.Staff_ID = ST.Staff_ID WHERE ST.UserId ='" + userID + "' ;";
            DataTable dt = DBHelper.GetDataTable(sqlquerysiteID);

            string sqlQueryGetSurveyStatus = "SELECT PD.Staff_ID, PD.Completed, PD.Schd_ID FROM  " +
                                                "[ISBEPI_DEV].[dbo].[Program_Director_Survey] PD WHERE PD.Schd_ID ='" + schdid + "'" +
                                                "AND PD.Staff_ID ='" + dt.Rows[0]["Staff_ID"].ToString() + "'";                                                
            DataTable dtgetStatus = DBHelper.GetDataTable(sqlQueryGetSurveyStatus);
            if (dtgetStatus.Rows.Count < 1)
            {
                //row = pd.Program_Director_Survey.NewRow();
                //row["Staff_ID"] = dt.Rows[0]["Staff_ID"].ToString();
                //row["Schd_ID"] = schdid;
                //row["StartedDate"] = DateTime.Now.ToShortDateString();
                //row["Completed"] = "Started";
                string sqlUpdate_NewRow = "INSERT INTO [ISBEPI_DEV].[dbo].[Program_Director_Survey] (Staff_ID, Schd_ID, StartedDate, Completed)"
                                         + " VALUES ('" + dt.Rows[0]["Staff_ID"].ToString() + "', '" + schdid + "', GETDATE(), 'Started');";
                int count = DBHelper.ExecuteSQL(sqlUpdate_NewRow);
                //pd.Program_Director_Survey.Rows.Add(row);
                //HVSurveyTableAdapters.Program_Director_SurveyTableAdapter PDSA = new HVSurveyTableAdapters.Program_Director_SurveyTableAdapter();
                //PDSA.Update(row);
                if (count > 0)
                {
                    toGetInfo setinfo = new toGetInfo();
                    setinfo.setSiteID(dt.Rows[0]["SiteID"].ToString());
                    Session["staffid"] = dt.Rows[0]["Staff_ID"].ToString();
                    setinfo.setSchdID(schdid);
                    setinfo.setStarted(false);
                    Response.Redirect("~/ProgramDirector/DirectorSurvey.aspx");
                }
                else
                {
                    Response.Redirect("~/UnauthorizedAccess.aspx");
                }
            }
            else
            {              
                toGetInfo setinfo = new toGetInfo();
                setinfo.setSiteID(dt.Rows[0]["SiteID"].ToString());
                Session["staffid"] = dt.Rows[0]["Staff_ID"].ToString();
                setinfo.setSchdID(schdid);
                setinfo.setStarted(true);
                Response.Redirect("~/ProgramDirector/DirectorSurvey.aspx");
            }
        }