Example #1
0
        // Constructor with useraction and staffdetail
        public FormStaffDetail(string userAction, Staff staff)
        {
            InitializeComponent();

            // Set useraction and staff
            this.StaffDetail = staff;
            this.UserAction = userAction;

            // Set default gender
            comboBoxGender.SelectedIndex = 0;
            comboBoxState.SelectedIndex = 0;            

            // Get department list and set it to comboBox
            comboBoxDepartment.DataSource = Department.GetListDepartment();
            comboBoxDepartment.ValueMember = "DEPARTMENTID";
            comboBoxDepartment.DisplayMember = "DEPARTMENTNAME";

            // Get major list and set it to combobox
            comboBoxMajor.DataSource = Major.GetListMajor();
            comboBoxMajor.ValueMember = "MAJORID";
            comboBoxMajor.DisplayMember = "MAJORNAME";

            comboBoxRole.DataSource = Role.GetListRole();
            comboBoxRole.ValueMember = "ROLEID";
            comboBoxRole.DisplayMember = "ROLENAME";

            // If useraction is edit then set staffdetail to staffdetail form
            if ("edit".Equals(userAction))
            {
                setStaffDetail(staff);
            }
            else if ("personalEdit".Equals(userAction))
            {
                SetPersonalDetail(staff);
            }
            else
            {
                textBoxPassword.ReadOnly = true;
                textBoxPasswordCheck.ReadOnly = true;
            }
        }
Example #2
0
        public static int UpdateStaff(Staff staff)
        {
            string sqlUpdate = @"UPDATE STAFF
                                SET DEPARTMENTID = @DepartmentID, MAJORID = @MajorID, ROLEID = @RoleID, PASSWORD = @Password
                                                 , FIRSTNAME = @FirstName, LASTNAME = @LastName, BIRTHDAY = @BirthDay, GENDER = @Gender
                                                 , ICN = @ICN, ADDRESS = @Address, STATE = @State
                                WHERE (STAFFID = @StaffID)";

            SqlParameter[] sqlParameters = { new SqlParameter("StaffID", staff.StaffID),
                                           new SqlParameter("@DepartmentID", staff.DepartmentID),
                                           new SqlParameter("@MajorID", staff.MajorID),
                                           new SqlParameter("@RoleID", staff.RoleID),
                                           new SqlParameter("@Password", staff.Password),
                                           new SqlParameter("@FirstName", staff.FirstName),
                                           new SqlParameter("@LastName", staff.LastName),
                                           new SqlParameter("@BirthDay", staff.BirthDay),
                                           new SqlParameter("@Gender", staff.Gender),
                                           new SqlParameter("@ICN", staff.ICN),
                                           new SqlParameter("@Address", staff.Address),
                                           new SqlParameter("@State", staff.State)};

            return SqlResult.ExecuteNonQuery(sqlUpdate, sqlParameters);
        }
Example #3
0
        public static int InsertStaff(Staff staff)
        {
            string sqlInsert = @"INSERT INTO STAFF
                                (DEPARTMENTID, MAJORID, ROLEID, PASSWORD, FIRSTNAME, LASTNAME, BIRTHDAY, GENDER, ICN, ADDRESS, STATE)
                                VALUES
                                (@DepartmentID, @MajorID, @RoleID, @Password, @FirstName, @LastName, @BirthDay, @Gender, @ICN
                                    , @Address, @State)";

            SqlParameter[] sqlParameters = {   new SqlParameter("@DepartmentID", staff.DepartmentID),
                                           new SqlParameter("@MajorID", staff.MajorID),
                                           new SqlParameter("@RoleID", staff.RoleID),
                                           new SqlParameter("@Password", staff.Password),
                                           new SqlParameter("@FirstName", staff.FirstName),
                                           new SqlParameter("@LastName", staff.LastName),
                                           new SqlParameter("@BirthDay", staff.BirthDay),
                                           new SqlParameter("@Gender", staff.Gender),
                                           new SqlParameter("@ICN", staff.ICN),
                                           new SqlParameter("@Address", staff.Address),
                                           new SqlParameter("@State", staff.State)};



            return SqlResult.ExecuteNonQuery(sqlInsert, sqlParameters);
        }
Example #4
0
 public FormMain(Staff staff)
 {
     InitializeComponent();
     loginStaff = staff;
 }
Example #5
0
        public static Staff GetStaff(int staffID)
        {
            Staff newStaff = new Staff();
            DataTable staffDataTable;
            string sqlSelect = @"SELECT STAFFID, DEPARTMENTID, MAJORID, ROLEID, PASSWORD, FIRSTNAME, LASTNAME, BIRTHDAY,
                                        GENDER, ICN, ADDRESS, STATE
                                FROM STAFF
                                WHERE (STAFFID = @StaffID)";
            SqlParameter[] sqlParameters = { new SqlParameter("@StaffID", staffID) };

            staffDataTable = SqlResult.ExecuteQuery(sqlSelect, sqlParameters);

            if (staffDataTable.Rows.Count > 0)
            {
                newStaff.StaffID = Convert.ToInt32(staffDataTable.Rows[0]["STAFFID"].ToString());
                newStaff.DepartmentID = Convert.ToInt32(staffDataTable.Rows[0]["DEPARTMENTID"].ToString());
                newStaff.MajorID = Convert.ToInt32(staffDataTable.Rows[0]["MAJORID"].ToString());
                newStaff.RoleID = Convert.ToInt32(staffDataTable.Rows[0]["ROLEID"].ToString());
                newStaff.Password = (string)staffDataTable.Rows[0]["PASSWORD"];
                newStaff.FirstName = (string)staffDataTable.Rows[0]["FIRSTNAME"];
                newStaff.LastName = (string)staffDataTable.Rows[0]["LASTNAME"];
                newStaff.BirthDay = (DateTime)staffDataTable.Rows[0]["BIRTHDAY"];
                newStaff.Gender = (int)staffDataTable.Rows[0]["GENDER"];
                newStaff.ICN = (decimal)staffDataTable.Rows[0]["ICN"];
                newStaff.Address = (string)staffDataTable.Rows[0]["ADDRESS"];
                newStaff.State = (int)staffDataTable.Rows[0]["STATE"];
            }
            
            return newStaff;
        }
Example #6
0
        // Set staffdetail to staffdetail form
        public void setStaffDetail(Staff staff)
        {
            this.StaffDetail = staff;
            textBoxStaffID.Text = staff.StaffID.ToString();
            textBoxFirstName.Text = staff.FirstName;
            textBoxLastName.Text = staff.LastName;
            dateBirthday.Value = staff.BirthDay;
            if (staff.ICN != 0)
            {
                textBoxIdentityCard.Text = staff.ICN.ToString();
            }
            
            if (Staff.GENDER_MALE.Equals(staff.Gender))
            {
                comboBoxGender.SelectedIndex = Staff.GENDER_MALE;
            }
            else
            {
                comboBoxGender.SelectedIndex = Staff.GENDER_FEMALE;
            }

            textBoxAddress.Text = staff.Address;

            if (staff.State == 0)
            {
                comboBoxState.Text = "Đã thôi việc";
            }
            else
            {
                comboBoxState.Text = "Đang làm việc";
            }

            comboBoxDepartment.SelectedValue = (object)staff.DepartmentID;
            comboBoxMajor.SelectedValue = (object)staff.MajorID;
            comboBoxRole.SelectedValue = (object)staff.RoleID;

            textBoxPassword.ReadOnly = true;
            textBoxPasswordCheck.ReadOnly = true;


        }