コード例 #1
0
        public void Build(int year, int month, Guid deptId)
        {
            //生成表头T_SalarySheet

            //查询部门的所有员工
            //foreach(员工 in 员工们)
            //{针对每个员工都生成一条T_SalarySheetItem}

            //生成的时候是先生成主表,再生成明细表。因为明细表需要主表的Id

            Guid sheetId = Guid.NewGuid();

            SqlHelper.ExecuteNonQuery(@"Insert into T_SalarySheet(Id,Year,Month,DepartmentId)
                    Values(@Id,@Year,@Month,@DepartmentId)",
                                      new SqlParameter("@Id", sheetId), new SqlParameter("@Year", year),
                                      new SqlParameter("@Month", month), new SqlParameter("@DepartmentId", deptId));

            Employee[] employees = new EmployeeDAL().ListByDepment(deptId);
            foreach (Employee employee in employees)
            {
                SqlHelper.ExecuteNonQuery(@"Insert into T_SalarySheetItem
                    (Id,SheetId,EmployeeId,Bonus,BaseSalary,Fine,Other)
                values(newid(),@SheetId,@EmployeeId,0,0,0,0)",
                                          new SqlParameter("@SheetId", sheetId),
                                          new SqlParameter("@EmployeeId", employee.Id));
            }
        }
コード例 #2
0
        public void Build(int year, int month, Guid deptId)
        {
            //生成表头T_SalarySheet

            //查询部门的所有员工
            //foreach(员工 in 员工们)
            //{针对每个员工都生成一条T_SalarySheetItem}

            //生成的时候是先生成主表,再生成明细表。因为明细表需要主表的Id

            Guid sheetId = Guid.NewGuid();
            SqlHelper.ExecuteNonQuery(@"Insert into T_SalarySheet(Id,Year,Month,DepartmentId)
                    Values(@Id,@Year,@Month,@DepartmentId)",
               new SqlParameter("@Id", sheetId), new SqlParameter("@Year", year),
               new SqlParameter("@Month", month), new SqlParameter("@DepartmentId", deptId));

            Employee[] employees = new EmployeeDAL().ListByDepment(deptId);
            foreach (Employee employee in employees)
            {
                SqlHelper.ExecuteNonQuery(@"Insert into T_SalarySheetItem
                    (Id,SheetId,EmployeeId,Bonus,BaseSalary,Fine,Other)
                values(newid(),@SheetId,@EmployeeId,0,0,0,0)",
                          new SqlParameter("@SheetId",sheetId),
                                new SqlParameter("@EmployeeId", employee.Id));
            }
        }
コード例 #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            LoginWindow win = new LoginWindow();
            if (win.ShowDialog() != true)
            {
                //退出程序
                Application.Current.Shutdown();
            }

            this.Title = new SettingDAL().GetValue("公司名称")+"人事管理系统";

            EmployeeDAL employeeDAL = new EmployeeDAL();
            Employee[] birthdayEmployees =
                employeeDAL.Search3DaysBirthDay();

            if (new SettingDAL().GetBoolValue("启用生日提醒"))
            {
                //检测一个月之内合同到期的员工
                if (birthdayEmployees.Length > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < birthdayEmployees.Length; i++)
                    {
                        sb.Append(birthdayEmployees[0].Name).Append(",");
                    }
                    sb.Append("三天之内过生日");
                    //MessageBox.Show(sb.ToString());
                    PopupWindow popupWin = new PopupWindow();
                    popupWin.Left = SystemParameters.WorkArea.Width - popupWin.Width;
                    popupWin.Top = SystemParameters.WorkArea.Height - popupWin.Height;
                    popupWin.Message = sb.ToString();
                    popupWin.Show();
                }
            }
        }
コード例 #4
0
        private void btnSearch_Click(object sender, RoutedEventArgs e)
        {
            List<string> whereList = new List<string>();
            List<SqlParameter> paramsList = new List<SqlParameter>();
            if (cbSearchByName.IsChecked==true)
            {
                whereList.Add("Name=@Name");
                paramsList.Add(new SqlParameter("@Name",txtName.Text));
            }
            if (cbSearchByInDate.IsChecked == true)
            {
                whereList.Add("InDate>=@InDateStart and InDate<=@InDateEnd");
                paramsList.Add(new SqlParameter("@InDateStart",dpInDateStart.SelectedDate));
                paramsList.Add(new SqlParameter("@InDateEnd", dpInDateEnd.SelectedDate));
            }
            if (cbSearchByDept.IsChecked == true)
            {
                whereList.Add("DepartmentId=@DepartmentId");
                paramsList.Add(new SqlParameter("@DepartmentId",cmbDept.SelectedValue));
            }

            string whereSql = string.Join(" and ", whereList);
            string sql = "select * from T_Employee";
            if (whereSql.Length > 0)
            {
                sql = sql + " where " + whereSql;
            }
            Employee[] result = new EmployeeDAL().Search(sql, paramsList);
            datagrid.ItemsSource = result;
        }
コード例 #5
0
        private void Window_Loaded_1(object sender, RoutedEventArgs e)
        {
            IdNameDAL idNameDAL = new IdNameDAL();
            cbGender.ItemsSource = idNameDAL.GetByCategory("性别");
            cbMarriage.ItemsSource = idNameDAL.GetByCategory("婚姻状况");
            cbPartyStatus.ItemsSource = idNameDAL.GetByCategory("政治面貌");
            cbEducation.ItemsSource = idNameDAL.GetByCategory("学历");
            cbDepatment.ItemsSource = new DepartmentDAL().ListAll();

            if (IsAddNew)
            {
                Employee employee = new Employee();
                employee.InDate = DateTime.Today;//给默认值
                employee.ContractStartDay = DateTime.Today;
                employee.ContractEndDay = DateTime.Today.AddYears(1);
                employee.Nationality = "汉族";
                employee.Email = "@itcast.cn";
                //employee.Number = "YG";
                employee.Number = new SettingDAL().GetValue("员工工号前缀");
                gridEmployee.DataContext = employee;
            }
            else
            {
                Employee employee = new EmployeeDAL().GetById(EditingId);
                gridEmployee.DataContext = employee;

                if (employee.Photo != null)
                {
                    ShowImg(employee.Photo);
                }
            }
        }