Ejemplo n.º 1
0
 /// <summary>
 /// 点击添加按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         CheckValid();
         Salary newsalary = new Salary();
         newsalary.Id          = Convert.ToInt32(txtBoxId.Text);
         newsalary.Pre_sal     = Convert.ToInt32(txtBoxPre_sal.Text);
         newsalary.Current_sal = Convert.ToInt32(txtBoxCurrent_sal.Text);
         salaryBLL.AddSalary(newsalary);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "添加用户时出错");
     }
     this.Close();
 }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtYear.Text.Trim() == "")
            {
                MessageBox.Show("year is empty");
            }
            else if (txtSalary.Text.Trim() == "")
            {
                MessageBox.Show("Salary is empty");
            }
            else if (cmbMonth.SelectedIndex == -1)
            {
                MessageBox.Show("Select a month");
            }
            else
            {
                bool control = false;
                if (!isUpdate)
                {
                    if (salary.EmployeeID == 0)
                    {
                        MessageBox.Show("please select an employee from table");
                    }
                    else
                    {
                        salary.Year    = Convert.ToInt32(txtYear.Text);
                        salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue);
                        salary.Amount  = Convert.ToInt32(txtSalary.Text);
                        if (salary.Amount > oldsalary)
                        {
                            control = true;
                        }
                        SalaryBLL.AddSalary(salary, control);
                        MessageBox.Show("Salary was added");
                        cmbMonth.SelectedIndex = -1;
                        salary = new SALARY();
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        SALARY salary = new SALARY();
                        salary.ID         = detail.SalaryID;
                        salary.EmployeeID = detail.EmployeeID;
                        salary.Year       = Convert.ToInt32(txtYear.Text);
                        salary.MonthID    = Convert.ToInt32(cmbMonth.SelectedValue);
                        salary.Amount     = Convert.ToInt32(txtSalary.Text);

                        if (salary.Amount > detail.oldSalary)
                        {
                            control = true;
                        }
                        SalaryBLL.UpdateSalary(salary, control);
                        MessageBox.Show("Salary was Uptaded");
                        this.Close();
                    }
                }
            }
        }
Ejemplo n.º 3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtYear.Text.Trim() == "")
     {
         MessageBox.Show("Please fill the year");
     }
     else if (cmbMonth.SelectedIndex == -1)
     {
         MessageBox.Show("Please select month");
     }
     else if (txtSalary.Text.Trim() == "")
     {
         MessageBox.Show("Please fill the salary");
     }
     else if (txtUserNo.Text.Trim() == "")
     {
         MessageBox.Show("Please select the employee");
     }
     else
     {
         bool control = false;
         if (!isUpdated)
         {
             if (salary.EmployeeID == 0)
             {
                 MessageBox.Show("Please select the employee from the table");
             }
             else
             {
                 salary.Year    = Convert.ToInt32(txtYear.Text);
                 salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue);
                 salary.Amount  = Convert.ToInt32(txtSalary.Text);
                 if (salary.Amount > oldSalary)
                 {
                     control = true;
                 }
                 SalaryBLL.AddSalary(salary, control);
                 MessageBox.Show("Salary added!");
                 cmbMonth.SelectedIndex = -1;
                 salary = new SALARY();
             }
         }
         else
         {
             DialogResult dialogResult = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 SALARY salary = new SALARY();
                 salary.ID         = detail.SalaryID;
                 salary.EmployeeID = detail.EmployeeID;
                 salary.Year       = Convert.ToInt32(txtYear.Text);
                 salary.MonthID    = Convert.ToInt32(cmbMonth.SelectedValue);
                 salary.Amount     = Convert.ToInt32(txtSalary.Text);
                 if (salary.Amount > detail.OldSalary)
                 {
                     control = true;
                 }
                 SalaryBLL.UpdateSalary(salary, control);
                 MessageBox.Show("Salary updated!");
                 this.Close();
             }
         }
     }
 }
Ejemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtYear.Text.Trim() == "")
            {
                MessageBox.Show("Year is empty");
            }
            else if (cmbMonth.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a Month");
            }
            else if (txtSalary.Text.Trim() == "")
            {
                MessageBox.Show("Salary is empty");
            }
            else if (txtUserNo.Text.Trim() == "")
            {
                MessageBox.Show("User number is empty");
            }
            else
            {
                //Guardando el salario maximo del empleado
                bool control = false;
                if (!isUpdate)
                {
                    if (salary.EmployeeID == 0)
                    {
                        MessageBox.Show("Select an Employee");
                    }
                    else
                    {
                        salary.Year    = Convert.ToInt32(txtYear.Text);
                        salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue);
                        salary.Amount  = Convert.ToInt32(txtSalary.Text);
                        if (salary.Amount > oldsalary)
                        {
                            control = true;
                        }
                        SalaryBLL.AddSalary(salary, control);
                        MessageBox.Show("Salary Added");
                        cmbMonth.SelectedIndex = -1;
                        salary = new Salary();
                    }
                }
                else
                {
                    DialogResult result = MessageBox.Show("Are you sure", "Warning", MessageBoxButtons.YesNo);
                    if (DialogResult.Yes == result)
                    {
                        Salary salary = new Salary();
                        salary.ID         = detail.SalaryID;
                        salary.EmployeeID = detail.EmployeeID;
                        salary.Year       = Convert.ToInt32(txtYear.Text);
                        salary.MonthID    = Convert.ToInt32(cmbMonth.SelectedValue);
                        salary.Amount     = Convert.ToInt32(txtSalary.Text);


                        if (salary.Amount > detail.OldSalary)
                        {
                            control = true;
                        }
                        SalaryBLL.UpdateSalary(salary, control);
                        MessageBox.Show("Salary Updated");
                        this.Close();
                    }
                }
            }
        }