/// <summary> /// 绑定下拉筐数据 /// </summary> private void BindItemDetails() { DataTable dataTable = new DataTable(BaseItemDetailsEntity.TableName); dataTable = DotNetService.Instance.ItemDetailsService.GetDataTableByCode(UserInfo, "OrganizeCategory"); // 添加一个空记录 DataRow dataRow = dataTable.NewRow(); dataTable.Rows.InsertAt(dataRow, 0); // 绑定数据 this.cmbCategory.DisplayMember = BaseItemDetailsEntity.FieldItemName; this.cmbCategory.ValueMember = BaseItemDetailsEntity.FieldItemCode; // this.cmbCategory.ValueMember = BaseItemDetailsEntity.FieldId; this.cmbCategory.DataSource = dataTable.DefaultView; // 判断这个下拉框的值是否存在 if (BaseBusinessLogic.Exists(dataTable, BaseItemDetailsEntity.FieldItemCode, "Department")) { this.cmbCategory.SelectedValue = "Department"; } }
/// <summary> /// 获取退回人员列表 /// </summary> /// <param name="entity"></param> /// <returns></returns> public DataTable GetBackToDT(BaseWorkFlowCurrentEntity entity) { string processId = entity.ProcessId.ToString(); string sortCode = entity.SortCode.ToString(); string sqlQuery = @" SELECT MAX(Id) AS Id, ActivityId, AuditUserId, AuditUserRealName FROM BaseWorkFlowHistory WHERE ( AuditStatus != 'AuditReject' AND CurrentFlowId = '" + entity.Id + @"' AND ProcessId = " + processId + @" -- AND AuditUserId = ToUserId AND ActivityId IN ( SELECT Id FROM BaseWorkFlowActivity WHERE (DeletionStateCode = 0) AND (Enabled = 1) AND (ProcessId = " + processId + @") AND (SortCode < " + sortCode + @") ) ) GROUP BY ActivityId, AuditUserId, AuditUserRealName ORDER BY MAX(SortCode) " ; // 发出人是否在单据里? var dt = DbHelper.Fill(sqlQuery); dt.TableName = "BaseWorkFlowHistory"; if (!BaseBusinessLogic.Exists(dt, "AuditUserId", entity.CreateUserId)) { DataRow dr = dt.NewRow(); dr["Id"] = DBNull.Value; dr["ActivityId"] = DBNull.Value; dr["AuditUserId"] = entity.CreateUserId; dr["AuditUserRealName"] = entity.CreateBy; dt.Rows.InsertAt(dr, 0); dt.AcceptChanges(); } return(dt); }
/// <summary> /// 从Excel文件导入(角色) /// </summary> /// <param name="filePath"></param> /// <returns></returns> private bool DoImport(string filePath) { bool returnValue = false; // 鼠标忙碌状态 this.Cursor = Cursors.WaitCursor; try { //将Excel表转换为DataTable string error = ""; DataTable dataTable = new DataTable(); AsposeExcelTools.ExcelFileToDataTable(filePath, out dataTable, out error); //检查Excell转为DataTable是否成功 if (error != "") { MessageBox.Show(error, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } //是否有记录 if (dataTable.Rows.Count > 0) { //将第一行数据给数据列置名称,以便于识别和调用数据。 int columnsCount = 0; for (columnsCount = 0; columnsCount < dataTable.Columns.Count; columnsCount++) { dataTable.Columns[columnsCount].ColumnName = dataTable.Rows[0][columnsCount].ToString().Trim(); } //循环处理每行数据 int rowsCount = 0; int errorCount = 0; BaseRoleEntity tempentity; string statusCode = string.Empty; string statusMessage = string.Empty; DataTable dt = DotNetService.Instance.RoleService.GetDataTable(UserInfo); for (rowsCount = 1; rowsCount < dataTable.Rows.Count; rowsCount++) { //角色名称不允许导入重复项 bool exists = BaseBusinessLogic.Exists(dt, BaseRoleEntity.FieldRealName, dataTable.Rows[rowsCount][BaseRoleEntity.FieldRealName].ToString()); if (!exists) { //清空实体 tempentity = new BaseRoleEntity(); //给实体赋值 tempentity.RealName = dataTable.Rows[rowsCount][BaseRoleEntity.FieldRealName].ToString(); tempentity.Code = dataTable.Rows[rowsCount][BaseRoleEntity.FieldCode].ToString(); tempentity.Description = dataTable.Rows[rowsCount][BaseRoleEntity.FieldDescription].ToString(); tempentity.Enabled = int.Parse(dataTable.Rows[rowsCount][BaseRoleEntity.FieldEnabled].ToString()); tempentity.CategoryCode = dataTable.Rows[rowsCount][BaseRoleEntity.FieldCategoryCode].ToString(); tempentity.AllowDelete = 1; tempentity.AllowEdit = 1; tempentity.DeletionStateCode = 0; tempentity.IsVisible = 1; DotNetService.Instance.RoleService.Add(UserInfo, tempentity, out statusCode, out statusMessage); } else { errorCount++; } } this.Changed = true; returnValue = true; MessageBox.Show("共有" + (dataTable.Rows.Count - 1) + "条记录," + (dataTable.Rows.Count - 1 - errorCount).ToString() + "条记录被成功导入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { this.ProcessException(ex); } finally { // 设置鼠标默认状态 this.Cursor = Cursors.Default; } return(returnValue); }
/// <summary> /// 获取用户每月考勤信息 /// </summary> /// <param name="userId"></param> /// <param name="yearMonth"></param> /// <param name="blank"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public DataTable GetUserMonthCheckIn(string userId, string yearMonth, bool blank = true, string startTime = "", string endTime = "") { // string commandText = @"SELECT Id, CompanyId, CompanyName,DepartmentId, DepartmentName, UserId, UserName, CheckInDay // , CONVERT(varchar(5), AMStartTime, 108) as AMStartTime // , AMStartIp // , CONVERT(varchar(5), AMEndTime, 108) as AMEndTime // , AMEndIp // , CONVERT(varchar(5), PMStartTime, 108) as PMStartTime // , PMStartIp // , CONVERT(varchar(5), PMEndTime, 108) as PMEndTime // , PMEndIp // , CONVERT(varchar(5), NightStartTime, 108) as NightStartTime // , NightStartIp // , CONVERT(varchar(5), NightEndTime, 108) as NightEndTime // , NightEndIp // , Description // FROM " + this.CurrentTableName // + " WHERE UserId = '" + userId + "' AND CheckInDay LIKE '" + yearMonth + "%'" // + " ORDER BY CheckInDay"; string commandText = @"SELECT Id, CompanyId, CompanyName,DepartmentId, DepartmentName, UserId, UserName, CheckInDay , TO_CHAR(AMStartTime, 'hh24:mi') AMSTARTTIME , AMStartIp , TO_CHAR(AMEndTime, 'hh24:mi') AMENDTIME , AMEndIp , TO_CHAR(PMStartTime, 'hh24:mi') PMSTARTTIME , PMStartIp , TO_CHAR(PMEndTime, 'hh24:mi') PMENDTIME , PMEndIp , TO_CHAR(NightStartTime, 'hh24:mi') NIGHTSTARTTIME , NightStartIp , TO_CHAR(NightEndTime, 'hh24:mi') NIGHTENDTIME , NightEndIp , Description FROM " + this.CurrentTableName + " WHERE UserId = '" + userId + "' AND CheckInDay LIKE '" + yearMonth + "%'"; if (!string.IsNullOrEmpty(startTime)) { commandText += "AND to_date(CheckInDay,'yyyy-mm-dd') " + " BETWEEN TO_DATE('" + startTime + "','yyyy-mm-dd')" + " AND TO_DATE('" + endTime + "','yyyy-mm-dd')"; } commandText += " ORDER BY CheckInDay"; DataTable result = this.DbHelper.Fill(commandText); result.TableName = this.CurrentTableName; result.Columns.Add("Week"); if (blank) { DateTime dtStart = new DateTime(int.Parse(yearMonth.Substring(0, 4)), int.Parse(yearMonth.Substring(5, 2)), 1); DateTime dtEnd = dtStart; while (dtEnd.Month == dtStart.Month) { string day = dtEnd.ToString(BaseSystemInfo.DateFormat); if (!BaseBusinessLogic.Exists(result, "CheckInDay", day)) { if (!string.IsNullOrEmpty(startTime)) { DateTime startDateTime = DateTime.Parse(startTime); DateTime endDateTime = DateTime.Parse(endTime); if (endDateTime >= dtEnd && dtEnd >= startDateTime) { DataRow dr = result.NewRow(); dr["CheckInDay"] = day; result.Rows.Add(dr); } } else { DataRow dr = result.NewRow(); dr["CheckInDay"] = day; result.Rows.Add(dr); } } dtEnd = dtEnd.AddDays(1); } foreach (DataRow dr in result.Rows) { dtEnd = DateTime.Parse(dr["CheckInDay"].ToString()); dr["Week"] = DateUtil.GetDayOfWeek(dtEnd.DayOfWeek.ToString(), true).ToString(); } result.DefaultView.Sort = "CheckInDay"; result.AcceptChanges(); } return(result); }