private void textBox11_TextChanged(object sender, EventArgs e)
 {
     if (RegExp.checkForEmail(textBox11.Text.ToString()))
     {
         label18.Text      = "Valid mail Id";
         label18.ForeColor = System.Drawing.Color.Green;
     }
     else
     {
         label18.Text      = "InValid mail Id";
         label18.ForeColor = System.Drawing.Color.Red;
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string ab, cd, ef, gh, ij, kl, mn, op, qr, st, uv, xy, mk;

                ab = textBox8.Text;
                cd = dateTimePicker1.Text;
                ef = comboBox1.Text;
                gh = textBox4.Text;
                ij = textBox5.Text;
                kl = textBox6.Text;
                mn = textBox10.Text;
                op = textBox9.Text;
                qr = dateTimePicker2.Text;
                st = textBox11.Text;
                uv = textBox13.Text;
                xy = textBox2.Text;
                mk = textBox1.Text;



                if ((ab == "") || (cd == "") || (ef == "") || (gh == "") || (ij == "") || (kl == "") || (mn == "") || (op == "") || (ab == "") || (qr == "") || (st == "") || (uv == "") || (xy == "") || (mk == ""))
                {
                    MessageBox.Show("please add the full details", "Warning");
                    label18.Text = string.Empty;
                }

                else if (RegExp.checkForEmail(textBox11.Text.ToString()))
                {
                    label18.Text = string.Empty;

                    StringBuilder            hash        = new StringBuilder();
                    MD5CryptoServiceProvider md5provider = new MD5CryptoServiceProvider();
                    byte[] bytes = md5provider.ComputeHash(new UTF8Encoding().GetBytes(xy));

                    for (int i = 0; i < bytes.Length; i++)
                    {
                        hash.Append(bytes[i].ToString("x2"));
                    }

                    con.Open();
                    sql = "insert into details values('" + ab + "','" + cd + "','" + ef + "','" + gh + "','" + ij + "','" + kl + "','" + mn + "','" + op + "','" + qr + "','" + st + "','" + uv + "','" + hash + "','" + mk + "')";
                    com = new SqlCommand(sql, con);
                    com.ExecuteNonQuery();

                    con.Close();

                    /*   con.Open();
                     * sql = "insert into detailsAdmin values('" + uv + "','" + hash + "','" + mk + "')";
                     * com = new SqlCommand(sql, con);
                     * com.ExecuteNonQuery();
                     *
                     * con.Close();*/


                    MessageBox.Show("successfully added", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    label18.Text         = string.Empty;
                    textBox8.Text        = "";
                    dateTimePicker1.Text = "";
                    comboBox1.Text       = "";
                    textBox4.Text        = "";
                    textBox5.Text        = "";
                    textBox6.Text        = "";
                    textBox10.Text       = "";
                    textBox9.Text        = "";
                    dateTimePicker2.Text = "";
                    textBox11.Text       = "";
                    textBox13.Text       = "";
                    textBox2.Text        = "";
                    textBox1.Text        = "";
                }
                else
                {
                    label18.Text         = string.Empty;
                    textBox8.Text        = "";
                    dateTimePicker1.Text = "";
                    comboBox1.Text       = "";
                    textBox4.Text        = "";
                    textBox5.Text        = "";
                    textBox6.Text        = "";
                    textBox10.Text       = "";
                    textBox9.Text        = "";
                    dateTimePicker2.Text = "";
                    textBox11.Text       = "";
                    textBox13.Text       = "";
                    textBox2.Text        = "";
                    textBox1.Text        = "";
                }
            }


            catch (Exception ex1)
            {
                MessageBox.Show("sorry there are something went wrong, please try again..!!");
            }
        }
Esempio n. 3
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                string ab, cd, ef, gh, ij, kl, mn, mk;

                ab = textBox1.Text;
                cd = textBox2.Text;
                ef = textBox3.Text;
                mn = textBox6.Text;
                gh = textBox4.Text;
                ij = textBox5.Text;
                kl = richTextBox1.Text;

                mk = textBox1.Text;
                if ((ab == "") || (cd == "") || (ef == "") || (ef == "") || (gh == "") || (ij == "") || (kl == ""))
                {
                    MessageBox.Show("please add the full details", "Warning");
                    label9.Text = string.Empty;
                }

                else if (RegExp.checkForEmail(textBox4.Text.ToString()))
                {
                    label9.Text = string.Empty;

                    con.Open();
                    sql = "insert into details_M values('" + ab + "','" + cd + "','" + ef + "','" + ef + "','" + gh + "','" + ij + "','" + kl + "')";
                    com = new SqlCommand(sql, con);
                    com.ExecuteNonQuery();

                    con.Close();
                    MessageBox.Show("successfully added", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information);



                    textBox4.Text     = "";
                    textBox5.Text     = "";
                    richTextBox1.Text = "";
                    textBox2.Text     = "";
                    textBox1.Text     = "";
                    textBox3.Text     = "";
                    textBox6.Text     = "";
                }

                else
                {
                    label9.Text       = string.Empty;
                    textBox4.Text     = "";
                    textBox5.Text     = "";
                    richTextBox1.Text = "";
                    textBox2.Text     = "";
                    textBox1.Text     = "";
                    textBox3.Text     = "";
                    textBox6.Text     = "";
                }
            }

            catch (Exception ex1)
            {
                MessageBox.Show("Sorry there are some went to wrong, please try again..!!");
            }
        }
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                if ((textBox5.Text == "") || (textBox7.Text == "") || (richTextBox1.Text == "") || (textBox4.Text == "") || (textBox5.Text == "") || (textBox2.Text == "") || (textBox6.Text == ""))
                {
                    label10.Text = string.Empty;
                    MessageBox.Show("Sorry,please add the full details", "Warning");
                }
                else if (RegExp.checkForEmail(textBox4.Text.ToString()))
                {
                    label10.Text = string.Empty;
                    con.Open();
                    String ab, cd, ef, gh, ij, kl, mn;

                    ab = textBox7.Text;
                    cd = textBox6.Text;
                    ef = textBox3.Text;
                    gh = textBox2.Text;
                    ij = textBox4.Text;
                    kl = textBox5.Text;
                    mn = richTextBox1.Text;


                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = con;
                    //string sql = "UPDATE details SET name = '" + ab + "', dob = '" + cd + "', gender = '" + ef + "', address = '" + gh + "', contactNum = '" + ij + "', age = '" + mn + "' , salary = '" + op + "' , joiningDate = '" + qr + "' , email = '" + st + "' , username = '******' , password = '******' , role = '" + mk + "' where NICno = '" +hs + "'";
                    string sql = "UPDATE sDetails SET supplierID = '" + ab + "',supplierName = '" + cd + "', companyName = '" + ef + "' ,licenceNo = '" + gh + "' ,contactNum = '" + ij + "', address = '" + mn + "' where supplierID = '" + comboBox1.Text + "'";
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                    //com = new OleDbCommand(sql,con);
                    // com.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show("Succesfully Updated", "Update");


                    textBox7.Text     = "";
                    textBox4.Text     = "";
                    textBox5.Text     = "";
                    textBox6.Text     = "";
                    textBox3.Text     = "";
                    textBox2.Text     = "";
                    richTextBox1.Text = "";
                }

                else
                {
                    label10.Text      = string.Empty;
                    textBox7.Text     = "";
                    textBox4.Text     = "";
                    textBox5.Text     = "";
                    textBox6.Text     = "";
                    textBox3.Text     = "";
                    textBox2.Text     = "";
                    richTextBox1.Text = "";
                }
            }
            catch (Exception ex1)
            {
                MessageBox.Show("Sorry there are some went to wrong, Please try again..!!");
            }
        }