Example #1
0
        } // end of ReadFullTime

        public static void InsertFullTimer(FullTime insFull)
        {
            // add to employee table
            sql = "INSERT INTO EmployeeTable(EmployeeID, FirstName, LastName, DateHired, SSN, Email, PhoneNumber, TaxRate) " +
                  "VALUES ('" +
                  insFull.Id + "', '" + insFull.FirstName + "', '" +
                  insFull.LastName + "', '" + insFull.Doh + "', '" +
                  insFull.Ssn + "', '" + insFull.EMail + "', '" +
                  insFull.PhoneNum + "', '" + insFull.TaxRate + "');";
            OpenDB();
            SqlCommand cmdInsert1 = new SqlCommand(sql, dbConn);

            ExecCommand(cmdInsert1);
            CloseDB();


            // adds to f/t table

            sql = "INSERT INTO FullTime(Salary, NumberVacationDays, NumberSickDays, IsTaxExempt, IsInsured, EmployeeID) " +
                  "VALUES('" +
                  insFull.Salary + "', '" + insFull.VacDays + "', '" +
                  insFull.SickDays + "', '" + insFull.TaxExempt + "', '" +
                  insFull.Insured + "', '" + insFull.Id + "');";
            OpenDB();
            SqlCommand cmdInsert = new SqlCommand(sql, dbConn);

            ExecCommand(cmdInsert);
            CloseDB();
        } // end of insert
Example #2
0
 private void listBoxFullTime_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listBoxFullTime.SelectedIndex != -1)
     {
         i = listBoxFullTime.SelectedIndex;
         FullTime FTEmployee = (FullTime)listBoxFullTime.Items[i];
         employeeIDtxtBox.Text  = FTEmployee.EmployeeID.ToString();
         nameTxtBox.Text        = FTEmployee.FName + " " + FTEmployee.LName;
         salaryTxtBox.Text      = FTEmployee.Salary.ToString();
         sickDayTxtBox.Text     = FTEmployee.SickDays.ToString();
         vacationDayTxtBox.Text = FTEmployee.VacationDays.ToString();
         if (FTEmployee.HasInsurance)
         {
             hasInsuranceCheckBox.Checked = true;
         }
         else
         {
             hasInsuranceCheckBox.Checked = false;
         }
         if (FTEmployee.TaxExempt)
         {
             taxExemptCheckBox.Checked = true;
         }
         else
         {
             taxExemptCheckBox.Checked = false;
         }
     }
 }
Example #3
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            FullTime aFullTime = new FullTime();

            aFullTime.ID                = Convert.ToInt16(txtBxEmployeeID.Text);
            aFullTime.FirstNanme        = txtBxFName.Text;
            aFullTime.LastName          = txtBxLName.Text;
            aFullTime.DateHired         = Convert.ToDateTime(txtBxDateHired.Text);
            aFullTime.SSN               = txtBxSSN.Text;
            aFullTime.Email             = txtBxEmail.Text;
            aFullTime.Phone             = txtBxPhone.Text;
            aFullTime.TaxRate           = Convert.ToDecimal(txtBxTaxRate.Text);
            aFullTime.ID                = Convert.ToInt16(txtBxID.Text);
            aFullTime.Salary            = Convert.ToDecimal(txtBxSalary.Text);
            aFullTime.NumOfVacationDays = Convert.ToInt16(numBxVacationDays.Text);
            aFullTime.HasInsurance      = txtBxHasInsurance.Text;
            aFullTime.TaxExempt         = txtBxTaxExempt.Text;
            aFullTime.NumOfSickDays     = Convert.ToInt16(numBxSickDays.Text);

            DataAdapter.Update(aFullTime);

            listBox1.Items.Clear();
            DataAdapter.FullTimeEmployees[idx] = aFullTime;
            foreach (FullTime item in DataAdapter.FullTimeEmployees)
            {
                listBox1.Items.Add(item);
                loaded = true;
            }
        }
Example #4
0
        }     // end of CloseDB

        public static ArrayList GetFullTimers()
        {
            OpenDB();
            dbReader = ReadFullTime();

            ArrayList fullEmp = new ArrayList();

            while (dbReader.Read())
            {
                aFullTime = new FullTime(
                    dbReader["EmployeeID"].ToString(),
                    dbReader["FirstName"].ToString(),
                    dbReader["LastName"].ToString(),
                    dbReader["DateHired"].ToString(),
                    dbReader["SSN"].ToString(),
                    dbReader["Email"].ToString(),
                    dbReader["PhoneNumber"].ToString(),
                    dbReader["TaxRate"].ToString(),
                    dbReader["Salary"].ToString(),
                    dbReader["NumberVacationDays"].ToString(),
                    dbReader["NumberSickDays"].ToString(),
                    dbReader["IsTaxExempt"].ToString(),
                    dbReader["IsInsured"].ToString());
                fullEmp.Add(aFullTime);
            } // end of while
            CloseDB();
            return(fullEmp);
        } // end of getall
Example #5
0
        /// <summary>
        /// Insert a Full time employee into both of the tables
        /// </summary>
        /// <param name="insFullTime"></param>
        public static void InsertFullTimeTable(FullTime insFullTime)
        {
            sql = "SET IDENTITY_INSERT Employee ON " +
                  "INSERT INTO Employee(EmployeeId, FirstName, LastName, DateHired, Ssn, Email, Phone, TaxRate)" +
                  "VALUES('" +
                  insFullTime.EmployeeId + "', '" +
                  insFullTime.FirstName + "', '" +
                  insFullTime.LastName + "', '" +
                  insFullTime.DateHired + "', '" +
                  insFullTime.Ssn + "', '" +
                  insFullTime.Email + "', '" +
                  insFullTime.Phone + "', '" +
                  insFullTime.TaxRate + "');" +

                  "SET IDENTITY_INSERT Employee OFF " +
                  "INSERT INTO FullTime(EmployeeId,Salary, NumOfVacationDays, HasInsurance, TaxExempt, SickDays)" +
                  "VALUES('" +
                  insFullTime.EmployeeId + "', '" +
                  insFullTime.Salary + "', '" +
                  insFullTime.NumOfVacationDays + "', '" +
                  insFullTime.HasInsurance + "', '" +
                  insFullTime.IsTaxExempt + "', '" +
                  insFullTime.SickDays + "');";

            Connect();

            SqlCommand cmdInsert = new SqlCommand(sql, oConn);

            ExeCommand(cmdInsert);
        }
Example #6
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                btnInsert.Enabled = false;
                btnUpdate.Enabled = true;
                btnDelete.Enabled = true;
                // These two enabled function is for us to not duplicate data in the database.
                // For example you can not just click on an exist data and do INSERT them to the database
                // The only option you have is only to Update data if you click on the list
                idx = listBox1.SelectedIndex;
                FullTime aFullTime = (FullTime)DataAdapter.FullTimeEmployees[idx];

                txtBxEmployeeID.Text   = aFullTime.ID.ToString();
                txtBxFName.Text        = aFullTime.FirstNanme;
                txtBxLName.Text        = aFullTime.LastName;
                txtBxDateHired.Text    = aFullTime.DateHired.ToString();
                txtBxSSN.Text          = aFullTime.SSN;
                txtBxEmail.Text        = aFullTime.Email;
                txtBxPhone.Text        = aFullTime.Phone;
                txtBxTaxRate.Text      = aFullTime.TaxRate.ToString();
                txtBxID.Text           = aFullTime.ID.ToString();
                txtBxSalary.Text       = aFullTime.Salary.ToString();
                numBxVacationDays.Text = aFullTime.NumOfVacationDays.ToString();
                txtBxHasInsurance.Text = aFullTime.HasInsurance;
                txtBxTaxExempt.Text    = aFullTime.TaxExempt;
                numBxSickDays.Text     = aFullTime.NumOfSickDays.ToString();
            }
        }
Example #7
0
        /// <summary>
        /// Updating Database row;
        /// </summary>
        /// <param name="updFullTime"></param>
        public static void UpdateFullTimeTable(FullTime updFullTime)
        {
            // set up an sql command to run in my sql
            sql = "UPDATE Employee SET " +

                  "FirstName = '" + updFullTime.FirstName + "', " +
                  "LastName  = '" + updFullTime.LastName + "', " +
                  "DateHired  = '" + updFullTime.DateHired + "', " +
                  "Ssn  = '" + updFullTime.Ssn + "', " +
                  "Email  = '" + updFullTime.Email + "', " +
                  "Phone = '" + updFullTime.Phone + "' " +
                  "WHERE EmployeeId = @id " +
                  "UPDATE FullTime SET " +

                  "Salary= '" + updFullTime.Salary + "', " +
                  "NumOfVacationDays= '" + updFullTime.NumOfVacationDays + "', " +
                  "HasInsurance= '" + updFullTime.HasInsurance + "', " +
                  "TaxExempt= '" + updFullTime.IsTaxExempt + "', " +
                  "SickDays= '" + updFullTime.SickDays + "' " +
                  "WHERE EmployeeId = @id; ";


            Connect();

            SqlCommand cmdUpdate = new SqlCommand(sql, oConn);

            cmdUpdate.Parameters.AddWithValue("@id", updFullTime.EmployeeId);
            ExeCommand(cmdUpdate);
        }
Example #8
0
        } // end of insert

        public static void UpdateEmployee(FullTime updEmp)
        {
            // to update the employee table
            sql = $"UPDATE EmployeeTable " +
                  $"SET FirstName = '{updEmp.FirstName}', " +
                  $"    LastName = '{updEmp.LastName}', " +
                  $"    DateHired = '{updEmp.Doh}', " +
                  $"    SSN = '{updEmp.Ssn}', " +
                  $"    Email = '{updEmp.EMail}'," +
                  $"    PhoneNumber = '{updEmp.PhoneNum}', " +
                  $"    TaxRate = '{updEmp.TaxRate}' " +
                  $"WHERE EmployeeID = '{updEmp.Id}';";
            OpenDB();
            SqlCommand cmdUpdate = new SqlCommand(sql, dbConn);

            ExecCommand(cmdUpdate);
            CloseDB();

            // updates the fulltime table
            sql = $"UPDATE FullTime " +
                  $"SET Salary = '{updEmp.Salary}', " +
                  $"    NumberVacationDays = '{updEmp.VacDays}', " +
                  $"    NumberSickDays = '{updEmp.SickDays}', " +
                  $"    IsTaxExempt = '{updEmp.TaxExempt}', " +
                  $"IsInsured = '{updEmp.Insured}' " +
                  $"WHERE EmployeeID = '{updEmp.Id}';";
            OpenDB();
            cmdUpdate = new SqlCommand(sql, dbConn);
            ExecCommand(cmdUpdate);
            CloseDB();
        } // end of UpdateEmployee
Example #9
0
        } // end of UpdateEmployee

        public static void DeleteEmployee(FullTime delEmp)
        {
            // sql to delete row where id =
            sql = "DELETE FROM EmployeeTable WHERE EmployeeID = '" + delEmp.Id + "';";
            OpenDB();
            SqlCommand cmdDelete = new SqlCommand(sql, dbConn);

            ExecCommand(cmdDelete);
            CloseDB();
        } // end of delete
        /// <summary>
        /// load items in the text box
        /// </summary>
        public void LoadItems()
        {
            lstBxFullTime.Items.Clear();

            ArrayList fullTime = FullTime.getAllFullTime();

            foreach (FullTime aFullTime in fullTime)
            {
                this.lstBxFullTime.Items.Add(aFullTime);
            }
        }
Example #11
0
        } // end of btnLoad_Click

        private void LoadItems()
        {
            lstBxFullTime.Items.Clear();

            ArrayList ar = FullTime.GetFullTime();

            // foreaach f/t , add to listbox
            foreach (FullTime fullTimer in ar)
            {
                lstBxFullTime.Items.Add(fullTimer);
            } // end of foreach
        }     // end of LoadItems
Example #12
0
        /// <summary>
        /// Purpose: Check on condition before insert data to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnInsert_Click_1(object sender, EventArgs e)
        {
            FullTime aFullTime = new FullTime();

            if (Convert.ToInt16(txtBxEmployeeID.Text) <= DataAdapter.FullTimeEmployees.Count)
            {
                MessageBox.Show("This ID has been taken!");
            }
            else if (!Decimal.TryParse(txtBxTaxRate.Text, out decimal number) || txtBxTaxRate.Text == "")
            {
                MessageBox.Show("Please Enter TaxRate to check out");
            }
            else if (!Decimal.TryParse(txtBxSalary.Text, out decimal salary) || txtBxSalary.Text == "")
            {
                MessageBox.Show("Please Enter Salary to check out");
            }
            else if (numBxVacationDays.Text == "")
            {
                MessageBox.Show("Please Enter TaxRate to check out");
            }
            else if (numBxSickDays.Text == "")
            {
                MessageBox.Show("Please Enter TaxRate to check out");
            }
            else
            {
                aFullTime.ID                = Convert.ToInt16(txtBxEmployeeID.Text);
                aFullTime.FirstNanme        = txtBxFName.Text;
                aFullTime.LastName          = txtBxLName.Text;
                aFullTime.DateHired         = Convert.ToDateTime(txtBxDateHired.Text);
                aFullTime.SSN               = txtBxSSN.Text;
                aFullTime.Email             = txtBxEmail.Text;
                aFullTime.Phone             = txtBxPhone.Text;
                aFullTime.TaxRate           = Convert.ToDecimal(txtBxTaxRate.Text);
                aFullTime.ID                = Convert.ToInt16(txtBxID.Text);
                aFullTime.Salary            = Convert.ToDecimal(txtBxSalary.Text);
                aFullTime.NumOfVacationDays = Convert.ToInt16(numBxVacationDays.Text);
                aFullTime.HasInsurance      = txtBxHasInsurance.Text;
                aFullTime.TaxExempt         = txtBxTaxExempt.Text;
                aFullTime.NumOfSickDays     = Convert.ToInt16(numBxSickDays.Text);

                DataAdapter.Insert(aFullTime);

                listBox1.Items.Clear();
                DataAdapter.FullTimeEmployees.Add(aFullTime);
                foreach (FullTime item in DataAdapter.FullTimeEmployees)
                {
                    listBox1.Items.Add(item);
                    loaded = true;
                }
            }
        }
        /// <summary>
        /// Add or update employee method when OK button clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            bool hasIns      = Convert.ToBoolean(txtBxInsure.Text);
            bool isTaxEx     = Convert.ToBoolean(txtBxTax.Text);
            int  ifHasIns    = hasIns ? 1 : 0;
            int  isTaxExempt = isTaxEx ? 1:0;

            if (selectedItem == -1) // if creating a new full time employee
            {
                aFullTime = new FullTime(txtBxFName.Text, txtBxLName.Text,
                                         Convert.ToDateTime(txtBxDateHired.Text),
                                         txtBxSsn.Text,
                                         txtBxEmail.Text,
                                         txtBxPhone.Text,
                                         Convert.ToDecimal(txtBxTaxRate.Text),
                                         Convert.ToInt32(txtBxID.Text),
                                         Convert.ToDecimal(txtBxSalary.Text),
                                         Convert.ToInt32(txtBxVac.Text),
                                         Convert.ToInt32(txtBxSick.Text),
                                         Convert.ToBoolean(ifHasIns),
                                         Convert.ToBoolean(txtBxInsure.Text)
                                         );

                aFullTime.InsertFullTime();
                lblMessage.Text = "Member Added";
                LoadItems();
            }
            else if (selectedItem >= 0)// if not, update the employee selected in the listbox
            {
                aFullTime.FirstName         = txtBxFName.Text;
                aFullTime.LastName          = txtBxLName.Text;
                aFullTime.DateHired         = Convert.ToDateTime(txtBxDateHired.Text);
                aFullTime.Ssn               = txtBxSsn.Text;
                aFullTime.Email             = txtBxEmail.Text;
                aFullTime.Phone             = txtBxPhone.Text;
                aFullTime.TaxRate           = Convert.ToDecimal(txtBxTaxRate.Text);
                aFullTime.Salary            = Convert.ToDecimal(txtBxSalary.Text);
                aFullTime.NumOfVacationDays = Convert.ToInt32(txtBxVac.Text);
                aFullTime.SickDays          = Convert.ToInt32(txtBxSick.Text);
                aFullTime.IsTaxExempt       = Convert.ToBoolean(ifHasIns);
                aFullTime.HasInsurance      = Convert.ToBoolean(ifHasIns);
                aFullTime.updateFullTime();
                lblMessage.Text = "Full Time Employee Updated";
            }
            else
            {
            }
            EnableDisable(false);
            ClearText();
            LoadItems();
        }
Example #14
0
        /// <summary>
        /// Delete the full time employee dynamically
        /// </summary>
        /// <param name="delFullTime"></param>
        public static void DelFullTimeTable(FullTime delFullTime)
        {
            // set up an sql command to run in my sql
            sql = "DELETE Employee " +
                  "WHERE EmployeeId = @id; ";


            Connect();

            SqlCommand cmdDelete = new SqlCommand(sql, oConn);

            cmdDelete.Parameters.AddWithValue("@id", aFulltime.EmployeeId); // deleting the employee using the employeeId dynamically make sure both tables are cascaded
            ExeCommand(cmdDelete);
        }
Example #15
0
        }// end of event

        private void LoadText()
        {
            //EnableDisable(false);
            btnDelete.Visible = false;
            btnDelete.Enabled = false;
            try
            {
                aFullTime          = (FullTime)lstBxFullTime.Items[selected];
                txtBxEmpID.Text    = aFullTime.Id.ToString();
                txtBxEmpID.Enabled = false;
                txtBxFName.Text    = aFullTime.FirstName;
                txtBxLName.Text    = aFullTime.LastName;
                txtBxDOH.Text      = aFullTime.Doh.ToString();
                txtBxSSN.Text      = aFullTime.Ssn;
                txtBxMail.Text     = aFullTime.EMail;
                txtBxPhNum.Text    = aFullTime.PhoneNum;
                txtBxTaxRate.Text  = aFullTime.TaxRate.ToString();
                txtBxSal.Text      = aFullTime.Salary.ToString();
                txtBxVacDay.Text   = aFullTime.VacDays.ToString();
                txtBxSick.Text     = aFullTime.SickDays.ToString();

                if (aFullTime.TaxExempt.ToString() == "True")
                {
                    txtBxTax.Text = "Y";
                } // end of true
                else
                {
                    txtBxTax.Text = "N";
                } // end of false
                  //txtBxTax.Text = aFullTime.TaxExempt.ToString();
                if (aFullTime.Insured.ToString() == "True")
                {
                    txtBxIns.Text = "Y";
                } // end of true
                else
                {
                    txtBxIns.Text = "N";
                } // end of false
            }     // end of try
            catch (Exception e)
            {
                lblMessage.Text = "Must have an employee selected";
            } // end of catch
              //txtBxIns.Text = aFullTime.Insured.ToString();
        }     // end of loadText
 /// <summary>
 /// populated text box fields upon selected item in the list box
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void lstBxFullTime_SelectedIndexChanged(object sender, EventArgs e)
 {
     selectedItem        = lstBxFullTime.SelectedIndex;
     aFullTime           = (FullTime)lstBxFullTime.Items[selectedItem]; // cast the items
     txtBxID.Text        = aFullTime.EmployeeId.ToString();
     txtBxFName.Text     = aFullTime.FirstName;
     txtBxLName.Text     = aFullTime.LastName;
     txtBxDateHired.Text = aFullTime.DateHired.ToString();
     txtBxSsn.Text       = aFullTime.Ssn;
     txtBxEmail.Text     = aFullTime.Email;
     txtBxPhone.Text     = aFullTime.Phone;
     txtBxTaxRate.Text   = aFullTime.TaxRate.ToString();
     txtBxSalary.Text    = aFullTime.Salary.ToString();
     txtBxVac.Text       = aFullTime.NumOfVacationDays.ToString();
     txtBxSick.Text      = aFullTime.SickDays.ToString();
     txtBxTax.Text       = aFullTime.IsTaxExempt.ToString();
     txtBxInsure.Text    = aFullTime.HasInsurance.ToString();
 }
        public static List <FullTime> SelectAll()
        {
            var        FTEmployees     = new List <FullTime>();
            string     selectStatement = "SELECT * FROM Employees LEFT JOIN FullTime ON Employees.employeeID = FullTime.employeeID; ";
            SqlCommand sql             = new SqlCommand(selectStatement, myConnection);

            try
            {
                Connect();
                SqlDataReader reader = sql.ExecuteReader();

                while (reader.Read())
                {
                    var fullTimeEmployee = new FullTime
                    {
                        EmployeeID   = Convert.ToInt32(reader["employeeID"]),
                        FName        = reader["firstName"].ToString(),
                        LName        = reader["lastName"].ToString(),
                        HireDate     = Convert.ToDateTime(reader["hireDate"]),
                        Social       = Convert.ToInt32(reader["SSN"]),
                        Email        = reader["email"].ToString(),
                        PhoneNumber  = Convert.ToInt32(reader["phone"]),
                        TaxRate      = Convert.ToDecimal(reader["taxRate"]),
                        Salary       = Convert.ToDecimal(reader["salary"]),
                        VacationDays = Convert.ToDecimal(reader["vacationDays"]),
                        HasInsurance = Convert.ToBoolean(reader["hasInsurance"]),
                        TaxExempt    = Convert.ToBoolean(reader["taxExempt"]),
                        SickDays     = Convert.ToDecimal(reader["sickDays"])
                    };

                    FTEmployees.Add(fullTimeEmployee);
                    Status = "Connected - Full Time Employee List Loaded";
                }
                reader.Close();
            }
            catch (Exception e)
            {
                Status = e.Message;
            }
            return(FTEmployees);
        }
Example #18
0
        }// Emd pf Insert

        public static void Update(FullTime data)
        {
            string sqlIns   = $"UPDATE Employee SET FirstName = @FirstName , DateHired = @DateHired, SSN = @SSN, Email = @Email, Phone = @Phone, TaxRate = @TaxRate WHERE ID = @condition; ";
            string sqlIns_1 = $"UPDATE  FullTime SET Salary=@Salary, NumOfVacationDays= @NumOfVacationDays, HasUInsurance= @HasUInsurance,TaxExempt= @TaxExempt,NumOfSickDays= @NumOfSickDays) WHERE ID = @condition; ";

            try
            {
                Connect();

                SqlCommand cmdIns = new SqlCommand(sqlIns, oConn);

                cmdIns.Parameters.AddWithValue("@FirstName", data.FirstNanme);
                cmdIns.Parameters.AddWithValue("@LastName", data.LastName);
                cmdIns.Parameters.AddWithValue("@DateHired", data.DateHired);
                cmdIns.Parameters.AddWithValue("@SSN", data.SSN);
                cmdIns.Parameters.AddWithValue("@Email", data.Email);
                cmdIns.Parameters.AddWithValue("@Phone", data.Phone);
                cmdIns.Parameters.AddWithValue("@TaxRate", data.TaxRate);
                cmdIns.Parameters.AddWithValue("@condition", data.ID);
                cmdIns.ExecuteNonQuery();

                SqlCommand cmdIns_1 = new SqlCommand(sqlIns_1, oConn);

                cmdIns_1.Parameters.AddWithValue("@Salary", data.Salary);
                cmdIns_1.Parameters.AddWithValue("@NumOfVacationDays", data.NumOfVacationDays);
                cmdIns_1.Parameters.AddWithValue("@HasUInsurance", data.HasInsurance);
                cmdIns_1.Parameters.AddWithValue("@TaxExempt", data.TaxExempt);
                cmdIns_1.Parameters.AddWithValue("@NumOfSickDays", data.NumOfSickDays);
                cmdIns.Parameters.AddWithValue("@condition", data.ID);
                cmdIns_1.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Disconnect();
            }
        }// End of Update
Example #19
0
        public static void Insert(FullTime data)
        {
            string sqlIns   = $"INSERT INTO Employee(ID, FirstName, LastName, DateHired, SSN, Email, Phone,TaxRate) VALUES(@ID, @FirstName, @LastName, @DateHired, @SSN, @Email, @Phone,@TaxRate);";
            string sqlIns_1 = $"INSERT INTO FullTime(ID, Salary, NumOfVacationDays, HasUInsurance, TaxExempt, NumOfSickDays) VALUES(@ID, @Salary, @NumOfVacationDays, @HasUInsurance, @TaxExempt, @NumOfSickDays);";

            try
            {
                Connect();

                SqlCommand cmdIns = new SqlCommand(sqlIns, oConn);
                cmdIns.Parameters.AddWithValue("@ID", data.ID);
                cmdIns.Parameters.AddWithValue("@FirstName", data.FirstNanme);
                cmdIns.Parameters.AddWithValue("@LastName", data.LastName);
                cmdIns.Parameters.AddWithValue("@DateHired", data.DateHired);
                cmdIns.Parameters.AddWithValue("@SSN", data.SSN);
                cmdIns.Parameters.AddWithValue("@Email", data.Email);
                cmdIns.Parameters.AddWithValue("@Phone", data.Phone);
                cmdIns.Parameters.AddWithValue("@TaxRate", data.TaxRate);
                cmdIns.ExecuteNonQuery();

                SqlCommand cmdIns_1 = new SqlCommand(sqlIns_1, oConn);
                cmdIns_1.Parameters.AddWithValue("@ID", data.ID);
                cmdIns_1.Parameters.AddWithValue("@Salary", data.Salary);
                cmdIns_1.Parameters.AddWithValue("@NumOfVacationDays", data.NumOfVacationDays);
                cmdIns_1.Parameters.AddWithValue("@HasUInsurance", data.HasInsurance);
                cmdIns_1.Parameters.AddWithValue("@TaxExempt", data.TaxExempt);
                cmdIns_1.Parameters.AddWithValue("@NumOfSickDays", data.NumOfSickDays);
                cmdIns_1.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Disconnect();
            }
        }// Emd pf Insert
Example #20
0
        /// <summary>
        /// Get all full time employee and stores it into a instance passing the data unto a constructor on the full time employee
        /// Then the instance is added in to a Collection of ArrayList
        /// </summary>
        /// <returns>memarray</returns>

        public static ArrayList getAllFullTime()
        {
            Connect();

            dbReader = getFullTime();

            ArrayList memArray = new ArrayList();

            while (dbReader.Read())
            {
                //aFulltime = new FullTime(
                //    Convert.ToDecimal(dbReader["Salary"]),
                //    Convert.ToDouble(dbReader["NumOfVacationDays"]));
                //Convert.ToBoolean(dbReader["TaxExempt"]),
                //    Convert.ToBoolean(dbReader["HasInsurance"]));
                aFulltime = new FullTime(
                    dbReader["FirstName"].ToString(),
                    dbReader["LastName"].ToString(),
                    Convert.ToDateTime(dbReader["DateHired"]),
                    dbReader["SSN"].ToString(),
                    dbReader["Email"].ToString(),
                    dbReader["Phone"].ToString(),
                    Convert.ToDecimal(dbReader["TaxRate"]),
                    Convert.ToInt32(dbReader["EmployeeId"]),
                    Convert.ToDecimal(dbReader["Salary"]),
                    Convert.ToDouble(dbReader["NumOfVacationDays"]),
                    Convert.ToDouble(dbReader["SickDays"]),
                    Convert.ToBoolean(dbReader["TaxExempt"]),
                    Convert.ToBoolean(dbReader["HasInsurance"]));


                memArray.Add(aFulltime); // the instance in to the ArrayList
            }
            Disconnect();
            return(memArray);
        }
Example #21
0
        } // end of add

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (selected == -1)
            {
                //anEmployee = new Employee(txtBxEmpID.Text, txtBxFName.Text, txtBxLName.Text, txtBxDOH.Text, txtBxSSN.Text, txtBxMail.Text, txtBxPhNum.Text, txtBxTaxRate.Text);

                aFullTime = new FullTime(txtBxEmpID.Text, txtBxFName.Text,
                                         txtBxLName.Text, txtBxDOH.Text, txtBxSSN.Text,
                                         txtBxMail.Text, txtBxPhNum.Text, txtBxTaxRate.Text,
                                         txtBxSal.Text, txtBxVacDay.Text, txtBxSick.Text,
                                         txtBxTax.Text, txtBxIns.Text);
                aFullTime.InsertFullTimeEmp();
                lblMessage.Text = "FullTimer Added";

                LoadItems();
                EnableDisable(false);
                ClearText();
            }  // end of if
            else
            {
                //aFullTime = (FullTime)lstBxFullTime.Items[selected];
                aFullTime.FirstName = txtBxFName.Text;
                aFullTime.LastName  = txtBxLName.Text;
                aFullTime.Doh       = DateTime.Parse(txtBxDOH.Text);
                aFullTime.Ssn       = txtBxSSN.Text;
                aFullTime.EMail     = txtBxMail.Text;
                aFullTime.PhoneNum  = txtBxPhNum.Text;
                //if (txtBxTaxRate.Text = "")
                //{
                //    string taxRate = "0.0";
                //    aFullTime.TaxRate = decimal.Parse(taxRate);
                //} // end of if
                aFullTime.TaxRate  = decimal.Parse(txtBxTaxRate.Text);
                aFullTime.Salary   = decimal.Parse(txtBxSal.Text);
                aFullTime.VacDays  = Convert.ToDouble(txtBxVacDay.Text);
                aFullTime.SickDays = Convert.ToDouble(txtBxSick.Text);
                if (txtBxTax.Text == "Y")
                {
                    aFullTime.TaxExempt = true;
                } // end of true
                else
                {
                    aFullTime.TaxExempt = false;
                } // end of false
                //aFullTime.TaxExempt = Boolean.Parse(txtBxTax.Text);
                if (txtBxIns.Text == "Y")
                {
                    aFullTime.Insured = true;
                } // end of true
                else
                {
                    aFullTime.Insured = false;
                } // end of false
                //aFullTime.Insured = Boolean.Parse(txtBxIns.Text);
                aFullTime.UpdateEmployee();
                lblMessage.Text = "Employee Updated";
                LoadItems();
                EnableDisable(false);
                ClearText();
            } // end of else
        }     // end of btnOK-Click
Example #22
0
        }//End of Delete

        /// <summary>
        /// Purpose: Connect to database and add objects of data
        /// </summary>
        /// <returns></returns>
        public static ArrayList Get()
        {
            string sql = "SELECT * FROM Employee LEFT JOIN FullTime ON Employee.ID = FullTime.ID; ";

            string[,] FulltimeStrArray = new string[99, 14];



            SqlCommand cmd = new SqlCommand(sql, oConn);

            try
            {
                //  Form1 frm1 = new Form1();
                Connect();

                SqlDataReader reader = cmd.ExecuteReader();
                Console.WriteLine("asdasdsad");

                //while (reader.Read())
                //{
                //    //while we are getting records from the DB
                //    Serializer.DeSerializeNow(reader["Data"].ToString());
                //}
                // for (int j = 0; j <= FulltimeStrArray.Length; j++)
                {
                    int j = 0;
                    while (reader.Read())
                    {
                        //FullTime item = new FullTime(reader);

                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            FulltimeStrArray[j, i] = reader.GetValue(i).ToString();
                        }
                        FullTime aFulltime = new FullTime();
                        aFulltime.ID                = Convert.ToInt32(FulltimeStrArray[j, 0]);
                        aFulltime.FirstNanme        = FulltimeStrArray[j, 1];
                        aFulltime.LastName          = FulltimeStrArray[j, 2];
                        aFulltime.DateHired         = Convert.ToDateTime(FulltimeStrArray[j, 3]);
                        aFulltime.SSN               = FulltimeStrArray[j, 4];
                        aFulltime.Email             = FulltimeStrArray[j, 5];
                        aFulltime.Phone             = FulltimeStrArray[j, 6];
                        aFulltime.TaxRate           = Convert.ToDecimal(FulltimeStrArray[j, 7]);
                        aFulltime.ID                = Convert.ToInt32(FulltimeStrArray[j, 8]);
                        aFulltime.Salary            = Convert.ToDecimal(FulltimeStrArray[j, 9]);
                        aFulltime.NumOfVacationDays = Convert.ToInt32(FulltimeStrArray[j, 10]);
                        aFulltime.HasInsurance      = FulltimeStrArray[j, 11];
                        aFulltime.TaxExempt         = FulltimeStrArray[j, 12];
                        aFulltime.NumOfSickDays     = Convert.ToInt32(FulltimeStrArray[j, 13]);

                        FullTimeEmployees.Add(aFulltime);
                        j++;
                        Console.WriteLine(FullTimeEmployees.Count);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Disconnect();
            }
            return(FullTimeEmployees);
        } // End of get