private void btnInsert_Click(object sender, EventArgs e)
        {
            u.Username         = txtUsername.Text;
            u.Password         = txtPassword.Text;
            u.FirstName        = txtFirstName.Text;
            u.MiddleName       = txtMiddleName.Text;
            u.LastName         = txtLastName.Text;
            u.Address          = txtAddress.Text;
            u.Email            = txtEmail.Text;
            u.Birthdate        = dtpBirthdate.Value;
            u.SecurityQuestion = drpSecurityQuestion.Text;
            u.SecurityAnswer   = txtSecurityAnswer.Text;
            u.ID = txtID.Text;

            if (u.IncompleteUserData() == 1)
            {
                MessageBox.Show("Please fill all boxes!");
            }
            else if (u.EmailError() == 1)
            {
                MessageBox.Show(u.InvalidEmail());
            }
            else
            {
                u.UserInsert();
                rdoAdmin.Checked = true;
                View();
                Clear();
            }
        }
Beispiel #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            UserLibrary u      = new UserLibrary();
            int         Upload = 0;

            foreach (DataGridViewRow row in dgvUserUpload.Rows)
            {
                u.GENID = u.UserID();

                for (int i = 0; i < row.Cells.Count; i++)
                {
                    if (row.Cells[i].Value == null || row.Cells[i].Value == DBNull.Value || String.IsNullOrWhiteSpace(row.Cells[i].Value.ToString()))
                    {
                    }
                    else
                    {
                        if (Convert.ToInt32(row.Cells[5].Value) == 110)
                        {
                            u.ID = "AD-" + (u.UserID() + 1).ToString().PadLeft(5, '0');
                        }
                        else if (Convert.ToInt32(row.Cells[5].Value) == 111)
                        {
                            u.ID = "TR-" + (u.UserID() + 1).ToString().PadLeft(5, '0');
                        }
                        else if (Convert.ToInt32(row.Cells[5].Value) == 112)
                        {
                            u.ID = "ST-" + (u.UserID() + 1).ToString().PadLeft(5, '0');
                        }

                        u.Username      = row.Cells[0].Value.ToString();
                        u.Password      = "******";
                        u.FirstName     = row.Cells[1].Value.ToString();
                        u.MiddleName    = row.Cells[2].Value.ToString();
                        u.LastName      = row.Cells[3].Value.ToString();
                        u.ContactNumber = row.Cells[4].Value.ToString();
                        u.Usertype      = Convert.ToInt32(row.Cells[5].Value);

                        Upload = 1;
                    }
                }

                if (Upload == 1)
                {
                    u.UserInsert();
                    Upload = 0;
                }
            }
        }