Esempio n. 1
0
 public bool SaveAll(StaffDesignation aDesignation)
 {
     aStaffDesignationGateway = new StaffDesignationGateway();
     if (aStaffDesignationGateway.SaveAll(aDesignation))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 2
0
        public List <StaffDesignation> GetAllStaffDesignation()
        {
            string        query         = "SELECT * FROM StaffDesignationTable";
            SqlConnection sqlConnection = new SqlConnection(connection.ConnectionString);

            sqlConnection.Open();
            SqlCommand              sqlCommand        = new SqlCommand(query, sqlConnection);
            SqlDataReader           sqlDataReader     = sqlCommand.ExecuteReader();
            List <StaffDesignation> staffDesignations = new List <StaffDesignation>();

            while (sqlDataReader.Read())
            {
                StaffDesignation aStaffDesignation = new StaffDesignation();
                aStaffDesignation.StaffDesignationId = Convert.ToInt32(sqlDataReader[0]);
                aStaffDesignation.Designation        = sqlDataReader[1].ToString();
                staffDesignations.Add(aStaffDesignation);
            }
            sqlConnection.Close();
            return(staffDesignations);
        }
Esempio n. 3
0
        public bool SaveAll(StaffDesignation aDesignation)
        {
            connection.Open();
            string query = string.Format("INSERT INTO StaffDesignationTable values ('{0}')", aDesignation.Designation);

            command = new SqlCommand(query, connection);
            int affectedRows = command.ExecuteNonQuery();

            connection.Close();
            if (affectedRows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }

            return(false);
        }
Esempio n. 4
0
        private void addButton_Click(object sender, EventArgs e)
        {
            bool             condition;
            StaffDesignation aDesignation = new StaffDesignation();

            aDesignation.Designation = designationTextBox.Text;

            StaffDesignationManager aStaffDesignationManager = new StaffDesignationManager();


            condition = aStaffDesignationManager.SaveAll(aDesignation);
            if (condition)
            {
                MessageBox.Show("Added Successfully");
            }
            else
            {
                MessageBox.Show("Error adding");
            }
        }
Esempio n. 5
0
        private void Addbutton_Click(object sender, EventArgs e)
        {
            Staff            aStaff                   = new Staff();
            StaffManager     aStaffManager            = new StaffManager();
            StaffType        selectedStaffType        = (StaffType)staffTypeCombobox.SelectedItem;
            StaffDesignation selectedStaffDesignation = (StaffDesignation)designationComboBox.SelectedItem;

            aStaff.StaffType        = selectedStaffType;
            aStaff.StaffDesignation = selectedStaffDesignation;
            aStaff.Name             = nameTextBox.Text;
            aStaff.Address          = addressTextBox.Text;
            aStaff.IdCardNumber     = IdCardTextBox.Text;
            aStaff.PhoneNumber      = phoneNumberTextBox.Text;
            aStaff.Email            = emailTextBox.Text;
            aStaff.Note             = noteTextBox.Text;
            aStaff.FatherName       = fatherNameTextBox.Text;
            aStaff.City             = cityTextBox.Text;
            aStaff.Balance          = Convert.ToDouble(balanceTextBox.Text);
            bool condition;

            if (selectedStaffType != null && selectedStaffDesignation != null)
            {
                condition = aStaffManager.SaveNewStaff(aStaff);

                if (condition)
                {
                    MessageBox.Show("New Staff Saved Successfull");
                }
                else
                {
                    MessageBox.Show("Save error!");
                }
            }
            else
            {
                MessageBox.Show("Select staff type and staff designation please");
            }
        }