コード例 #1
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            OracleCommand checkPass = new OracleCommand();

            checkPass.Connection  = OracleHelper.getConnection();
            checkPass.CommandType = CommandType.StoredProcedure;
            checkPass.CommandText = "Check_Password";
            checkPass.Parameters.Add("usr", userNameText.Text);
            checkPass.Parameters.Add("p", passwordTxt.Text);
            checkPass.Parameters.Add("ret", OracleDbType.Int32, ParameterDirection.Output);
            checkPass.ExecuteNonQuery();
            int ret = int.Parse(checkPass.Parameters["ret"].Value.ToString());

            if (ret == LoginForm.WRONG_PASS)
            {
                MessageBox.Show("Wrong Password!", "Warning");
                passwordTxt.Clear();
            }
            else if (ret == LoginForm.WRONG_USERNAME)
            {
                MessageBox.Show("Username not found!", "Warning");
                passwordTxt.Clear();
                userNameText.Clear();
            }
            else if (ret == LoginForm.SUCCESS)
            {
                OracleHelper.LoggedIn.user_name = userNameText.Text;
                this.Hide();
                UserHome uh = new UserHome();
                uh.Closed += (s, args) => this.Close();
                uh.Show();
                passwordTxt.Clear();
                userNameText.Clear();
            }
        }
コード例 #2
0
        private void backBtn_Click(object sender, EventArgs e)
        {
            this.Hide();
            UserHome v = new UserHome();

            v.FormClosed += (s, args) => this.Close();
            v.Show();
        }
コード例 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
            UserHome uh = new UserHome();

            uh.Closed += (s, args) => this.Close();
            uh.Show();
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            events.Clear();
            eventsCLB.Items.Clear();
            this.Hide();
            UserHome u = new UserHome();

            u.Closed += (s, args) => this.Close();
            u.Show();
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            titleTxt.Clear();
            descriptionTxt.Clear();
            capTxt.Clear();
            locCB.Items.Clear();
            timeCB.Items.Clear();
            depCB.Items.Clear();
            hostCLB.Items.Clear();
            this.Hide();
            UserHome u = new UserHome();

            u.Closed += (s, args) => this.Close();
            u.Show();
        }
コード例 #6
0
        private void btn_Click(object sender, EventArgs e)
        {
            //event title is not empty
            if (titleTxt.Text.Length == 0)
            {
                MessageBox.Show("Title is empty! Please enter a title...", "Warning");
                return;
            }
            //event title is unique
            OracleCommand title = new OracleCommand();

            title.Connection  = OracleHelper.getConnection();
            title.CommandText = "IsTitleUnique";
            title.CommandType = CommandType.StoredProcedure;
            title.Parameters.Add("title", titleTxt.Text);
            int ret;

            title.Parameters.Add("ret", OracleDbType.Int32, ParameterDirection.Output);
            title.ExecuteNonQuery();

            //description is not empty
            if (descriptionTxt.Text.Length == 0)
            {
                MessageBox.Show("Description is empty! Please enter a description...", "Warning");
                return;
            }

            //capacity is not empty
            if (capTxt.Text.Length == 0)
            {
                MessageBox.Show("Capacity is empty! Please enter a capacity...", "Warning");
                return;
            }

            if (locCB.SelectedIndex < 0 || timeCB.SelectedIndex < 0 || depCB.SelectedIndex < 0)
            {
                MessageBox.Show("Please do not leave empty fields..", "Warning");
                return;
            }

            try
            {
                ret = int.Parse(title.Parameters["ret"].Value.ToString());
                if (ret == 0)
                {
                    MessageBox.Show("Title is not unique!", "Warning");
                    return;
                }
                int x = int.Parse(capTxt.Text);
            }catch (Exception ex)
            {
                MessageBox.Show("Please enter number in capacity...", "Warning");
            }


            //insert event
            OracleCommand insEvent = new OracleCommand();

            insEvent.Connection  = OracleHelper.getConnection();
            insEvent.CommandText = "Insert_Event";
            insEvent.CommandType = CommandType.StoredProcedure;
            insEvent.Parameters.Add("t", titleTxt.Text);
            insEvent.Parameters.Add("cap", capTxt.Text);
            insEvent.Parameters.Add("des", descriptionTxt.Text);
            insEvent.Parameters.Add("ln", locCB.SelectedItem.ToString());
            int tIndx = timeCB.SelectedIndex;

            insEvent.Parameters.Add("st", startTimes[tIndx].ToString());
            insEvent.Parameters.Add("et", endTimes[tIndx].ToString());
            insEvent.Parameters.Add("ld", dates[tIndx].ToString().ToUpper());
            insEvent.Parameters.Add("did", dids[depCB.SelectedIndex]);
            insEvent.Parameters.Add("hst", OracleHelper.LoggedIn.user_name);
            insEvent.ExecuteNonQuery();

            //insert hosts
            if (hostCLB.CheckedItems.Count > 0)
            {
                for (int i = 0; i < hostCLB.CheckedItems.Count; i++)
                {
                    OracleCommand addHost = new OracleCommand();
                    addHost.Connection  = OracleHelper.getConnection();
                    addHost.CommandText = "Add_Host";
                    addHost.CommandType = CommandType.StoredProcedure;
                    addHost.Parameters.Add("t", titleTxt.Text);
                    addHost.Parameters.Add("hst", usernames[hostCLB.CheckedItems[i].ToString()]);
                    addHost.ExecuteNonQuery();
                }
            }

            MessageBox.Show("Event successfully created!", "Success");
            titleTxt.Clear();
            descriptionTxt.Clear();
            capTxt.Clear();
            hostCLB.ClearSelected();

            this.Hide();
            UserHome u = new UserHome();

            u.Closed += (s, args) => this.Close();
            u.Show();
        }