コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            manager_window m = new manager_window();

            m.Show();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                conn.Open();
                string        query = "select username from user_account where username='******'";
                SqlCommand    comm  = new SqlCommand(query, conn);
                SqlDataReader rd    = comm.ExecuteReader();
                if (rd.HasRows == true)
                {
                    conn.Close();
                    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                    conn.Open();
                    string     q   = "delete from user_account where username='******'";
                    SqlCommand com = new SqlCommand(q, conn);
                    com.ExecuteNonQuery();

                    MessageBox.Show("login deleted");
                    this.Hide();
                    manager_window m = new manager_window();
                    m.Show();
                    con.Close();
                }
                else
                {
                    MessageBox.Show("no user exist with this username");
                }
            }
            else
            {
                MessageBox.Show("mention username");
            }
        }
コード例 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str1 = textBox2.Text.ToString();
            string str  = textBox5.Text.ToString();

            bool flag1 = true;

            for (int i = 0; i < str1.Length; i++)
            {
                if (str1[i] < '0' || str1[i] > '9')
                {
                    flag1 = false;
                }
            }
            bool flag = true;

            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] < '0' || str[i] > '9')
                {
                    flag1 = false;
                }
            }


            if (flag1 && flag && textBox1.Text != "" && comboBox2.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox5.Text != "" && Int32.Parse(textBox2.Text.ToString()) > 0 && Int32.Parse(textBox5.Text.ToString()) > 10)
            {
                SqlConnection co = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                co.Open();
                string        q1 = "select P_name from products where P_name='" + textBox1.Text + "'";
                SqlCommand    c  = new SqlCommand(q1, co);
                SqlDataReader rd = c.ExecuteReader();
                if (rd.HasRows != true)
                {
                    co.Close();



                    SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                    conn.Open();
                    string     query = "insert into products values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + comboBox2.Text + "','" + textBox5.Text + "')";
                    SqlCommand comm  = new SqlCommand(query, conn);
                    comm.ExecuteNonQuery();
                    MessageBox.Show("new food item successfully added");
                    this.Hide();
                    manager_window m = new manager_window();
                    m.Show();
                    conn.Close();
                }
                else
                {
                    MessageBox.Show("this product already exist");
                }
            }
            else
            {
                MessageBox.Show("invalid entries");
            }
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");

            conn.Open();
            string        query = "select status from user_account where username='******' and password='******'";
            SqlCommand    comm  = new SqlCommand(query, conn);
            SqlDataReader rd    = comm.ExecuteReader();

            if (rd.HasRows == true)
            {
                rd.Read();
                if (textBox1.Text == "ali123")
                {
                    this.Hide();
                    manager_window m = new manager_window();
                    m.Show();
                    conn.Close();
                }
                //else if (rd["status"].ToString() == "cashier")
                //else if (textBox1.Text.ToString() == "amir321")
                else
                {
                    this.Hide();
                    PBill m = new PBill();
                    m.Show();
                    conn.Close();
                }
            }
            else
            {
                MessageBox.Show("wrong id or password");
                this.Hide();
                login l = new login();
                l.Show();
                conn.Close();
            }
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox4.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && (textBox3.Text == "cashier"))
            {
                SqlConnection co = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                co.Open();
                string        q1 = "select username from user_account where username='******'";
                SqlCommand    c  = new SqlCommand(q1, co);
                SqlDataReader rd = c.ExecuteReader();

                if (rd.HasRows != true)
                {
                    co.Close();



                    SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                    conn.Open();
                    string     query = "insert into user_account values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "')";
                    SqlCommand comm  = new SqlCommand(query, conn);
                    comm.ExecuteNonQuery();
                    MessageBox.Show("login created");
                    this.Hide();
                    manager_window m = new manager_window();
                    m.Show();
                    conn.Close();
                }
                else
                {
                    MessageBox.Show("this username already exist");
                }
            }
            else
            {
                MessageBox.Show("invalid entries");
            }
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string str1 = textBox2.Text.ToString();

            bool flag1 = true;

            for (int i = 0; i < str1.Length; i++)
            {
                if (str1[i] < '0' || str1[i] > '9')
                {
                    flag1 = false;
                }
            }
            string str2 = textBox6.Text.ToString();

            bool flag = true;
            int  j    = 0;

            while (j < str2.Length)
            {
                if (str2[j] < '0' || str1[j] > '9')
                {
                    flag1 = false;
                }
                j++;
            }



            if (flag1 && flag && textBox1.Text != "" && textBox4.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox6.Text != "" && Int32.Parse(textBox2.Text.ToString()) > 0 && Int32.Parse(textBox6.Text.ToString()) > 10)
            {
                SqlConnection co = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                co.Open();
                string        q1 = "select P_name from products where P_name='" + textBox1.Text + "'";
                SqlCommand    c  = new SqlCommand(q1, co);
                SqlDataReader rd = c.ExecuteReader();
                if (rd.HasRows != true)
                {
                    co.Close();
                    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                    con.Open();
                    string     q   = "delete from products where P_name='" + textBox5.Text + "'";
                    SqlCommand com = new SqlCommand(q, con);
                    com.ExecuteNonQuery();
                    con.Close();



                    SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                    conn.Open();
                    string     query = "insert into products values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "')";
                    SqlCommand comm  = new SqlCommand(query, conn);
                    comm.ExecuteNonQuery();
                    MessageBox.Show(" item successfully updated");
                    this.Hide();
                    manager_window m = new manager_window();
                    m.Show();
                    conn.Close();
                    //SqlConnection con5 = new SqlConnection(@"Data Source=SHEIKH\SQLEXPRESS;Initial Catalog=data1;Integrated Security=True;Pooling=False");
                    //con5.Open();
                    //string q5 = "delete from sales where order_id>'" + 1 + "'";
                    //SqlCommand com5 = new SqlCommand(q5, con5);
                    //com5.ExecuteNonQuery();
                    //con5.Close();
                }
                else
                {
                    SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                    con.Open();
                    string     q   = "delete from products where P_name='" + textBox1.Text + "'";
                    SqlCommand com = new SqlCommand(q, con);
                    com.ExecuteNonQuery();
                    con.Close();
                    SqlConnection conn = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\M. Hammad Shahid\Documents\Visual Studio 2013\Projects\hotel_management\hotel_management\Database1.mdf;Integrated Security=True");
                    conn.Open();
                    string     query = "insert into products values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox6.Text + "')";
                    SqlCommand comm  = new SqlCommand(query, conn);
                    comm.ExecuteNonQuery();
                    MessageBox.Show("item successfully updated");
                    this.Hide();
                    manager_window m = new manager_window();
                    m.Show();
                    conn.Close();
                }
            }
            else
            {
                MessageBox.Show("invalid entries");
            }
        }