Example #1
0
        private void Login_Click(object sender, EventArgs e)
        {
            dbconnect dbms = new dbconnect();

            dbms.connect();
            OracleCommand cmd = new OracleCommand("SELECT COUNT(*) FROM EMP_LOGIN WHERE USERID= :p1 AND PASSWORD= :p2", dbms.con);

            cmd.Parameters.Add("p1", user.Text);
            cmd.Parameters.Add("p2", pass.Text);
            OracleDataReader reader = cmd.ExecuteReader();

            reader.Read();
            if (reader["COUNT(*)"].ToString() == "1")
            {
                cmd = new OracleCommand("SELECT USERID, ROLE FROM EMP_LOGIN WHERE USERID= :p1 AND PASSWORD= :p2", dbms.con);
                cmd.Parameters.Add("p1", user.Text);
                cmd.Parameters.Add("p2", pass.Text);
                reader = cmd.ExecuteReader();
                reader.Read();
                globalVar.loginStatus = true;
                globalVar.userid      = reader["USERID"].ToString();
                globalVar.role        = reader["ROLE"].ToString();
                MessageBox.Show("User " + globalVar.userid + " logged in as " + globalVar.role, "Success");
                this.Close();
            }
            else
            {
                MessageBox.Show("Username/Password invalid");
            }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            dbconnect dbms = new dbconnect();

            dbms.connect();
            OracleCommand cmd = new OracleCommand("SELECT * FROM CUSTOMER WHERE CUST_ID=:p1", dbms.con);

            cmd.Parameters.Add("p1", custId.Text);
            OracleDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                panel.Visible = false;
                name.Text     = reader["NAME"].ToString();
                address.Text  = reader["ADDRESS"].ToString();
                dob.Text      = reader["DATE_OF_BIRTH"].ToString();
                aadharNo.Text = reader["AADHAR_NO"].ToString();
                mobileNo.Text = reader["MOBILE_NO"].ToString();
                email.Text    = reader["EMAIL_ID"].ToString();
            }
            else
            {
                MessageBox.Show("Customer ID not found", "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            dbconnect dbms = new dbconnect();

            dbms.connect();
            OracleCommand cmd = new OracleCommand("INSERT INTO CUSTOMER (NAME, ADDRESS, DATE_OF_BIRTH, AADHAR_NO, MOBILE_NO, EMAIL_ID) VALUES (:p1, :p2, :p3, :p4, :p5, :p6)", dbms.con);

            cmd.Parameters.Add("p1", name.Text);
            cmd.Parameters.Add("p2", address.Text);
            cmd.Parameters.Add("p3", dob.Value.Date);
            cmd.Parameters.Add("p4", aadharNo.Text);
            cmd.Parameters.Add("p5", mobileNo.Text);
            cmd.Parameters.Add("p6", email.Text);
            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show("Customer added successfully", "Success");
                ((Form)this.TopLevelControl).Close();
            }
            catch (Exception exp)
            {
                MessageBox.Show("Customer not added\n" + exp.Message, "Error!!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }