Exemplo n.º 1
0
        /// <summary>
        /// this will add a course to the List view to be saved when the employee is created
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnAddCourse_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem item in LVxCourses.Items)
            {
                if (item.SubItems[0].Text == TxtCourseID.Text)
                {
                    if (MessageBox.Show("Course already exists would you like to update the record.", "Update", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        LVxCourses.Items.Remove(item);
                    }
                    else
                    {
                        return;
                    }
                }
            }
            ListViewItem lvi = new ListViewItem(TxtCourseID.Text);

            if (TxtDescription.Text != "")
            {
                lvi.SubItems.Add(TxtDescription.Text);
            }
            else
            {
                LblStatus.Text = "Please enter a value for the Description";
                TxtDescription.Focus();
            }
            if (TxtGrade.Text != "")
            {
                lvi.SubItems.Add(TxtGrade.Text);
            }
            else
            {
                LblStatus.Text = "Please enter a value for the Grade";
                TxtGrade.Focus();
            }
            if (TxtDateApproved.Text != "")
            {
                lvi.SubItems.Add(TxtDateApproved.Text);
            }
            else
            {
                LblStatus.Text = "Please enter a value for the Date Approved";
                TxtDateApproved.Focus();
            }
            if (TxtCredits.Text != "")
            {
                lvi.SubItems.Add(TxtCredits.Text);
            }
            else
            {
                LblStatus.Text = "Please enter a value for the Credits.";
                TxtCredits.Focus();
            }
            //checkbox value
            lvi.SubItems.Add(CkbApproved.Checked.ToString());
            LVxCourses.Items.Add(lvi);
            ClearEducation();
        }
Exemplo n.º 2
0
 private void BtnClear_Click(object sender, EventArgs e)
 {
     TxtFirstName.Clear();
     TxtLastName.Clear();
     TxtGrade.Clear();
     TxtAddress.Clear();
     TxtContactNo.Clear();
 }
Exemplo n.º 3
0
 /// <summary>
 /// this will clear all the educational fields
 /// </summary>
 private void ClearEducation()
 {
     CkbApproved.Checked = true;
     TxtCourseID.Clear();
     TxtGrade.Clear();
     TxtDescription.Clear();
     TxtDateApproved.Clear();
     TxtCredits.Clear();
 }
Exemplo n.º 4
0
        private void BtnScoreAdd_Click(object sender, EventArgs e)
        {
            if (CboSno.Text == "")
            {
                MessageBox.Show("请选择学号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CboSno.Focus();
            }
            else if (CboCourse.Text == "")
            {
                MessageBox.Show("请选择课程号!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CboCourse.Focus();
            }
            else if (CboYear.Text == "")
            {
                MessageBox.Show("请选择学年!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CboYear.Focus();
            }
            else if (CboTeam.Text == "")
            {
                MessageBox.Show("请选择学期!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                CboTeam.Focus();
            }
            else if (TxtGrade.Text == "")
            {
                MessageBox.Show("请输入成绩!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtGrade.Focus();
            }
            else
            {
                try
                {
                    string str = string.Format(" insert into tbscore(studentNo,courseID,score,term,Year) values('{0}','{1}','{2}','{3}','{4}')", CboSno.Text, Status.sql, int.Parse(TxtGrade.Text), CboTeam.Text, CboYear.Text);
                    DBHelper.conn.Open();
                    SqlCommand command = new SqlCommand(str, DBHelper.conn);
                    int        result  = command.ExecuteNonQuery();

                    if (result < 1)
                    {
                        MessageBox.Show("成绩录入失败!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("成绩录入成功!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("数据库操作错误:" + ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    DBHelper.conn.Close();
                    this.ViewInfo();
                }
            }
        }
Exemplo n.º 5
0
 private void BtnUpdate_Click(object sender, EventArgs e)
 {
     if (TxtFirstName.Text == "")
     {
         MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtLastName.Text == "")
     {
         MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtGrade.Text == "")
     {
         MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtAddress.Text == "")
     {
         MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtContactNo.Text == "")
     {
         MessageBox.Show("Please fill empty fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         var result = MessageBox.Show("Confirm editing new record?", "Edit New Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             using (var con = new MySqlConnection(GetConnection()))
             {
                 string command = $"UPDATE `lms.sad`.`tblusers`" +
                                  $" SET " +
                                  $"`First_Name`='{TxtFirstName.Text}',`Last_Name`='{TxtLastName.Text}',`Year_Level`='{TxtGrade.Text}',`Address`='{TxtAddress.Text}',`Contact_Number`='{TxtContactNo.Text}'" +
                                  $" WHERE `User_ID`='{TxtUserID.Text}'";
                 con.Open();
                 using (var cmd = new MySqlCommand(command, con))
                 {
                     cmd.CommandType = CommandType.Text;
                     var i = cmd.ExecuteNonQuery();
                     if (i > 0)
                     {
                         MessageBox.Show("Successfully Updated! Please refresh Book List to view entry!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         TxtFirstName.Clear();
                         TxtLastName.Clear();
                         TxtGrade.Clear();
                         TxtAddress.Clear();
                         TxtContactNo.Clear();
                         TxtUserID.Clear();
                     }
                 }
                 con.Close();
             }
         }
     }
 }
Exemplo n.º 6
0
 private void BtnRegister_Click(object sender, EventArgs e)
 {
     if (TxtFirstName.Text == "")
     {
         MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtLastName.Text == "")
     {
         MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtGrade.Text == "")
     {
         MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtAddress.Text == "")
     {
         MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else if (TxtContactNo.Text == "")
     {
         MessageBox.Show("Please enter missing fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         var result = MessageBox.Show("Confirm adding new record?", "Add New Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (result == DialogResult.Yes)
         {
             using (var con = new MySqlConnection(GetConnection()))
             {
                 string command = $"INSERT INTO `lms.sad`.`tblusers` (`First_Name`,`Last_Name`, `Year_Level`, `Address`,`Contact_Number`) " +
                                  "VALUES " +
                                  $"('{TxtFirstName.Text}','{TxtLastName.Text}','{TxtGrade.Text}','{TxtAddress.Text}','{TxtContactNo.Text}')";
                 con.Open();
                 using (var cmd = new MySqlCommand(command, con))
                 {
                     cmd.CommandType = CommandType.Text;
                     var i = cmd.ExecuteNonQuery();
                     if (i > 0)
                     {
                         MessageBox.Show("Successfully Added! Please refresh Borrower List to view entry!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         TxtFirstName.Clear();
                         TxtLastName.Clear();
                         TxtGrade.Clear();
                         TxtAddress.Clear();
                         TxtContactNo.Clear();
                     }
                 }
                 con.Close();
             }
         }
     }
 }
Exemplo n.º 7
0
        /***************************************
        *
        *  This is where the UTILITY METHODS are.
        *
        ***************************************/

        /// <summary>
        /// This clears the form after an entry is added.
        /// </summary>
        private void ClearForm()
        {
            TxtEmpID.Clear();
            TxtFirstName.Clear();
            TxtLastName.Clear();
            TxtMiddleName.Clear();
            TxtXtraProp1.Clear();
            TxtXtraProp2.Clear();
            CkbActiveEmployee.Checked = true;
            CkbBenefits.Checked       = true;
            CkbApproved.Checked       = true;
            LVxCourses.Items.Clear();
            TxtCourseID.Clear();
            TxtGrade.Clear();
            TxtDescription.Clear();
            TxtDateApproved.Clear();
            TxtCredits.Clear();
            TxtMaritalStatus.Clear();
            TxtDepartment.Clear();
            TxtTitle.Clear();
            TxtStartDate.Clear();
        }