/// <summary>
        /// 工资管理模块
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SalaryButton_Click(object sender, RoutedEventArgs e)
        {
            stateflag = 3;
            RemoveFieldColumns();
            pagename.Content = "工资管理";
            DataGridTextColumn dgtxtCol;

            string[] fields = { "id", "基本工资",    "最终工资",
                                "Id", "Pre_sal", "Current_sal" };
            for (int i = 0; i < 3; i++)
            {
                dgtxtCol         = new DataGridTextColumn();
                dgtxtCol.Header  = fields[i];
                dgtxtCol.Binding = new Binding(fields[i + 3]);
                UserGrid.Columns.Insert(1 + i, dgtxtCol);
            }

            //List<Salary> salarys = new List<Salary>();
            salaryList.Clear();
            Salary        salary    = new Salary();
            SalaryBLL     salaryBLL = new SalaryBLL();
            List <Salary> salary1   = salaryBLL.GetAllSalary();
            int           id        = 0;

            foreach (Salary item in salary1)
            {
                id     = item.Id;
                salary = salaryBLL.GetsalaryByID(id);
                RP        rP    = new RP();
                RPBLL     rpBll = new RPBLL();
                List <RP> rps   = rpBll.GetRPsByUserId(id);
                int       sum   = 0;
                if (rps != null)
                {
                    foreach (RP item1 in rps)
                    {
                        sum += item1.Sal;
                    }
                    salary.Current_sal = salary.Pre_sal + sum;
                    salaryBLL.Modifysalary(salary);
                }
                Salary salary2 = new Salary();
                salary2 = salaryBLL.GetsalaryByID(id);
                if (salary2 != null)
                {
                    salaryList.Add(salary2);
                }
            }
            UserGrid.ItemsSource = salaryList;
            sum = salaryList.Count;            //sum是记录总数
            SalaryBinding(maxnum, 1);
        }
Example #2
0
 /// <summary>
 /// 点击添加按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtnModifyAdd_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         CheckValid();
         Salary newsalary = new Salary();
         newsalary.Id          = Convert.ToInt32(txtBoxModifyId.Text);
         newsalary.Pre_sal     = Convert.ToInt32(txtBoxModifyPre_sal.Text);
         newsalary.Current_sal = Convert.ToInt32(txtBoxModifyCurrent_sal.Text);
         salaryBLL.Modifysalary(newsalary);
         MessageBox.Show("修改成功!");
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "添加用户时出错");
     }
     this.Close();
 }