예제 #1
0
        protected void btnManageAdd(object sender, EventArgs e)
        {
            try
            {
                DAL.StaffClass staff = new DAL.StaffClass(txtStaffNo.Text, txtFirstName.Text, txtLastName.Text, txtEmail.Text, int.Parse(txtContactNumber.Text), cmbStaffType.SelectedValue.ToString(), int.Parse(cmbDepartmentCode.SelectedValue.ToString()), txtUsername.Text, txtPassword.Text, cmbActiveStatus.SelectedValue.ToString());
                int            x     = bll.AddStaff(staff);


                if (x > 0)
                {
                    txtStaffNo.Text        = "";
                    txtFirstName.Text      = "";
                    txtLastName.Text       = "";
                    txtEmail.Text          = "";
                    txtContactNumber.Text  = "";
                    cmbStaffType.Text      = " ";
                    cmbDepartmentCode.Text = " ";
                    txtUsername.Text       = "";
                    txtPassword.Text       = "";
                    cmbActiveStatus.Text   = " ";
                }
                else
                {
                }
            }
            catch
            {
            }
            dgStaff.DataSource = bll.GetStaff();
            dgStaff.DataBind();
        }
예제 #2
0
        private void BtnManageAdd_Click(object sender, EventArgs e)
        {
            try
            {
                string activeStatus = "";
                if (cmbStatus.SelectedItem.ToString() == "Active")
                {
                    activeStatus = "True";
                }
                else
                {
                    activeStatus = "False";
                }
                DAL.StaffClass staff = new DAL.StaffClass(txtStaffNumber.Text, txtName.Text, txtSurname.Text, txtEmailAddress.Text, int.Parse(txtContactNo.Text), cmbStaffType.SelectedItem.ToString(), int.Parse(cmbDepartmentCode.SelectedValue.ToString()), txtUsername.Text, txtPassword.Text, activeStatus);
                int            x     = bll.AddStaff(staff);


                if (x > 0)
                {
                    txtStaffNumber.Clear();
                    txtName.Clear();
                    txtSurname.Clear();
                    txtEmailAddress.Clear();
                    txtContactNo.Clear();
                    cmbStaffType.Text      = " ";
                    cmbDepartmentCode.Text = " ";
                    cmbStatus.Text         = " ";
                    txtUsername.Clear();
                    txtPassword.Clear();
                }
                else
                {
                    MessageBox.Show("Please input valid data.");
                }
            }
#pragma warning disable CS0168 // The variable 'b' is declared but never used
            catch (Exception b)
#pragma warning restore CS0168 // The variable 'b' is declared but never used
            {
                MessageBox.Show("Please input valid data.");
            }
            dgvStaff.DataSource = bll.GetStaff();
        }