Esempio n. 1
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (name_.Enabled != true)
            {
                name_.Enabled       = true;
                gender.Enabled      = true;
                contactno.Enabled   = true;
                dateofbirth.Enabled = true;
                comboBox1BG.Enabled = true;
                CNIC.Enabled        = true;
            }
            else if (name_.Enabled == true)
            {
                name_.Enabled       = false;
                gender.Enabled      = false;
                contactno.Enabled   = false;
                dateofbirth.Enabled = false;
                comboBox1BG.Enabled = false;
                CNIC.Enabled        = false;

                if (name_.Text == String.Empty | userID.Text == String.Empty | contactno.Text == String.Empty | dateofbirth.Text == String.Empty | gender.Text == String.Empty | comboBox1BG.Text == String.Empty | CNIC.Text == String.Empty)
                {
                    MessageBox.Show("Fill All Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                try
                {
                    if (name_.Text != String.Empty && userID.Text != String.Empty && contactno.Text != String.Empty && dateofbirth.Text != String.Empty && gender.Text != String.Empty && comboBox1BG.Text != String.Empty && CNIC.Text != String.Empty)
                    {
                        try
                        {
                            signup     data = new signup(name_.Text, userID.Text, "", gender.Text, contactno.Text, dateofbirth.Text);
                            SqlCommand scmd = new SqlCommand("update Employee set E_name='" + data.name + "',E_username='******',Gender='" + data.gender + "',contactNo='" + data.contactNo + "',Blood_Group='" + comboBox1BG.Text + "',DOB='" + data.DOB + "',CNIC='" + CNIC.Text + "' where E_id='" + int.Parse(textBoxID.Text) + "'", database.con);
                            database.con.Open();
                            int o = scmd.ExecuteNonQuery();
                            MessageBox.Show("Account Updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            database.con.Close();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        finally
                        {
                            database.con.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    database.con.Close();
                }
            }
        }
Esempio n. 2
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (userID.Text.Contains(" ") || userPASS.Text.Contains(" "))
     {
         errorProvider1.SetError(userID, "No spaces");
         errorProvider1.SetError(userPASS, "No spaces");
     }
     else
     {
         errorProvider1.Clear();
         if (name_.Text == String.Empty | userID.Text == String.Empty | userPASS.Text == String.Empty | contactno.Text == String.Empty | dateofbirth.Text == String.Empty | gender.Text == String.Empty | comboBox1BG.Text == String.Empty | CNIC.Text == String.Empty | type_.Text == String.Empty)
         {
             MessageBox.Show("Fill All Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         try
         {
             if (name_.Text != String.Empty && userID.Text != String.Empty && userPASS.Text != String.Empty && contactno.Text != String.Empty && dateofbirth.Text != String.Empty && gender.Text != String.Empty && comboBox1BG.Text != String.Empty && CNIC.Text != String.Empty && type_.Text != String.Empty)
             {
                 try
                 {
                     signup     data = new signup(name_.Text, userID.Text, userPASS.Text, gender.Text, contactno.Text, dateofbirth.Text);
                     SqlCommand scmd = new SqlCommand("update Employee set E_name='" + data.name + "',E_username='******',E_password='******',Gender='" + data.gender + "',contactNo='" + data.contactNo + "',Blood_Group='" + comboBox1BG.Text + "',DOB='" + data.DOB + "',CNIC='" + CNIC.Text + "',Type='" + type_.Text + "' where E_id='" + listBox1.SelectedItem + "'", database.con);
                     database.con.Open();
                     int o = scmd.ExecuteNonQuery();
                     MessageBox.Show("Account Updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                     database.con.Close();
                     name_.Text       = "";
                     userID.Text      = "";
                     userPASS.Text    = "";
                     gender.Text      = "";
                     contactno.Text   = "";
                     dateofbirth.Text = "";
                     comboBox1BG.Text = "";
                     CNIC.Text        = "";
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 finally
                 {
                     database.con.Close();
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         finally
         {
             database.con.Close(); listboxdata();
         }
     }
 }
Esempio n. 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (userID.Text.Contains(" ") || userPASS.Text.Contains(" "))
     {
         errorProvider1.SetError(userID, "No spaces");
         errorProvider1.SetError(userPASS, "No spaces");
     }
     else
     {
         if (name_.Text == String.Empty | userID.Text == String.Empty | userPASS.Text == String.Empty | contactno.Text == String.Empty | dateofbirth.Text == String.Empty | gender.Text == String.Empty | comboBox1BG.Text == String.Empty | CNIC.Text == String.Empty | type_.Text == String.Empty)
         {
             MessageBox.Show("Fill All Fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         try
         {
             if (name_.Text != String.Empty && userID.Text != String.Empty && userPASS.Text != String.Empty && contactno.Text != String.Empty && dateofbirth.Text != String.Empty && gender.Text != String.Empty && comboBox1BG.Text != String.Empty && CNIC.Text != String.Empty && type_.Text != String.Empty)
             {
                 database.con.Open();
                 SqlDataAdapter sda = new SqlDataAdapter("Select * From Employee where E_Username ='******'", database.con);
                 DataTable      dt  = new DataTable();
                 sda.Fill(dt);
                 if (dt.Rows.Count == 1)
                 {
                     MessageBox.Show("Username Already Taken", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     database.con.Close();
                 }
                 else
                 {
                     try
                     {
                         signup     data = new signup(name_.Text, userID.Text, userPASS.Text, gender.Text, contactno.Text, dateofbirth.Text);
                         SqlCommand scmd = new SqlCommand("insert into Employee values('" + data.name + "','" + data.username + "','" + data.password + "','" + data.gender + "','" + data.contactNo + "','" + comboBox1BG.Text + "','" + data.DOB + "','" + CNIC.Text + "','" + type_.Text + "')", database.con);
                         int        o    = scmd.ExecuteNonQuery();
                         MessageBox.Show("Sign Up Process Complete", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                         database.con.Close();
                         name_.Text       = "";
                         userID.Text      = "";
                         userPASS.Text    = "";
                         gender.Text      = "";
                         contactno.Text   = "";
                         dateofbirth.Text = "";
                         comboBox1BG.Text = "";
                         CNIC.Text        = "";
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                     finally
                     {
                         database.con.Close();
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         finally
         {
             database.con.Close(); listboxdata();
         }
     }
 }