public static Boolean checkTypeAndDocumentNumber(Int32 clientId, String typeDocument, Int32 documentNumber) { SqlCommand sp_client_check_exist_document = new SqlCommand(); sp_client_check_exist_document.CommandText = "PUNTO_ZIP.sp_client_check_exist_document"; sp_client_check_exist_document.Parameters.Add(new SqlParameter("@p_client_id", SqlDbType.Int)); sp_client_check_exist_document.Parameters["@p_client_id"].Value = clientId; sp_client_check_exist_document.Parameters.Add(new SqlParameter("@p_client_type_document", SqlDbType.VarChar, 255)); sp_client_check_exist_document.Parameters["@p_client_type_document"].Value = typeDocument; sp_client_check_exist_document.Parameters.Add(new SqlParameter("@p_client_document_number", SqlDbType.Int)); sp_client_check_exist_document.Parameters["@p_client_document_number"].Value = documentNumber; var returnParametersIsValid = sp_client_check_exist_document.Parameters.Add(new SqlParameter("@p_isValid", SqlDbType.Int)); returnParametersIsValid.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(sp_client_check_exist_document, "chequear tipo y numero de documento", false); if (Convert.ToInt16(returnParametersIsValid.Value) == 0) { return(false); } else { return(true); } }
public static Boolean checkMail(Int32 clientId, String mail) { SqlCommand sp_client_check_exist_mail = new SqlCommand(); sp_client_check_exist_mail.CommandText = "PUNTO_ZIP.sp_client_check_exist_mail"; sp_client_check_exist_mail.Parameters.Add(new SqlParameter("@p_client_id", SqlDbType.Int)); sp_client_check_exist_mail.Parameters["@p_client_id"].Value = clientId; sp_client_check_exist_mail.Parameters.Add(new SqlParameter("@p_client_mail", SqlDbType.VarChar)); sp_client_check_exist_mail.Parameters["@p_client_mail"].Value = mail; var returnParametersIsValid = sp_client_check_exist_mail.Parameters.Add(new SqlParameter("@p_isValid", SqlDbType.Int)); returnParametersIsValid.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(sp_client_check_exist_mail, "chequear mail", false); if (Convert.ToInt16(returnParametersIsValid.Value) == 0) { return(false); } else { return(true); } }
private static Boolean wasCharged(Int32 bookingId) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_facturar_estadia_was_charged"; command.Parameters.AddWithValue("@p_charge_stay_booking_id", bookingId); var returnParameterWasCharge = command.Parameters.Add(new SqlParameter("@p_charge_stay_was_charged", SqlDbType.Bit)); returnParameterWasCharge.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(command, "check if stay was charged", false); Int16 wasCharged = Convert.ToInt16(returnParameterWasCharge.Value); if (wasCharged != 0) { return(true); } else { return(false); } }
public static Int32 save(Cliente clientData) { SqlCommand sp_save_or_update_client = new SqlCommand(); sp_save_or_update_client.CommandType = CommandType.StoredProcedure; sp_save_or_update_client.CommandText = "PUNTO_ZIP.sp_client_save_update"; var returnParameterClientId = sp_save_or_update_client.Parameters.Add(new SqlParameter("@p_client_id", SqlDbType.Int)); returnParameterClientId.Direction = ParameterDirection.InputOutput; sp_save_or_update_client.Parameters["@p_client_id"].Value = clientData.id; sp_save_or_update_client.Parameters.AddWithValue("@p_client_name", clientData.name); sp_save_or_update_client.Parameters.AddWithValue("@p_client_lastname", clientData.lastname); sp_save_or_update_client.Parameters.AddWithValue("@p_client_type_document", clientData.typeDocument); sp_save_or_update_client.Parameters.AddWithValue("@p_client_document_number", clientData.documentNumber); sp_save_or_update_client.Parameters.AddWithValue("@p_client_mail", clientData.mail); sp_save_or_update_client.Parameters.AddWithValue("@p_client_telephone", clientData.telephone); sp_save_or_update_client.Parameters.AddWithValue("@p_client_address_name", clientData.addressName); sp_save_or_update_client.Parameters.AddWithValue("@p_client_address_number", clientData.addressNum); if (clientData.addressFloor != VarGlobal.NoAddressFloor) { sp_save_or_update_client.Parameters.AddWithValue("@p_client_address_floor", clientData.addressFloor); sp_save_or_update_client.Parameters.AddWithValue("@p_client_address_dept", clientData.adressDeptName); } sp_save_or_update_client.Parameters.AddWithValue("@p_client_nationality", clientData.nacionality); sp_save_or_update_client.Parameters.AddWithValue("@p_client_birthdate", clientData.birthdate); ProcedureHelper.execute(sp_save_or_update_client, "save or update client data", false); return(Convert.ToInt32(returnParameterClientId.Value)); }
public static Boolean isBefore(Int32 bookingId) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_estadia_booking_is_before"; command.Parameters.AddWithValue("@p_stay_booking_id", bookingId); command.Parameters.AddWithValue("@p_stay_hotel_id", VarGlobal.usuario.hotel); command.Parameters.Add(new SqlParameter("@p_system_date", SqlDbType.DateTime)); command.Parameters["@p_system_date"].Value = VarGlobal.FechaHoraSistema; var returnParameterBefore = command.Parameters.Add(new SqlParameter("@p_stay_booking_before", SqlDbType.Bit)); returnParameterBefore.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(command, "check if booking before", false); Int16 isBefore = Convert.ToInt16(returnParameterBefore.Value); if (isBefore != 0) { return(true); } else { return(false); } }
private static Boolean isCheckIn(Int32 bookingId) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_facturar_estadia_is_check_in"; command.Parameters.AddWithValue("@p_charge_stay_booking_id", bookingId); var returnParameterIsCheckIn = command.Parameters.Add(new SqlParameter("@p_charge_stay_is_check_in", SqlDbType.Bit)); returnParameterIsCheckIn.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(command, "check if check in exist", false); Int16 isCheckIn = Convert.ToInt16(returnParameterIsCheckIn.Value); if (isCheckIn != 0) { return(true); } else { return(false); } }
public static Boolean isCancel(Int32 bookingId) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_estadia_booking_is_cancel"; command.Parameters.AddWithValue("@p_stay_booking_id", bookingId); command.Parameters.AddWithValue("@p_stay_hotel_id", VarGlobal.usuario.hotel); var returnParameterCancel = command.Parameters.Add(new SqlParameter("@p_stay_booking_cancel", SqlDbType.Bit)); returnParameterCancel.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(command, "check if booking cancel", false); Int16 isCancel = Convert.ToInt16(returnParameterCancel.Value); if (isCancel != 0) { return(true); } else { return(false); } }
public static Boolean existFullStay(int bookingId) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_estadia_exist_full_stay"; command.Parameters.AddWithValue("@p_stay_booking_id", bookingId); var returnParameterExistFullStay = command.Parameters.Add(new SqlParameter("@p_stay_exist_full_stay", SqlDbType.Bit)); returnParameterExistFullStay.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(command, "check if checkin and checkout was release", false); Int16 existFullStay = Convert.ToInt16(returnParameterExistFullStay.Value); if (existFullStay != 0) { return(true); } else { return(false); } }
public static bool checkIsMustBeCancelled(int bookingId) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_estadia_cancel_is_after_date_check_in"; command.Parameters.AddWithValue("@p_stay_booking_id", bookingId); command.Parameters.Add(new SqlParameter("@p_system_date", SqlDbType.DateTime)); command.Parameters["@p_system_date"].Value = VarGlobal.FechaHoraSistema; var returnParameterHotel = command.Parameters.Add(new SqlParameter("@p_stay_change_to_cancel", SqlDbType.Bit)); returnParameterHotel.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(command, "cancel if checkin past", false); Int16 isCancel = Convert.ToInt16(returnParameterHotel.Value); if (isCancel != 0) { return(true); } else { return(false); } }
public static Boolean isCorrectPassword(String password) { SqlCommand sp_check_password = new SqlCommand(); sp_check_password.CommandText = "PUNTO_ZIP.sp_password_check_ok"; sp_check_password.Parameters.Add(new SqlParameter("@p_id", SqlDbType.VarChar)); sp_check_password.Parameters["@p_id"].Value = VarGlobal.usuario.id; sp_check_password.Parameters.Add(new SqlParameter("@p_pass", SqlDbType.VarChar)); sp_check_password.Parameters["@p_pass"].Value = Encrypt.Sha256(password); var returnParameterIsOk = sp_check_password.Parameters.Add(new SqlParameter("@p_ok", SqlDbType.Int)); returnParameterIsOk.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(sp_check_password, "chequear password", false); Int16 isOk = Convert.ToInt16(returnParameterIsOk.Value); if (isOk != 0) { return(true); } return(false); }
public static int fillHotelByUser(Usuario user) { SqlCommand sp_rol_exist_one_by_user = new SqlCommand(); sp_rol_exist_one_by_user.CommandText = "PUNTO_ZIP.sp_hotel_exist_one_by_user"; sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_id", SqlDbType.VarChar)); sp_rol_exist_one_by_user.Parameters["@p_id"].Value = user.id; sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_id_rol", SqlDbType.Int)); sp_rol_exist_one_by_user.Parameters["@p_id_rol"].Value = user.rol.id; var returnParameterCountHotel = sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_count_hotel", SqlDbType.Int)); returnParameterCountHotel.Direction = ParameterDirection.InputOutput; var returnParameterIdHotel = sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_id_hotel", SqlDbType.Int)); returnParameterIdHotel.Direction = ParameterDirection.InputOutput; var returnParameterHotelDesc = sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_hotel_desc", SqlDbType.VarChar, 255)); returnParameterHotelDesc.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(sp_rol_exist_one_by_user, "chequear si un usuario tiene un solo hotel asignado", false); int countHotel = Convert.ToInt16(returnParameterCountHotel.Value); if (countHotel == 1) { int id = Convert.ToInt16(returnParameterIdHotel.Value); user.hotel = id; } return(countHotel); }
public static Int32 save(Hotel hotelData) { SqlCommand sp_save_or_update_hotel = new SqlCommand(); sp_save_or_update_hotel.CommandType = CommandType.StoredProcedure; sp_save_or_update_hotel.CommandText = "PUNTO_ZIP.sp_hotel_save_update"; var returnParameterHotelId = sp_save_or_update_hotel.Parameters.Add(new SqlParameter("@p_hotel_id", SqlDbType.Int)); returnParameterHotelId.Direction = ParameterDirection.InputOutput; sp_save_or_update_hotel.Parameters["@p_hotel_id"].Value = hotelData.id; sp_save_or_update_hotel.Parameters.AddWithValue("@p_user_id", VarGlobal.usuario.id); sp_save_or_update_hotel.Parameters.AddWithValue("@p_user_rol_id", VarGlobal.usuario.rol.id); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_name", hotelData.name); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_mail", hotelData.mail); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_address", hotelData.address); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_address_number", hotelData.addressNumber); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_telephone", hotelData.telephone); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_city", hotelData.city); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_country", hotelData.country); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_star", hotelData.star); sp_save_or_update_hotel.Parameters.AddWithValue("@p_hotel_creation", hotelData.creation); ProcedureHelper.execute(sp_save_or_update_hotel, "save or update hotel data", false); return(Convert.ToInt32(returnParameterHotelId.Value)); }
public static Boolean existHotelRoom(Int32 hotelId, Int32 floorId, Int32 roomId) { SqlCommand sp_habitacion_exist_hotel_room = new SqlCommand(); sp_habitacion_exist_hotel_room.CommandType = CommandType.StoredProcedure; sp_habitacion_exist_hotel_room.CommandText = "PUNTO_ZIP.sp_habitacion_exist_hotel_room"; sp_habitacion_exist_hotel_room.Parameters.AddWithValue("@p_habitacion_id", roomId); sp_habitacion_exist_hotel_room.Parameters.AddWithValue("@p_habitacion_hotel_id", hotelId); sp_habitacion_exist_hotel_room.Parameters.AddWithValue("@p_habitacion_floor_id", floorId); var returnParameterExist = sp_habitacion_exist_hotel_room.Parameters.Add(new SqlParameter("@p_exist", SqlDbType.Bit)); returnParameterExist.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(sp_habitacion_exist_hotel_room, "check if exist a room", false); Int16 enable = Convert.ToInt16(returnParameterExist.Value); if (enable != 0) { return(true); } else { return(false); } }
public void DTOObjectSingleSelectSingleRowMultipleColumnTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List<Select>{ new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true), new SelectColumn("col2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), false), new SelectColumn("col3", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "String"), true), }, true, null) }); // Act var result = helper.GetDtoObject(procedure); // Assert Assert.AreEqual(@"/// <summary> /// DTO for the output of the ""proc"" stored procedure. /// </summary> public partial class procOutputDto { public Int32? col1 { get; set; } public Int32 col2 { get; set; } public String col3 { get; set; } } ", result); }
public void ExecuteStatementMultipleRowMultipleColumnTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List <Select> { new Select(new List <SelectColumn> { new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true), new SelectColumn("col2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "String"), true), }, false, null) }); // Act var result = helper.GetExecuteStatement(procedure); // Assert Assert.AreEqual(@"using(var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { result.RecordsAffected = reader.RecordsAffected; var list = new List<procOutputDto>(); while (reader.Read()) { var item = new procOutputDto(); item.col1 = !reader.IsDBNull(0) ? reader.GetInt32(0) : default(Int32?); item.col2 = !reader.IsDBNull(1) ? reader.GetString(1) : default(String); list.Add(item); } result.Data = list; reader.Close(); } ", result); }
public static int fillRolByUser(Usuario user) { SqlCommand sp_rol_exist_one_by_user = new SqlCommand(); sp_rol_exist_one_by_user.CommandText = "PUNTO_ZIP.sp_rol_exist_one_by_user"; sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_id", SqlDbType.VarChar)); sp_rol_exist_one_by_user.Parameters["@p_id"].Value = user.id; var returnParameterCountRol = sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_count_rol", SqlDbType.Int)); returnParameterCountRol.Direction = ParameterDirection.InputOutput; var returnParameterIdRol = sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_id_rol", SqlDbType.Int)); returnParameterIdRol.Direction = ParameterDirection.InputOutput; var returnParameterRolDesc = sp_rol_exist_one_by_user.Parameters.Add(new SqlParameter("@p_rol_desc", SqlDbType.VarChar, 255)); returnParameterRolDesc.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(sp_rol_exist_one_by_user, "chequear si un usuario tiene un solo rol", false); int countRol = Convert.ToInt16(returnParameterCountRol.Value); if (countRol == 1) { int id = Convert.ToInt16(returnParameterIdRol.Value); string description = Convert.ToString(returnParameterRolDesc.Value); user.rol = new Rol(id, description); } return(countRol); }
public static Boolean existUser(string user) { SqlCommand sp_check_user = new SqlCommand(); sp_check_user.CommandText = "PUNTO_ZIP.sp_login_check_valid_user"; sp_check_user.Parameters.Add(new SqlParameter("@p_id", SqlDbType.VarChar)); sp_check_user.Parameters["@p_id"].Value = user; var returnParameterIsValid = sp_check_user.Parameters.Add(new SqlParameter("@p_is_valid", SqlDbType.Bit)); returnParameterIsValid.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(sp_check_user, "chequear usuario valido", false); int isValid = Convert.ToInt16(returnParameterIsValid.Value); if (isValid == 1) { return(true); } else { return(false); } }
/// <summary> /// 获取模块的当前用户操作权限 /// </summary> /// <param name="managerId"></param> /// <param name="action"></param> /// <returns></returns> public List <GetPermissionCode> GetPermission(Int64 managerId, string action) { // 换用存储过程 //var permis = GetCurrentPermission(managerId, action); //定义存储过程入参 var sqlParas = new SqlParameter[1]; sqlParas[0] = new SqlParameter("@ManagerId", DbType.Int64) { Direction = ParameterDirection.Input }; sqlParas[1] = new SqlParameter("@Url", DbType.String) { Direction = ParameterDirection.Input }; IList <ChannelRightOperate> permis = ProcedureHelper.ExcuteDataSet <ChannelRightOperate>("getChannelRightOperateByManagerId", sqlParas); List <GetPermissionCode> rights = (from perm in permis select new GetPermissionCode { KeyCode = perm.RightId, IsValid = perm.IsValid }).ToList(); return(rights); }
public static void save(UsuarioDatos userData, Int32 hotel, string rol, String password) { SqlCommand sp_save_or_update_user = new SqlCommand(); sp_save_or_update_user.CommandType = CommandType.StoredProcedure; sp_save_or_update_user.CommandText = "PUNTO_ZIP.sp_user_save_update"; sp_save_or_update_user.Parameters.AddWithValue("@p_user_name", userData.username); sp_save_or_update_user.Parameters.AddWithValue("@p_name_lastName", userData.nameLastname); sp_save_or_update_user.Parameters.AddWithValue("@p_id_type_document", userData.typeDocument); sp_save_or_update_user.Parameters.AddWithValue("@p_document_number", userData.documentNumber); sp_save_or_update_user.Parameters.AddWithValue("@p_mail", userData.mail); sp_save_or_update_user.Parameters.AddWithValue("@p_telephone", userData.telephone); sp_save_or_update_user.Parameters.AddWithValue("@p_address", userData.address); sp_save_or_update_user.Parameters.AddWithValue("@p_birthdate", userData.birthDate); if (userData.enabled) { sp_save_or_update_user.Parameters.AddWithValue("@p_enabled", 1); } else { sp_save_or_update_user.Parameters.AddWithValue("@p_enabled", 0); } sp_save_or_update_user.Parameters.AddWithValue("@p_id_hotel", hotel); sp_save_or_update_user.Parameters.AddWithValue("@p_description_rol", rol); if (password != null) { sp_save_or_update_user.Parameters.AddWithValue("@p_password", Encrypt.Sha256(password)); } ProcedureHelper.execute(sp_save_or_update_user, "save or update user data", false); }
public void DTOObjectSingleSelectMultipleRowMultipleColumnTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List <Select> { new Select(new List <SelectColumn> { new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true), new SelectColumn("col2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "String"), true) }, false, null) }); // Act var result = helper.GetDtoObject(procedure); // Assert Assert.AreEqual(@"/// <summary> /// DTO for the output of the ""proc"" stored procedure. /// </summary> public partial class procOutputDto { public Int32? col1 { get; set; } public String col2 { get; set; } } ", result); }
public static Boolean removeRegimenToHotel(Int32 hotelId, Int32 regimenId) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_hotel_regimen_remove"; command.Parameters.Add(new SqlParameter("@p_hotel_id", SqlDbType.Int)); command.Parameters["@p_hotel_id"].Value = hotelId; command.Parameters.Add(new SqlParameter("@p_regimen_id", SqlDbType.Int)); command.Parameters["@p_regimen_id"].Value = regimenId; command.Parameters.Add(new SqlParameter("@p_system_date", SqlDbType.DateTime)); command.Parameters["@p_system_date"].Value = VarGlobal.FechaHoraSistema; var returnParameterRemoveOk = command.Parameters.Add(new SqlParameter("@p_remove_ok", SqlDbType.Int)); returnParameterRemoveOk.Direction = ParameterDirection.InputOutput; ProcedureHelper.execute(command, "remover regimen a hotel", false); Int16 enable = Convert.ToInt16(returnParameterRemoveOk.Value); if (enable != 0) { return(true); } else { return(false); } }
public static Boolean closePeriod(int hotelId, Period period) { SqlCommand sp_hotel_close_period_valid = new SqlCommand(); sp_hotel_close_period_valid.CommandType = CommandType.StoredProcedure; sp_hotel_close_period_valid.CommandText = "PUNTO_ZIP.sp_hotel_close_period_valid"; var returnParameterAddOk = sp_hotel_close_period_valid.Parameters.Add(new SqlParameter("@p_add_ok", SqlDbType.Int)); returnParameterAddOk.Direction = ParameterDirection.InputOutput; sp_hotel_close_period_valid.Parameters.AddWithValue("@p_user_id", VarGlobal.usuario.id); sp_hotel_close_period_valid.Parameters.AddWithValue("@p_hotel_id", hotelId); sp_hotel_close_period_valid.Parameters.AddWithValue("@p_hotel_close_period_from", period.from); sp_hotel_close_period_valid.Parameters.AddWithValue("@p_hotel_close_period_to", period.to); sp_hotel_close_period_valid.Parameters.AddWithValue("@p_hotel_close_period_motive", period.motive); ProcedureHelper.execute(sp_hotel_close_period_valid, "check down period", false); Int16 enable = Convert.ToInt16(returnParameterAddOk.Value); if (enable != 0) { return(true); } else { return(false); } }
public static void UpdateProcedure(dynamic dynamic) { var query = MyEntity.Procedure.UpdateProcedure.ProcedureUpdate(dynamic); var data = commoned(dynamic, query); if (data == false) { ProcedureHelper.ReCreateProcedureIfUpdateExists(dynamic); } }
public static void SelectProcedure(dynamic dynamic) { var query = MyEntity.Procedure.SelectProcedure.ProcedureSelect(dynamic); var data = commoned(dynamic, query); if (data == false) { ProcedureHelper.ReCreateProcedureIfSelectExists(dynamic); } }
public static void InsertProcedure(dynamic dynamic) { var query = Procedure.InsertProcedure.ProcedureInsert(dynamic, "Create"); var data = commoned(dynamic, query); if (data == false) { ProcedureHelper.ReCreateProcedureIfInsertExists(dynamic); } }
public static void cleanLogin(string username) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_user_clean_login"; command.Parameters.Add(new SqlParameter("@p_user_name", SqlDbType.VarChar, 255)); command.Parameters["@p_user_name"].Value = username; ProcedureHelper.execute(command, "Limpiar intentos de login", false); }
public void ReturnVariableNoSelectTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, null); // Act var result = helper.GetReturnVariable(procedure); // Assert Assert.AreEqual("int result;", result); }
public void DTOObjectNoSelectTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, null); // Act var result = helper.GetDtoObject(procedure); // Assert Assert.AreEqual("", result); }
public void ExecuteStatementNoSelectTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, null); // Act var result = helper.GetExecuteStatement(procedure); // Assert Assert.AreEqual("result = cmd.ExecuteNonQuery();\r\n", result); }
public static void change(string password) { SqlCommand sp_check_password = new SqlCommand(); sp_check_password.CommandText = "PUNTO_ZIP.sp_password_change"; sp_check_password.Parameters.Add(new SqlParameter("@p_id", SqlDbType.VarChar)); sp_check_password.Parameters["@p_id"].Value = VarGlobal.usuario.id; sp_check_password.Parameters.Add(new SqlParameter("@p_pass", SqlDbType.VarChar)); sp_check_password.Parameters["@p_pass"].Value = Encrypt.Sha256(password); ProcedureHelper.execute(sp_check_password, "chequear password", false); }
public static void removeFunctionalityToRol(Int32 idRol, Int32 idFunctionality) { SqlCommand command = new SqlCommand(); command.CommandText = "PUNTO_ZIP.sp_rol_functionality_remove"; command.Parameters.Add(new SqlParameter("@p_id_rol", SqlDbType.Int)); command.Parameters["@p_id_rol"].Value = idRol; command.Parameters.Add(new SqlParameter("@p_id_functionality", SqlDbType.Int)); command.Parameters["@p_id_functionality"].Value = idFunctionality; ProcedureHelper.execute(command, "quitar funcionalidad a rol", false); }
public void DTOObjectSingleSelectMultipleRowSingleColumnTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List<Select>{ new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true) }, false, null) }); // Act var result = helper.GetDtoObject(procedure); // Assert Assert.AreEqual("", result); }
public void ExecuteStatementSingleRowMulipleColumnTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List<Select>{ new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true), new SelectColumn("col2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "String"), true), }, true, null) }); // Act var result = helper.GetExecuteStatement(procedure); // Assert Assert.AreEqual(@"using(var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { result.RecordsAffected = reader.RecordsAffected; while (reader.Read()) { var item = new procOutputDto(); item.col1 = !reader.IsDBNull(0) ? reader.GetInt32(0) : default(Int32?); item.col2 = !reader.IsDBNull(1) ? reader.GetString(1) : default(String); result.Data = item; } reader.Close(); } ", result); }
public void ExecuteStatementSingleValueTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List<Select>{ new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), false) }, true, null) }); // Act var result = helper.GetExecuteStatement(procedure); // Assert Assert.AreEqual("result = (Int32)cmd.ExecuteScalar();\r\n", result); }
public void MethodParameterTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, new List<Parameter> { new Parameter("param1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), false, null), new Parameter("param2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true, null) }, null); // Act var result = helper.GetMethodParamList(procedure, true, true, false); // Assert Assert.AreEqual("Int32? param1, out Int32? param2", result); }
public void ReturnTypeMultipleRowSingleColumnTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List<Select>{ new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), false) }, false, null) }); // Act var result = helper.GetReturnType(procedure); // Assert Assert.AreEqual("Result<IEnumerable<Int32>>", result); }
public void ReturnTypeMultipleSelectTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List<Select>{ new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true), new SelectColumn("col2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "String"), true) }, false, null), new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true), new SelectColumn("col2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "String"), true) }, true, null) }); // Act var result = helper.GetReturnType(procedure); // Assert Assert.AreEqual("procResults", result); }
public void ReturnVariableSingleSelectTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, null, new List<Select>{ new Select(new List<SelectColumn>{ new SelectColumn("col1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true), new SelectColumn("col2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "String"), true) }, false, null) }); // Act var result = helper.GetReturnVariable(procedure); // Assert Assert.AreEqual("Result<IEnumerable<procOutputDto>> result = new Result<IEnumerable<procOutputDto>>();", result); }
public void SqlParameterTest() { // Arrange var helper = new ProcedureHelper(); var procedure = new Procedure("proc", "proc", null, new List<Parameter> { new Parameter("param1", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), false, null), new Parameter("param2", DataTypeHelper.Instance.GetMap(TypeFormat.DotNetFrameworkType, "Int32?"), true, null) }, null); // Act var result = helper.GetSqlParamList(procedure); // Assert Assert.AreEqual(@"cmd.Parameters.Add(""param1"", SqlDbType.Int).Value = (object)param1 ?? DBNull.Value; var param2OutputParameter = new SqlParameter(""param2"", SqlDbType.Int) { Direction = ParameterDirection.Output }; cmd.Parameters.Add(param2OutputParameter); ", result); }