예제 #1
0
 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;
             }
         }
     }
 }
예제 #2
0
    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;
                }
            }
        }
    }