Exemplo n.º 1
0
 /// <summary>
 /// Purpose: Dissconect to update data if a row is just deleted.
 // Recreate the FulltimeEmployee Arraylist
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDisconnect_Click(object sender, EventArgs e)
 {
     loaded = false;
     DataAdapter.Disconnect();
     listBox1.Items.Clear();
     DataAdapter.FullTimeEmployees.Clear();
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            int newInsurance = 0;
            int newTaxExempt = 0;

            if (addInsured.Checked == true)
            {
                newInsurance = 1;
            }
            if (addTaxExempt.Checked == true)
            {
                newTaxExempt = 1;
            }
            DataAdapter.InsertFullTime(
                addLname.Text,
                addFName.Text,
                DateTime.Now,
                Convert.ToInt32(addSocial.Text),
                addEmail.Text,
                Convert.ToInt32(addPhone.Text),
                Convert.ToDecimal(addTaxRate.Text),
                Convert.ToInt32(addEmpID.Text),
                Convert.ToInt32(addSalary.Text),
                Convert.ToInt32(addVacationDays.Text),
                newInsurance,
                newTaxExempt,
                Convert.ToInt32(addSickDays.Text)


                );
        }
Exemplo n.º 3
0
 /// <summary>
 /// Purpose: Delete from Database based on current ID  ==> Disconect ==> Clear Array ==> ReLoad Data and the list to From and array
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     // listBox1.Items.Clear();
     DataAdapter.Delete(Convert.ToInt16(txtBxID.Text));
     DataAdapter.Disconnect();
     loaded = false;
     listBox1.Items.Clear();
     DataAdapter.FullTimeEmployees.Clear();
     if (loaded == false)
     {
         txtBxID.Enabled         = false;
         txtBxEmployeeID.Enabled = false;
         btnAddnew.Enabled       = true;
         DataAdapter.Get();
         foreach (FullTime item in DataAdapter.FullTimeEmployees)
         {
             listBox1.Items.Add(item);
             loaded = true;
             //Console.WriteLine(item);
         }
     }
     else
     {
         MessageBox.Show("You already load the data");
     }
 }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            int          employeeID   = Convert.ToInt32(employeeIDtxtBox.Text);
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + nameTxtBox.Text + "?", "Delete?", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                DataAdapter.DeleteFullTime(employeeID);
            }
        }
Exemplo n.º 6
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;
                }
            }
        }
Exemplo n.º 7
0
 private void btnLoad_Click(object sender, EventArgs e)
 {
     if (loaded == false)
     {
         txtBxID.Enabled         = false;
         txtBxEmployeeID.Enabled = false;
         btnAddnew.Enabled       = true;
         DataAdapter.Get();
         foreach (FullTime item in DataAdapter.FullTimeEmployees)
         {
             listBox1.Items.Add(item);
             loaded = true;
             //Console.WriteLine(item);
         }
     }
     else
     {
         MessageBox.Show("You already load the data");
     }
 }
Exemplo n.º 8
0
 private void disconnectBtn_Click(object sender, EventArgs e)
 {
     DataAdapter.Disconnect();
     labelStatus.Text = DataAdapter.Status;
 }
Exemplo n.º 9
0
 private void button2_Click(object sender, EventArgs e)
 {
     listBoxFullTime.DataSource = DataAdapter.SelectAll();
     labelStatus.Text           = DataAdapter.Status;
 }