コード例 #1
0
ファイル: Form1.cs プロジェクト: naricci/SE255
        // OVERLOADED CONSTRUCTOR - Meant to pull in existing data
        public Form1(Int32 intPerson_ID)
        {
            InitializeComponent();

            /*************************************************************
             * Extra-Credit:    Fill in the ComboBox    *****************/
            //FillPersons();
            /************************************************************/

            // Gather info about this one person and store it in a datareader
            Person        temp = new Person();
            SqlDataReader dr   = temp.FindOnePerson(intPerson_ID);

            /**
             * Use that info to fill out the form
             * Loop thru the records stored in the reader 1 record at a time
             * Note that since this is based on one person's ID, then we
             * should only have one record
             */
            while (dr.Read())
            {
                // Take the Name(s) from the DataReader and copy them
                // into the appropriate text fields
                txtFName.Text   = dr["FName"].ToString();
                txtMName.Text   = dr["MName"].ToString();
                txtLName.Text   = dr["LName"].ToString();
                txtStreet1.Text = dr["Street1"].ToString();
                txtStreet2.Text = dr["Street2"].ToString();
                txtCity.Text    = dr["City"].ToString();
                // Select the appropriate State for this person
                cmbState.SelectedItem = dr["State"].ToString();
                txtZipCode.Text       = dr["Zipcode"].ToString();
                txtCountry.Text       = dr["Country"].ToString();
                txtPhone.Text         = dr["Phone"].ToString();
                txtEmail.Text         = dr["Email"].ToString();
                // We added this one to store the ID in a new label
                lblPerson_ID.Text = dr["Person_ID"].ToString();

                /*
                 * bool blnFound = false;
                 * int intIndex = 0;
                 * while (blnFound == false)
                 * {
                 *  if (((ComboBoxItem)cmbWho.Items[intIndex]).Value == intPerson_ID)
                 *  {
                 *      blnFound = true;
                 *      cmbWho.SelectedIndex = intIndex;
                 *  }
                 *  intIndex++;
                 * }
                 */
            }
            chkEmployee.Visible   = false;
            chkEmployee.Checked   = false;
            lblEmployeeID.Visible = false;
            txtEmployeeID.Visible = false;
            lblHourlyRate.Visible = false;
            txtHourlyRate.Visible = false;
            btnSubmit.Visible     = false;
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: naricci/SE255
        // OVERLOADED CONSTRUCTOR - Meant to pull in existing data
        public Form1(Int32 intPerson_ID)
        {
            InitializeComponent();

            chkEmployee.Visible   = false;
            chkEmployee.Checked   = false;
            lblEmployeeID.Visible = false;
            txtEmployeeID.Visible = false;
            lblHourlyRate.Visible = false;
            txtHourlyRate.Visible = false;
            btnSubmit.Visible     = false;

            // Gather info about this one person and store it in a datareader
            Person        temp = new Person();
            SqlDataReader dr   = temp.FindOnePerson(intPerson_ID);

            /**
             * Use that info to fill out the form
             * Loop thru the records stored in the reader 1 record at a time
             * Note that since this is based on one person's ID, then we
             * should only have one record
             */
            while (dr.Read())
            {
                // Take the Name(s) from the DataReader and copy them
                // into the appropriate text fields
                txtFName.Text   = dr["FName"].ToString();
                txtMName.Text   = dr["MName"].ToString();
                txtLName.Text   = dr["LName"].ToString();
                txtStreet1.Text = dr["Street1"].ToString();
                txtStreet2.Text = dr["Street2"].ToString();
                txtCity.Text    = dr["City"].ToString();
                txtState.Text   = dr["State"].ToString();
                txtZipCode.Text = dr["ZipCode"].ToString();
                txtCountry.Text = dr["Country"].ToString();
                txtPhone.Text   = dr["Phone"].ToString();
                txtEmail.Text   = dr["Email"].ToString();
                // We added this one to store the ID in a new label
                lblPerson_ID.Text = dr["Person_ID"].ToString();
            }
        }