protected void btnMove_Click(object sender, EventArgs e) { if (Page.IsValid) { string strID = string.Empty; if (Request.QueryString["id"] != null) { strID = Request.QueryString["id"].ToString(); } if (Request.QueryString["did"] != null) { strID = Request.QueryString["did"].ToString(); } if (strID.Length > 0) { dsRequestorsTableAdapters.licenseeTableTableAdapter licenseeTableTA = new dsRequestorsTableAdapters.licenseeTableTableAdapter(); dsRequestors.licenseeTableDataTable licenseeTableDT = new dsRequestors.licenseeTableDataTable(); licenseeTableDT = licenseeTableTA.GetLicenseesByRequestorTable(Convert.ToInt32(strID)); string tmp = string.Empty; foreach (DataRow dr in licenseeTableDT) { if (dr["RequestorID"] != DBNull.Value) { dr["RequestorID"] = Convert.ToInt32(ddlMLBContacts.SelectedValue); //tmp += dr["id"].ToString() + ":"; } //tmp += dr["RequestorID"].ToString() + ":"; //if (cblLicensees.Items.FindByValue(dr["id"].ToString()).Selected) //{ // dr["RequestorID"] = Convert.ToInt32(strID); //} //else //{ // dr["RequestorID"] = DBNull.Value; //} } //lblMoveDone.Text = tmp; licenseeTableTA.Update(licenseeTableDT); //Display the requester name dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); requestorsDT = requestorsTA.GetRequestorByID(Convert.ToInt32(strID)); string ln = ddlMLBContacts.SelectedItem.Text.Substring(0, ddlMLBContacts.SelectedItem.Text.IndexOf(" ") - 1); string fn = ddlMLBContacts.SelectedItem.Text.Substring(ddlMLBContacts.SelectedItem.Text.IndexOf(" ") + 1); lblMoveDone.Text = requestorsDT[0]["FirstName"].ToString() + " " + requestorsDT[0]["LastName"].ToString() + "'s ALL users been assigned to <br>'" + fn + " " + ln + "' SUCCESSFULLY!"; // Response.Redirect("RequesterMgr.aspx?id=" + ddlMLBContacts.SelectedValue); PopulateCblLicensees(); } } }
protected void btnContinue1_Click(object sender, EventArgs e) { if (Page.IsValid) { try { dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); requestorsDT = requestorsTA.GetAllRequestors(); dsRequestors.requestorsRow requestorR = requestorsDT.NewrequestorsRow(); requestorR.firstname = tbFirstName.Text; requestorR.lastname = tbLastName.Text; requestorR.email = tbEmail.Text; if (cbLicenseeA.Checked) { requestorR.moreinfo = ":LicenseeA MLB Contact"; requestorR.displayorder = 1; } else { requestorR.moreinfo = " "; requestorR.displayorder = 1; } requestorsDT.Rows.Add(requestorR); requestorsDT.RowChanged += new DataRowChangeEventHandler(Row_Changed); requestorsTA.Update(requestorsDT); Response.Redirect("RequesterMgr.aspx?newid=" + iPkey); } catch (ConstraintException ce) { if (ce.Message.IndexOf("firstname, lastname") >= 0) { lblErr.Text = "'" + tbFirstName.Text + " " + tbLastName.Text + "' is already registered."; lblErr.Visible = true; } else { throw ce; } } } }
protected void btnContinue1_Click(object sender, EventArgs e) { if (Page.IsValid) { try { dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); requestorsDT = requestorsTA.GetRequestorByID(Convert.ToInt32(Request.QueryString["id"].ToString())); requestorsDT[0]["FirstName"] = tbFirstName.Text; requestorsDT[0]["LastName"] = tbLastName.Text; requestorsDT[0]["Email"] = tbEmail.Text; if (cbLicenseeA.Checked) { requestorsDT[0]["MoreInfo"] = ":LicenseeA MLB Contact"; requestorsDT[0]["DisplayOrder"] = 1; } else { requestorsDT[0]["MoreInfo"] = " "; requestorsDT[0]["DisplayOrder"] = 1; } requestorsDT.RowChanged += new DataRowChangeEventHandler(Row_Changed); requestorsTA.Update(requestorsDT); Response.Redirect("RequesterMgr.aspx?newid=" + iPkey); } catch (Exception ex) { if (ex.Message.IndexOf("PK_requestors") >= 0) { lblErr.Text = "'" + tbFirstName.Text + " " + tbLastName.Text + "' is already registered."; lblErr.Visible = true; } else { throw ex; } } } }
protected void Page_Load(object sender, EventArgs e) { if ((Request.QueryString["fn"] != null) && (Request.QueryString["ln"] != null)) { string strFN = Server.UrlDecode(Request.QueryString["fn"].ToString()); string strLN = Server.UrlDecode(Request.QueryString["ln"].ToString()); try { dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); requestorsDT = requestorsTA.GetAllRequestors(); dsRequestors.requestorsRow requestorsR = requestorsDT.FindByfirstnamelastname(strFN, strLN); dsRequestorsTableAdapters.legacyusersTableAdapter legacyusersTA = new dsRequestorsTableAdapters.legacyusersTableAdapter(); dsRequestors.legacyusersDataTable legacyusersDT = new dsRequestors.legacyusersDataTable(); legacyusersDT = legacyusersTA.GetDataByRequestorID(requestorsR.id); foreach (DataRow row in legacyusersDT.Rows) { row["RequestorID"] = DBNull.Value; } legacyusersTA.Update(legacyusersDT); requestorsR.Delete(); requestorsTA.Update(requestorsDT); Session["name"] = strFN + " " + strLN; Response.Redirect("RequesterMgr.aspx", true); } catch (SqlException se) { if (se.Message.IndexOf("FK_licensee_requestors") >= 0) { Response.Redirect("RequesterMgr.aspx?did=" + Request.QueryString["id"].ToString(), true); } else { throw se; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["id"] != null) { dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); requestorsDT = requestorsTA.GetRequestorByID(Convert.ToInt32(Request.QueryString["id"].ToString())); tbFirstName.Text = requestorsDT[0]["FirstName"].ToString(); tbLastName.Text = requestorsDT[0]["LastName"].ToString(); tbEmail.Text = requestorsDT[0]["Email"].ToString(); if (requestorsDT[0]["MoreInfo"].ToString() != " ") { cbLicenseeA.Checked = true; } } else { Response.Redirect("./"); } } }
protected void btnSave_Click(object sender, EventArgs e) { string strID = string.Empty; if (Request.QueryString["id"] != null) { strID = Request.QueryString["id"].ToString(); } if (Request.QueryString["did"] != null) { strID = Request.QueryString["did"].ToString(); } if (strID.Length > 0) { dsRequestorsTableAdapters.licenseeTableTableAdapter licenseeTableTA = new dsRequestorsTableAdapters.licenseeTableTableAdapter(); dsRequestors.licenseeTableDataTable licenseeTableDT = new dsRequestors.licenseeTableDataTable(); licenseeTableDT = licenseeTableTA.GetLicenseesByRequestorTable(Convert.ToInt32(strID)); foreach (DataRow dr in licenseeTableDT) { if (cblLicensees.Items.FindByValue(dr["id"].ToString()).Selected) { dr["RequestorID"] = Convert.ToInt32(strID); } else { dr["RequestorID"] = DBNull.Value; } } licenseeTableTA.Update(licenseeTableDT); /* * dsRequestorsTableAdapters.licenseeTableAdapter licenseeTA = new dsRequestorsTableAdapters.licenseeTableAdapter(); * dsRequestors.licenseeDataTable licenseeDT = new dsRequestors.licenseeDataTable(); * licenseeDT = licenseeTA.GetLicenseesByRequestor(Convert.ToInt32(Request.QueryString["id"].ToString())); * foreach (DataRow dr in licenseeDT) * { * if (cblLicensees.Items.FindByValue(dr["ID"].ToString()).Selected) * { * dr["RequestorID"] = Convert.ToInt32(Request.QueryString["id"].ToString()); * * } * * * * } * */ //Display the requester name dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); requestorsDT = requestorsTA.GetRequestorByID(Convert.ToInt32(strID)); lblDone.Text = requestorsDT[0]["FirstName"].ToString() + " " + requestorsDT[0]["LastName"].ToString() + "'s user list has been updated SUCCESSFULLY!"; ddlMLBContacts.Enabled = false; btnMove.Enabled = false; lblDone.Visible = true; pnlEdit.Visible = true; pnlUsers.Visible = false; } else { Response.Redirect("RequesterMgr.aspx"); } }
protected void PopulateCblLicensees() { dsRequestorsTableAdapters.licenseeTableAdapter licenseeTA = new dsRequestorsTableAdapters.licenseeTableAdapter(); dsRequestors.licenseeDataTable licenseeDT = new dsRequestors.licenseeDataTable(); if (Request.QueryString["did"] != null)//Deleting with users still exsiting { licenseeDT = licenseeTA.GetLicenseesByRequestor(Convert.ToInt32(Request.QueryString["did"].ToString())); } else { licenseeDT = licenseeTA.GetLicenseesByRequestor(Convert.ToInt32(Request.QueryString["id"].ToString())); } //Display the requester name dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); if (Request.QueryString["did"] != null)//Deleting with users still exsiting { requestorsDT = requestorsTA.GetRequestorByID(Convert.ToInt32(Request.QueryString["did"].ToString())); } else { requestorsDT = requestorsTA.GetRequestorByID(Convert.ToInt32(Request.QueryString["id"].ToString())); } if (licenseeDT.Rows.Count > 0) { cblLicensees.DataSource = licenseeDT; cblLicensees.DataTextField = "siteuser"; cblLicensees.DataValueField = "id"; cblLicensees.DataBind(); //Pre-select the users under the corresponding requester bool bEnable = false; foreach (DataRow dr in licenseeDT) { if (dr["RequestorID"] != DBNull.Value) { cblLicensees.Items.FindByValue(dr["ID"].ToString()).Selected = true; lblDone.Text = "You may edit the individual users."; bEnable = true; } else { lblDone.Text = "You may choose the individual users. The users who are not assigned to an MLB contact are appended at the bottom of the list."; } } ddlMLBContacts.Enabled = bEnable; btnMove.Enabled = bEnable; lblMoveDone.Visible = bEnable; lblDone.Visible = true; pnlEdit.Visible = true; lblRequestor.Text = "<b>" + requestorsDT[0]["FirstName"].ToString() + " " + requestorsDT[0]["LastName"].ToString() + "</b>'s user list:"; if (Request.QueryString["did"] != null) { lblDone.Text = "There are still users that <b>'" + requestorsDT[0]["FirstName"].ToString() + " " + requestorsDT[0]["LastName"].ToString() + "'</b> is taking care of.<br><br>" + "Please remove or assign them to other MLB contacts first and then try to delete '" + requestorsDT[0]["FirstName"].ToString() + " " + requestorsDT[0]["LastName"].ToString() + "' again.<br><br>"; lblDone.Visible = true; pnlEdit.Visible = true; } pnlUsers.Visible = true; //ddlMLBContacts.Enabled = true; //btnMove.Enabled = true; lblDone.Visible = true; } else { ddlMLBContacts.Enabled = false; btnMove.Enabled = false; lblDone.Text = "There is no user to choose for <b>'" + requestorsDT[0]["FirstName"].ToString() + " " + requestorsDT[0]["LastName"].ToString() + "'</b>. All of them are under one of the MLB contacts.<br/><br/>You can get users from other MLB contacts or uncheck some of them to release. And then you can select them here."; lblDone.Visible = true; pnlEdit.Visible = true; pnlUsers.Visible = false; } }
public string NotifyPrimaryContact(string pID, string cID) { //TO DO: Use pID and cID to send email; //Get the user list after deleteion //List<user> users = GetUsersByCID(cID); //return users; dsUserTableAdapters.licenseeTableAdapter licenseeTA = new dsUserTableAdapters.licenseeTableAdapter(); dsUser.licenseeDataTable licenseeDT = new dsUser.licenseeDataTable(); licenseeDT = licenseeTA.GetUserByID(Convert.ToInt32(pID)); string pEmail = licenseeDT.Rows[0]["email"].ToString(); //string pEmail = "*****@*****.**"; //string mlbEmail = "*****@*****.**"; string pFirstName = licenseeDT.Rows[0]["FirstName"].ToString(); string pLastName = licenseeDT.Rows[0]["LastName"].ToString(); dsRequestorsTableAdapters.requestorsTableAdapter requestorsTA = new dsRequestorsTableAdapters.requestorsTableAdapter(); dsRequestors.requestorsDataTable requestorsDT = new dsRequestors.requestorsDataTable(); requestorsDT = requestorsTA.GetRequestorByID(Convert.ToInt32(licenseeDT.Rows[0]["RequestorID"].ToString())); string mlbEmail = requestorsDT.Rows[0]["Email"].ToString(); licenseeDT = licenseeTA.GetUsersByCID(Convert.ToInt32(cID)); StringBuilder sbMsg = new StringBuilder(); StringBuilder sbMsgPop = new StringBuilder(); sbMsg.Append("Dear " + pFirstName + " " + pLastName + ",<br><br>"); sbMsg.Append("As part of our ongoing security practices, this message provides a current active list of the MLBstyleguide.com user group that you oversee. Please review and confirm that all of the following users are in good standing. If the status has changed for any of the registered users, it is very important that you let your MLB representative know immediately so that they can be removed from the active user list.<br><br>"); //sbMsg.Append("Please confirm the following users are up-to-dated and let us know if anyone needs to be removed.<br><br>"); sbMsgPop.Append("The following users were emailed to '" + pFirstName + "' successfully!\n\n"); foreach (dsUser.licenseeRow r in licenseeDT.Rows) { sbMsg.Append(r["FirstName"].ToString() + " " + r["LastName"].ToString() + "<br>"); sbMsgPop.Append(r["FirstName"].ToString() + " " + r["LastName"].ToString() + "\n"); } sbMsg.Append("<br>Thank you for your cooperation.<br><br>Major League Baseball Properties"); string _FromName = "Major League Baseball"; string _FromEmail = "*****@*****.**"; string strSubject = "MLB Style Guide: The current user list"; SmtpClient smtpClient; MailMessage message; try { smtpClient = new SmtpClient(); smtpClient.Host = ConfigurationManager.AppSettings["SMTPServer"].ToString(); smtpClient.Port = 25; message = new MailMessage(); MailAddress fromAddress = new MailAddress(_FromEmail, _FromName); message.From = fromAddress; MailAddress toAddress = new MailAddress(pEmail); message.To.Clear(); message.To.Add(toAddress); MailAddress ccAddress = new MailAddress(mlbEmail); message.CC.Clear(); message.CC.Add(ccAddress); message.Subject = strSubject; message.IsBodyHtml = true; message.Body = sbMsg.ToString(); smtpClient.Send(message); } catch (Exception ex) { //throw ex; //iBadEmails++; //sbBadEmailList.Append("<a href=\"EditUser.aspx?id=" + strID + "\" target=\"_blank\">" + strRecepient + "</a><br/>"); } return(sbMsgPop.ToString()); }