/// <summary> /// 新增排班计划班次数据。 /// </summary> /// <param name="dsParams">包含排班计划班次数据的数据集对象。</param> /// <returns>包含执行结果的数据集对象。</returns> public DataSet AddShift(DataSet dsParams) { DataSet dsReturn = new DataSet(); DbConnection dbConn = null; DbTransaction dbTran = null; string sqlCommand = ""; if (null != dsParams && dsParams.Tables.Contains(CAL_SHIFT.DATABASE_TABLE_NAME)) { try { dbConn = db.CreateConnection(); dbConn.Open(); //Create Transaction dbTran = dbConn.BeginTransaction(); DataTable dtParams = dsParams.Tables[CAL_SHIFT.DATABASE_TABLE_NAME]; //创建cal_shift对应的对象 CAL_SHIFT shiftFields = new CAL_SHIFT(); string shiftKey = dtParams.Rows[0][CAL_SHIFT.FIELD_SHIFT_KEY].ToString(); string scheduleKey = dtParams.Rows[0][CAL_SCHEDULE.FIELD_SCHEDULE_KEY].ToString(); sqlCommand = DatabaseTable.BuildInsertSqlStatement(shiftFields, dtParams, 0, new Dictionary <string, string>() { { CAL_SHIFT.FIELD_CREATE_TIME, null }, { CAL_SHIFT.FIELD_EDIT_TIME, null } }, new List <string>() { CAL_SCHEDULE.FIELD_SCHEDULE_KEY } ); db.ExecuteNonQuery(dbTran, CommandType.Text, sqlCommand); sqlCommand = string.Format(@"INSERT INTO CAL_SCHEDULE_SHIFT(SCHEDULE_KEY,SHIFT_KEY) VALUES('{0}','{1}')", scheduleKey.PreventSQLInjection(), shiftKey.PreventSQLInjection()); db.ExecuteNonQuery(dbTran, CommandType.Text, sqlCommand); dbTran.Commit(); } catch (Exception ex) { dbTran.Rollback(); FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(dsReturn, ex.Message); LogService.LogError("AddShift Error: " + ex.Message); } finally { dbTran.Dispose(); dbConn.Close(); dbConn.Dispose(); } } else { FanHai.Hemera.Share.Common.ReturnMessageUtils.AddServerReturnMessage(dsReturn, "${res:FanHai.Hemera.Modules.EMS.CalShiftEngine.TableIsNotExist}"); } return(dsReturn); }
public override bool Insert() { DataSet dataSet = new DataSet(); DataTable shiftTable = CAL_SHIFT.CreateDataTable(); //准备插入到数据库中的数据。 modi by chao.pang Dictionary <string, string> dataRow = new Dictionary <string, string>() { { CAL_SHIFT.FIELD_SHIFT_KEY, _shiftKey }, { CAL_SHIFT.FIELD_SHIFT_NAME, _shiftName }, { CAL_SHIFT.FIELD_DESCRIPTIONS, _descriptions }, { CAL_SHIFT.FIELD_START_TIME, _starTime }, { CAL_SHIFT.FIELD_END_TIME, _endTime }, { CAL_SHIFT.FIELD_OVER_DAY, _overDay }, { CAL_SHIFT.FIELD_CREATOR, Creator }, { CAL_SHIFT.FIELD_CREATE_TIMEZONE, CreateTimeZone }, { CAL_SHIFT.FIELD_EDITOR, Creator }, { CAL_SHIFT.FIELD_EDIT_TIMEZONE, CreateTimeZone }, { CAL_SCHEDULE.FIELD_SCHEDULE_KEY, _scheduleKey } }; FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref shiftTable, dataRow); //为远程调用函数准备参数。 modi by chao.Pang dataSet.Tables.Add(shiftTable); try { DataSet dsReturn = null; IServerObjFactory serverFactory = CallRemotingService.GetRemoteObject(); if (null != serverFactory) { //远程调用进行添加操作 modi by chao.pang dsReturn = serverFactory.CreateIShift().AddShift(dataSet); _errorMsg = FanHai.Hemera.Share.Common.ReturnMessageUtils.GetServerReturnMessage(dsReturn); if (_errorMsg != "") { return(false); } else { this.ResetDirtyList(); } } } catch (Exception ex) { _errorMsg = ex.Message; } finally { CallRemotingService.UnregisterChannel(); } return(true); }