// @Nombre : Pedro Marval // @Versión " 2 // @Fecha de Creación del Archivo: 10/09/2018 // @Descripción: Método que permite obtener la información de los MAESTROS DETALLES // @Parámetros : // pIdMDetalle : Se usa para buscar la información de un Maestro Detalle en especifico // pIdMCabecera: Se usa para buscar la información de todos los Maestros Detalles que pertenecen a un Maestro Cabecera // pDescripcion: Se Usa para buscar la información de los Maestro Detalle por su Descripcion // pIndActivo : Se usa para identificar los Maestros Detalles que están habilitados o no. si se pasa null como parámetros retorna sin importar el estatus(Indicador activo) // pFechaInicial , pFechaFinal: rango de fechas para buscar los maestros creados en un tiempo estimado // @Notas: Este método retorna una Lista de Maestros Detalles dependiendo de los parámetros que se le pasen. // Si no se envían parámetros retornara todos los Maestros detalles public List <cMaestrosDetalle> ConsultarMaestroDetalle(Int64 pIdMDetalle, Int64 pIdMCabecera, string pDescripcion, bool?pIndActivo, string pFechaInicial, string pFechaFinal) { string mensaje = string.Empty; List <cMaestrosDetalle> Lista = new List <cMaestrosDetalle>(); string cs = obtenerConexion(); SqlConnection cn = new SqlConnection(); cn.ConnectionString = cs; try { using (cn) { SqlCommand cmd = new SqlCommand(); SqlDataReader dr; cmd.Connection = cn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[Maestro].[spConsultarMDetalles]"; cmd.Parameters.Add("@pIdMDetalle", SqlDbType.BigInt).Value = pIdMDetalle; cmd.Parameters.Add("@pIdMCabecera", SqlDbType.BigInt).Value = pIdMCabecera; cmd.Parameters.Add("@pDescripcion", SqlDbType.VarChar, 50).Value = pDescripcion; cmd.Parameters.Add("@pIndActivo", SqlDbType.SmallInt).Value = pIndActivo; cmd.Parameters.Add("@pfechaInicial", SqlDbType.Date).Value = Convert.ToDateTime(pFechaInicial); cmd.Parameters.Add("@pfechaFinal", SqlDbType.Date).Value = Convert.ToDateTime(pFechaFinal); try { cn.Open(); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { cMaestrosDetalle dato = new cMaestrosDetalle(); dato.idMaestroDetalle = dr.GetInt64(0); dato.idMaestroCabecera = dr.GetInt64(1); dato.descripcion = dr.GetString(2); dato.idUsuarioCreador = dr.GetInt64(3); dato.idUsuarioActualiza = dr.GetInt64(4); dato.indActivo = dr.GetBoolean(5); dato.fechaCreacion = dr.GetDateTime(6); dato.fechaOcurrencia = dr.GetDateTime(7); Lista.Add(dato); } //end while } //end if dr.Close(); cn.Close(); } catch (Exception Ex) { mensaje = "Error... " + Ex.Message; Log.Error(mensaje); } } } catch (SqlException Ex) { mensaje = "Error... " + Ex.Message; Log.Error(mensaje); } return(Lista); }
private void btnGuardar_Click(object sender, RoutedEventArgs e) { string mensaje = ""; try { if (reglas.IsMatch(txtDescripcion.Text) && txtDescripcion.Text.Length > 3 && txtDescripcion.Text.Length < 51) { if (txtDescripcion.Text == descripcionAntigua && chkActivo.IsChecked.Value == indActivo) { MessageBox.Show("Realice por lo menos un cambio", "Error"); } else { if (UI.ToString() == "MasterOfMasterDesktop.UI.uiConfigMaestros") { cMaestrosCabecera MC = new cMaestrosCabecera(); MC.descripcion = txtDescripcion.Text; MC.indActivo = chkActivo.IsChecked.Value; MC.idUsuarioActualiza = 2; mensaje = svc.ActualizarMaestroCabecera(MC, descripcionAntigua); uiConfigMaestros CM = UI as uiConfigMaestros; CM.cargarListaMaestros(); } else { cMaestrosDetalle MD = new cMaestrosDetalle(); MD.idMaestroCabecera = idCabecera; MD.descripcion = txtDescripcion.Text; MD.indActivo = chkActivo.IsChecked.Value; MD.idUsuarioActualiza = 2; mensaje = svc.ActualizarMaestroDetalle(MD, descripcionAntigua); uiConfigDetalles CD = UI as uiConfigDetalles; CD.cargarMDetalles(CD.id); } MessageBox.Show(mensaje); pw.CargarMenus(); if (mensaje == "Modificación completada") { this.Close(); quitarEfecto(); } } } else { MessageBox.Show("Ingrese una descripción valida"); } } catch (Exception Ex) { Console.WriteLine(Ex.Message); Log.Error(Ex.Message); } }
/// <summary> /// Autor: RUBEN BALLESTEROS,RB /// Fecha: 16/08/2018 /// Descripcion: Codificacion del Metodo que permite Insertar Maestros Detalle, el cual se realiza por medio del servicio WCF a la tabla Maestros Detalle de la Base de Datos. /// </summary> /// <param name="pMD"> pMD son las variables que recibe el metodo como parametros para almacenar los datos que se van a Ingresar</param> /// <returns>El Metodo va a retornar la variable de tipo "String">(mensaje) el cual indica si Fue exitoso o no el ingreso de datos, en caso de no serlo mostrara el tipo de error y su codigo. public String InsertarMaestroDetalle(cMaestrosDetalle pMaestroDetalle) { string mensaje = String.Empty; string cs = obtenerConexion(); SqlConnection cn = new SqlConnection(); cn.ConnectionString = cs; try { using (cn) { SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "[Maestro].[SPInsertUpdateMaestrosDetalles]"; cmd.Parameters.Add("@pDescripcionAntigua", SqlDbType.VarChar, 50).Value = null; cmd.Parameters.Add("@pIdMaestroCabecera", SqlDbType.BigInt).Value = pMaestroDetalle.idMaestroCabecera; cmd.Parameters.Add("@pDescripcion", SqlDbType.VarChar, 50).Value = pMaestroDetalle.descripcion; cmd.Parameters.Add("@pUsuarioCreador", SqlDbType.BigInt).Value = pMaestroDetalle.idUsuarioCreador; cmd.Parameters.Add("@pUsuarioActualiza", SqlDbType.BigInt).Value = pMaestroDetalle.idUsuarioCreador; cmd.Parameters.Add("@pIndActivo", SqlDbType.Bit).Value = pMaestroDetalle.indActivo; cmd.Parameters.Add("@pMensaje", SqlDbType.VarChar, 50).Direction = ParameterDirection.Output; try { cn.Open(); cmd.ExecuteNonQuery(); mensaje = Convert.ToString(cmd.Parameters["@pMensaje"].Value); cn.Close(); Log.Info(mensaje); } catch (Exception Ex) { mensaje = "Error... " + Ex.Message; Log.Error(mensaje); } } } catch (SqlException Ex) { mensaje = "Error... " + Ex.Message; Log.Error(mensaje); } return(mensaje); }
public JsonResult IngresarMaestrosDetalles(Int64 pIdMaestroCabecera, string Descripcion, Boolean Estado) { string message; string titulo2 = ""; try { if (!(reglas.IsMatch(Descripcion) && Descripcion.Length > 3 && Descripcion.Length <= 50)) { message = "*Solo se admiten caracteres de [A-Z] o [0-9]. <br> *La cadena debe tener una longitud mínima de cuatro(4) caracteres. <br> *La cadena debe tener una longitud máxima de cincuenta(50) caracteres.<br> La cadena no puede empezar con un carácter numérico(0-9).<br>*La cadena debe contener al menos un (1) carácter alfabético."; titulo2 = "Por favor tome en cuenta las siguientes reglas para ingresar los datos. "; return(Json(new { titulo = titulo2, message = message }, JsonRequestBehavior.AllowGet)); } cMaestrosDetalle md = new cMaestrosDetalle(); md.idMaestroCabecera = pIdMaestroCabecera; md.descripcion = Descripcion; md.idUsuarioCreador = 1; md.idUsuarioActualiza = 1; md.indActivo = Estado; message = svc.InsertarMaestroDetalle(md); if (message == "Modificación completada" || message == "Registro exitoso") { titulo2 = "Excelente"; } else { titulo2 = "Advertencia"; } Log.Info(message); } catch (Exception e) { message = e.ToString(); titulo2 = "Ha Ocurrido un Error!!!"; Log.Error(message); } return(Json(new { titulo = titulo2, message = message }, JsonRequestBehavior.AllowGet));//Redirect(Url.Action("Config", "ConfiguracionM")); }
//metodo para guardar un nuevo maestro detalle private void btnGuardar_Click(object sender, RoutedEventArgs e) { try { if (reglas.IsMatch(txtDescripcion.Text) && txtDescripcion.Text.Length > 3 && txtDescripcion.Text.Length < 51) { Random rnd = new Random(); cMaestrosDetalle MD = new cMaestrosDetalle(); MD.descripcion = txtDescripcion.Text; MD.idMaestroCabecera = id; MD.idUsuarioCreador = rnd.Next(1, 3); MD.idUsuarioActualiza = MD.idUsuarioCreador; if (chkActivo.IsChecked == true) { MD.indActivo = true; } else { MD.indActivo = false; } txtDescripcion.Text = ""; MessageBox.Show(svc.InsertarMaestroDetalle(MD)); cargarMDetalles(id); pw.CargarMenus(); } else { MessageBox.Show("Ingrese una descripción valida", "Alerta"); } } catch (Exception Ex) { Console.WriteLine(Ex.Message); Log.Error(Ex.Message); } }
public string ActualizarMaestroDetalle(cMaestrosDetalle pMaestroDetalle, String pDescripcionAntigua) { return(MAD.ActualizarMaestroDetalle(pMaestroDetalle, pDescripcionAntigua)); }
public String InsertarMaestroDetalle(cMaestrosDetalle pMaestroDetalle) { return(MAD.InsertarMaestroDetalle(pMaestroDetalle)); }