Beispiel #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            plannerForm pf  = new plannerForm();
            SqlCommand  cmd = new SqlCommand("update [Wedding planner] set wed_planner_available_time= '" + updatee.Text + "' where wed_planner_id='" + id + "' ", cn);

            cn.Open();
            cmd.ExecuteNonQuery();
            MessageBox.Show("date has been updated ");
            cn.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection  cn = new SqlConnection("Data Source =DESKTOP-74I7G65\\SQLEXPRESS; Initial Catalog=Weddingguide;Integrated Security = True ");
            SqlDataAdapter da;
            DataTable      dt = new DataTable();

            if (comboBox1.Text == admin)
            {
                da = new SqlDataAdapter("Select* from Admin where admin_name ='" + textBox1.Text + "'and admin_pass = '******'", cn);
                da.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    adminForm f = new adminForm();
                    this.Hide();
                    f.Show();
                }
                else
                {
                    MessageBox.Show("Incorrect username and password ", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (comboBox1.Text == user)
            {
                da = new SqlDataAdapter("Select* from [User] where user_name ='" + textBox1.Text + "'and user_pass = '******'", cn);
                da.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    userForm f = new userForm(dt.Rows[0]["user_name"].ToString(), Convert.ToInt32(dt.Rows[0]["user_id"]));

                    this.Hide();
                    f.Show();
                }
                else
                {
                    MessageBox.Show("Incorrect username and password ", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (comboBox1.Text == WeddingP)
            {
                da = new SqlDataAdapter("Select* from [wedding planner] where wed_planner_name ='" + textBox1.Text + "'and wedding_planner_pass = '******'", cn);
                da.Fill(dt);
                if (dt.Rows.Count == 1)
                {
                    plannerForm f = new plannerForm(dt.Rows[0]["wed_planner_name"].ToString(), Convert.ToInt32(dt.Rows[0]["wed_planner_id"]));

                    this.Hide();
                    f.Show();
                }
                else
                {
                    MessageBox.Show("Incorrect username and password ", "Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }