示例#1
0
        private void back_Click(object sender, EventArgs e)
        {
            Labor l = new Labor();

            this.Hide();
            l.Show();
        }
示例#2
0
        private void next_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                if (textContact.Text.Length != 11)
                {
                    MessageBox.Show("Contact formation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    int    x = 0;
                    string s = textAge.Text;
                    x = Convert.ToInt32(s);
                    if (x < 18)
                    {
                        MessageBox.Show("Age must be 18+", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        SqlConnection conn = new SqlConnection(@"Server=.\SQLEXPRESS;Database=labormgt;Integrated Security=true");
                        conn.Open();
                        string query = "";
                        query = "INSERT INTO labor (Name,UserName,Contact,Age,Password) VALUES('" + textName.Text + "','" + textUserName.Text + "', '" + textContact.Text + "', '" + textAge.Text + "','" + textPassword.Text + "')";
                        SqlCommand cmd    = new SqlCommand(query, conn);
                        int        result = cmd.ExecuteNonQuery();
                        if (result > 0)
                        {
                            MessageBox.Show("Successfully Signed,Please LogIn", "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                            Labor l = new Labor();
                            this.Hide();
                            l.Show();
                        }
                        else
                        {
                            MessageBox.Show("Error!!!", "Message");
                        }
                        conn.Close();
                    }
                }
            }

            else
            {
                MessageBox.Show("Information Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
 private void ok_Click(object sender, EventArgs e)
 {
     if (adminTxt.Checked)
     {
         MessageBox.Show("Admin Selected");
         Admin a1 = new Admin();
         this.Hide();
         a1.Show();
     }
     if (managerTxt.Checked)
     {
         MessageBox.Show("Manager Selected");
         Manager m1 = new Manager();
         m1.Show();
         this.Hide();
     }
     if (laborTxt.Checked)
     {
         MessageBox.Show("Labor Selected");
         Labor l1 = new Labor();
         l1.Show();
         this.Hide();
     }
 }
示例#4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                if (textContact.Text.Length != 11)
                {
                    MessageBox.Show("Contact formation", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    System.Text.RegularExpressions.Regex rEMail = new System.Text.RegularExpressions.Regex(@"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$");

                    if (textEmail.Text.Length > 0)

                    {
                        if (!rEMail.IsMatch(textEmail.Text))

                        {
                            MessageBox.Show("E-Mail Formation Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            if (string.IsNullOrWhiteSpace(textPassword.Text))
                            {
                                textPassword.Text = Password;
                                SqlConnection conn = new SqlConnection(@"Server=.\SQLEXPRESS;Database=labormgt;Integrated Security=true");
                                conn.Open();
                                string query = "";
                                query = "Update labor SET Contact = '" + textContact.Text + "',City='" + textCity.Text + "',Email='" + textEmail.Text + "',Password='******' WHERE UserName = '******' AND Password='******'";

                                SqlCommand cmd    = new SqlCommand(query, conn);
                                int        result = cmd.ExecuteNonQuery();
                                if (result > 0)
                                {
                                    MessageBox.Show("Successfully Updated!!!Please LogIn Again", "Message");
                                    Labor l = new Labor();
                                    this.Hide();
                                    l.Show();
                                }
                                else
                                {
                                    MessageBox.Show("error!!!", "Message");
                                }
                                conn.Close();
                            }
                            else
                            {
                                SqlConnection conn = new SqlConnection(@"Server=.\SQLEXPRESS;Database=labormgt;Integrated Security=true");
                                conn.Open();
                                string query = "";
                                query = "Update labor SET Contact = '" + textContact.Text + "',City='" + textCity.Text + "',Email='" + textEmail.Text + "',Password='******' WHERE UserName = '******' AND Password='******'";

                                SqlCommand cmd    = new SqlCommand(query, conn);
                                int        result = cmd.ExecuteNonQuery();
                                if (result > 0)
                                {
                                    MessageBox.Show("Successfully Updated!!!Please LogIn Again", "Message");
                                    Labor l = new Labor();
                                    this.Hide();
                                    l.Show();
                                }
                                else
                                {
                                    MessageBox.Show("error!!!", "Message");
                                }
                                conn.Close();
                            }
                        }
                    }


                    else
                    {
                        MessageBox.Show("Information Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }