//TODO: FUTURO... #endregion #region [ Métodos para Persistência do objeto no banco de dados ] /// <summary> /// Insere o objeto no banco de dados /// </summary> /// <param name="pDto"></param> /// <param name="pReturnIdentity"></param> /// <returns></returns> public object Insert(TDto pDto, bool pReturnIdentity = false) { DBExecution _execution = DBExecution.NewConstructor(); DBParameter _parameter = DBParameter.NewConstructor(); try { this.FillParameters(ref pDto, ref _parameter, ExecutionTypes.Insert); if (pReturnIdentity) { return(_execution.ExecuteScalar(_parameter.Parameter, System.Data.CommandType.StoredProcedure, this.CommandInsert)); } else { return(_execution.ExecuteNonQuery(_parameter.Parameter, System.Data.CommandType.StoredProcedure, this.CommandInsert)); } } catch (Exception ex) { if (ex is Exception) { throw; } else { throw new Exception(this.ErrorMessageInsert); } } finally { _execution.Dispose(); } }
public int InsertUserInfo(User user) { int res = 0; NpgsqlParameter param_user_name = new NpgsqlParameter("@param_user_name", NpgsqlTypes.NpgsqlDbType.Text); param_user_name.Value = user.user_name; NpgsqlParameter param_password = new NpgsqlParameter("@param_password", NpgsqlTypes.NpgsqlDbType.Text); param_password.Value = user.password; NpgsqlParameter param_role = new NpgsqlParameter("@param_role", NpgsqlTypes.NpgsqlDbType.Text); param_role.Value = user.role; NpgsqlParameter param_display_name = new NpgsqlParameter("@param_display_name", NpgsqlTypes.NpgsqlDbType.Text); param_display_name.Value = user.display_name; res = cmd.ExecuteScalar(DBConstant.InsertUser, new NpgsqlParameter[] { param_user_name, param_password, param_role, param_display_name }); return(res); }
public int SaveAllConfig(string xml) { int res = 0; NpgsqlParameter param = new NpgsqlParameter("@xmlData", NpgsqlTypes.NpgsqlDbType.Text); param.Value = xml; res = cmd.ExecuteScalar(DBConstant.UpdateAllConfig, new NpgsqlParameter[] { param }); return(res); }
public int SaveVerifyData(int management_id, int data_process_id, string add1, string add2, string add3, string add4, string user_name, string start_time, string end_time, double totaltime, string step, int data_id, string cleaning_address1, string cleaning_address2, string cleaning_address3, string cleaning_address4, string full_cleaning_address) { int res = 0; NpgsqlParameter param_data_process_id = new NpgsqlParameter("@data_process_id", NpgsqlTypes.NpgsqlDbType.Integer); param_data_process_id.Value = data_process_id; NpgsqlParameter param_management_id = new NpgsqlParameter("@management_id", NpgsqlTypes.NpgsqlDbType.Integer); param_management_id.Value = management_id; NpgsqlParameter param_add1 = new NpgsqlParameter("@address1", NpgsqlTypes.NpgsqlDbType.Text); param_add1.Value = add1; NpgsqlParameter param_add2 = new NpgsqlParameter("@address2", NpgsqlTypes.NpgsqlDbType.Text); param_add2.Value = add2; NpgsqlParameter param_add3 = new NpgsqlParameter("@address3", NpgsqlTypes.NpgsqlDbType.Text); param_add3.Value = add3; NpgsqlParameter param_add4 = new NpgsqlParameter("@address4", NpgsqlTypes.NpgsqlDbType.Text); param_add4.Value = add4; NpgsqlParameter param_user_name = new NpgsqlParameter("@user_name", NpgsqlTypes.NpgsqlDbType.Text); param_user_name.Value = user_name; NpgsqlParameter param_start_time = new NpgsqlParameter("@start_time", NpgsqlTypes.NpgsqlDbType.Text); param_start_time.Value = start_time; NpgsqlParameter param_end_time = new NpgsqlParameter("@end_time", NpgsqlTypes.NpgsqlDbType.Text); param_end_time.Value = end_time; NpgsqlParameter param_totaltime = new NpgsqlParameter("@totaltime", NpgsqlTypes.NpgsqlDbType.Double); param_totaltime.Value = totaltime; NpgsqlParameter param_step = new NpgsqlParameter("@step", NpgsqlTypes.NpgsqlDbType.Text); param_step.Value = step; NpgsqlParameter param_data_id = new NpgsqlParameter("@data_id", NpgsqlTypes.NpgsqlDbType.Integer); param_data_id.Value = data_id; NpgsqlParameter param_cleaning_add1 = new NpgsqlParameter("@cleaning_address1", NpgsqlTypes.NpgsqlDbType.Text); param_cleaning_add1.Value = cleaning_address1; NpgsqlParameter param_cleaning_add2 = new NpgsqlParameter("@cleaning_address2", NpgsqlTypes.NpgsqlDbType.Text); param_cleaning_add2.Value = cleaning_address2; NpgsqlParameter param_cleaning_add3 = new NpgsqlParameter("@cleaning_address3", NpgsqlTypes.NpgsqlDbType.Text); param_cleaning_add3.Value = cleaning_address3; NpgsqlParameter param_cleaning_add4 = new NpgsqlParameter("@cleaning_address4", NpgsqlTypes.NpgsqlDbType.Text); param_cleaning_add4.Value = cleaning_address4; NpgsqlParameter param_full_cleaning_add = new NpgsqlParameter("@full_cleaning_address", NpgsqlTypes.NpgsqlDbType.Text); param_full_cleaning_add.Value = full_cleaning_address; res = cmd.ExecuteScalar(DBConstant.SaveVerifyData, new NpgsqlParameter[] { param_management_id, param_data_process_id, param_add1, param_add2, param_add3, param_add4, param_user_name, param_start_time, param_end_time, param_totaltime, param_step, param_data_id, param_cleaning_add1, param_cleaning_add2, param_cleaning_add3, param_cleaning_add4, param_full_cleaning_add }); return(res); }