Ejemplo n.º 1
0
        /// <summary>
        /// 计算当前所有员工的最终工资并更新到数据库
        /// </summary>
        public void CalcAllUserCurrentSalaryAndUpdateDB()
        {
            RPBLL         rpBll    = new RPBLL();
            List <Salary> salaries = GetAllSalary();

            foreach (Salary sal in salaries)
            {
                UpdateCurrentSalaryById(sal.Id);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 删除一条奖罚记录
        /// hzy
        /// </summary>
        private void DeleteOneRP()
        {
            RP    rp    = (RP)UserGrid.SelectedItem;
            RPBLL rpBll = new RPBLL();

            if (!rpBll.DeleteRPByNo(rp.No))
            {
                MessageBox.Show("删除奖罚记录失败", "人事工资管理系统");
            }
            m_rps = rpBll.GetAllRP();
            ManagerBindingRP(rpBll.GetAllRP(), maxnum, 1);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 计算并修改指定员工id的最终工资
        /// 当某员工的奖金/罚金有变时应该调用此方法重新计算最终工资
        /// </summary>
        /// <param name="id"></param>
        public void UpdateCurrentSalaryById(int id)
        {
            Salary    sal   = GetsalaryByID(id);
            RPBLL     rpBll = new RPBLL();
            List <RP> rps   = rpBll.GetRPsByUserId(sal.Id);
            int       sum   = 0;

            if (rps != null)
            {
                foreach (RP rp in rps)
                {
                    sum += rp.Sal;
                }
            }
            sal.Current_sal = sal.Pre_sal + sum;
            Modifysalary(sal);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 搜索一条奖罚记录
 /// </summary>
 private void SearchRP()
 {
     if (combox_search.SelectedItem == null)
     {
         MessageBox.Show("请先选择查询条件");
         return;
     }
     if (txt_search.Text != "" && (combox_search.SelectedItem).ToString() != "")
     {
         RPBLL     rpBLL = new RPBLL();
         List <RP> rps   = new List <RP>();
         //按员工ID查询 索引从0开始 但是第0项是空字符串
         if (combox_search.SelectedIndex == 1)
         {
             if (!isInteger(txt_search.Text))
             {
                 MessageBox.Show("请输入数字");
                 txt_search.Text = "";
                 return;
             }
             int id = int.Parse(txt_search.Text);
             rps = rpBLL.GetRPsByUserId(id);
         }
         else
         {
             string name = txt_search.Text;
             rps = rpBLL.GetRPByRPName(name);
         }
         UserGrid.ItemsSource = rps;
         m_rps = rps;
         ManagerBindingRP(rps, maxnum, 1);
     }
     else
     {
         MessageBox.Show("查找方式和内容不能为空!");
     }
     txt_search.Text = "";
 }