protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { teacher = DataRepository.TeacherProvider.GetByAspnetMembershipUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()))[0]; isTeacherExist = true; } catch { //customer = DataRepository.CustomerProvider.GetByAspnetMembershipUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()))[0]; //customerprofile = DataRepository.CustomerProfileProvider.GetByCustomerId(customer.CustomerId)[0]; //isCustomerExist = true; } CustomerSite siteid; int x = 0; DataTable dt = new DataTable(); dt.Columns.Add("Count", typeof(int)); dt.Columns.Add("First Name", typeof(string)); dt.Columns.Add("Last Name", typeof(string)); dt.Columns.Add("Email Address", typeof(string)); dt.Columns.Add("Facility", typeof(string)); dt.Columns.Add("ExpirationDate", typeof(string)); dt.Columns.Add("TeacherType", typeof(int)); dt.Columns.Add("Tier", typeof(int)); try { //DataTable dtathlets = _sprintAthleteEdit.GetPrimarySecondaryAthlets_Coach(teacher.TeacherId); DataTable dtathlets = _sprintAthleteEdit.GetPrimaryAthletsCoach(teacher.TeacherId); DataTable dtathlets1 = _sprintAthleteEdit.GetSecondaryAthlets_Coach(teacher.TeacherId); #region [Primary Coach Data] if (dtathlets != null) { foreach (DataRow row in dtathlets.Rows) { DataRow r = dt.NewRow(); string userrolename = string.Empty; int customerid = Convert.ToInt32(row["CustomerId"]); AthleteSearched = DataRepository.CustomerProvider.GetByCustomerId(customerid); Guid MemGuid = new Guid(AthleteSearched.AspnetMembershipUserId.ToString()); MembershipUser user = Membership.GetUser(MemGuid); string[] userrole = Roles.GetRolesForUser(user.UserName); userrolename = userrole[0]; if (userrolename == "Athletes") { string custid = row["CustomerId"].ToString(); x++; r["First Name"] = row["FirstName"].ToString(); r["Last Name"] = row["LastName"].ToString(); r["Email Address"] = row["Email"].ToString(); DateTime date = new DateTime(); date = Convert.ToDateTime(row["MemberShipExpiration"]); string onlydate = date.Month + "/" + date.Day + "/" + date.Year; r["ExpirationDate"] = onlydate; // r["Status"] = row["MemberShipStatus"].ToString(); r["Count"] = x.ToString(); customerprofile = DataRepository.CustomerProfileProvider.GetByCustomerId(Convert.ToInt16(custid))[0]; siteid = DataRepository.CustomerSiteProvider.GetByCustomerSiteId(customerprofile.CustomerSite); r["Facility"] = siteid.SiteName.ToString(); if (!string.IsNullOrEmpty(customerprofile.InitialTeacher.ToString())) { r["Tier"] = customerprofile.InitialTeacher; } else { r["Tier"] = Convert.ToInt16(null); } r["TeacherType"] = 1; siteid = DataRepository.CustomerSiteProvider.GetByCustomerSiteId(customerprofile.CustomerSite); r["Facility"] = siteid.SiteName.ToString(); dt.Rows.Add(r); } } } #endregion [Primary Coach Data] #region [Secondary Coach Data] if (dtathlets1 != null) { foreach (DataRow row in dtathlets1.Rows) { DataRow r = dt.NewRow(); string userrolename1 = string.Empty; int customerid1 = Convert.ToInt32(row["CustomerId"]); AthleteSearched = DataRepository.CustomerProvider.GetByCustomerId(customerid1); Guid MemGuid1 = new Guid(AthleteSearched.AspnetMembershipUserId.ToString()); MembershipUser user1 = Membership.GetUser(MemGuid1); string[] userrole1 = Roles.GetRolesForUser(user1.UserName); userrolename1 = userrole1[0]; if (userrolename1 == "Athletes") { string custid = row["CustomerId"].ToString(); x++; r["First Name"] = row["FirstName"].ToString(); r["Last Name"] = row["LastName"].ToString(); r["Email Address"] = row["Email"].ToString(); DateTime date = new DateTime(); date = Convert.ToDateTime(row["MemberShipExpiration"]); string onlydate = date.Month + "/" + date.Day + "/" + date.Year; r["ExpirationDate"] = onlydate; //r["Status"] = row["MemberShipStatus"].ToString(); r["Count"] = x.ToString(); customerprofile = DataRepository.CustomerProfileProvider.GetByCustomerId(Convert.ToInt16(custid))[0]; if (!string.IsNullOrEmpty(customerprofile.InitialTeacher.ToString())) { r["Tier"] = customerprofile.InitialTeacher;//tier number of athlete } else { r["Tier"] = Convert.ToInt16(null); } r["TeacherType"] = 2; siteid = DataRepository.CustomerSiteProvider.GetByCustomerSiteId(customerprofile.CustomerSite); r["Facility"] = siteid.SiteName.ToString(); dt.Rows.Add(r); } } } #endregion [Secondary Coach Data] } catch { } DataTable AthleteData = dt; GridView1.DataSource = AthleteData; GridView1.DataBind(); } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { lblsubnittext.Visible = false; Image1.Visible = true; Label1.Visible = true; FileUpload1.Visible = true; Label5.Visible = true; Label6.Visible = true; Label7.Visible = true; Label4.Text = ""; Label2.Visible = true; Label3.Visible = true; int SelectedTeacherId = Convert.ToInt16(DropDownList1.SelectedValue); try { Teacher teach = DataRepository.TeacherProvider.GetByTeacherId(SelectedTeacherId); //LblWelcomeText.Visible = true; Image1.ImageUrl = "~" + teach.PicturePath; } catch { } try { teacher = DataRepository.TeacherProvider.GetByAspnetMembershipUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()))[0]; } catch { } CustomerSite siteid; int x = 0; DataTable dt = new DataTable(); dt.Columns.Add("First Name", typeof(string)); dt.Columns.Add("Last Name", typeof(string)); //dt.Columns.Add("TeacherType", typeof(int)); DataTable dt1 = new DataTable(); dt1.Columns.Add("First Name", typeof(string)); dt1.Columns.Add("Last Name", typeof(string)); //dt1.Columns.Add("TeacherType", typeof(int)); DataTable dtathlets1 = _sprintAthleteEdit.GetSecondaryAthlets_Coach(SelectedTeacherId); DataTable dtathlets = _sprintAthleteEdit.GetPrimaryAthletsCoach(SelectedTeacherId); try { #region [Primary Coach Data] if (dtathlets != null) { foreach (DataRow row in dtathlets.Rows) { DataRow r = dt.NewRow(); string userrolename = string.Empty; int customerid = Convert.ToInt32(row["CustomerId"]); AthleteSearched = DataRepository.CustomerProvider.GetByCustomerId(customerid); Guid MemGuid = new Guid(AthleteSearched.AspnetMembershipUserId.ToString()); MembershipUser user = Membership.GetUser(MemGuid); string[] userrole = Roles.GetRolesForUser(user.UserName); userrolename = userrole[0]; if (userrolename == "Athletes") { r["First Name"] = row["FirstName"].ToString(); r["Last Name"] = row["LastName"].ToString(); // r["TeacherType"] = 1; dt.Rows.Add(r); } } } #endregion [Primary Coach Data] } catch { } if (dt.Rows.Count > 0) { lblerror.Visible = false; } else { lblprimaryCoach.Visible = true; lblprimaryList.Visible = true; lblerror.Visible = true; } lblprimaryCoach.Visible = true; lblprimaryList.Visible = true; DataTable AthleteData = dt; GridView1.DataSource = AthleteData; GridView1.DataBind(); try { #region [Secondary Coach Data] if (dtathlets1 != null) { foreach (DataRow row in dtathlets1.Rows) { DataRow r = dt1.NewRow(); string userrolename1 = string.Empty; int customerid1 = Convert.ToInt32(row["CustomerId"]); AthleteSearched = DataRepository.CustomerProvider.GetByCustomerId(customerid1); Guid MemGuid1 = new Guid(AthleteSearched.AspnetMembershipUserId.ToString()); MembershipUser user1 = Membership.GetUser(MemGuid1); string[] userrole1 = Roles.GetRolesForUser(user1.UserName); userrolename1 = userrole1[0]; if (userrolename1 == "Athletes") { r["First Name"] = row["FirstName"].ToString(); r["Last Name"] = row["LastName"].ToString(); // r["TeacherType"] = 2; dt1.Rows.Add(r); } } } #endregion [Secondary Coach Data] lblSecondryCoach.Visible = true; lblSecondaryList.Visible = true; DataTable AthleteData1 = dt1; GridView2.DataSource = AthleteData1; GridView2.DataBind(); } catch { } if (dt1.Rows.Count > 0) { lblerror1.Visible = false; } else { lblSecondryCoach.Visible = true; lblSecondaryList.Visible = true; lblerror1.Visible = true; } }