public bool AddResolucion(ResolucionModel resolucion, SentenciaModel sentencia)
        {
            using (SqlConnection openConnection = new SqlConnection(this.ConnectionString))
            {
                using (SqlCommand sqlcommand = new SqlCommand())
                {
                    sqlcommand.CommandType = CommandType.Text;
                    sqlcommand.CommandText = Scripts.SqlInsertResolucion;
                    sqlcommand.Connection  = openConnection;

                    sqlcommand.Parameters.AddWithValue("@NroResolucion", resolucion.NroResolucion);
                    sqlcommand.Parameters.AddWithValue("@NroProyecto", resolucion.NroProyecto);
                    sqlcommand.Parameters.AddWithValue("@TipoResolucion", (int)resolucion.TipoResolucion);
                    sqlcommand.Parameters.AddWithValue("@UGEL", (int)resolucion.TipoUGEL);
                    sqlcommand.Parameters.AddWithValue("@InstitucionEducativa", resolucion.InstitucionEducativa);
                    sqlcommand.Parameters.AddWithValue("@DNI", resolucion.DNI);
                    sqlcommand.Parameters.AddWithValue("@Situacion", (int)resolucion.SituacionResolucion);
                    sqlcommand.Parameters.AddWithValue("@Concepto", resolucion.ConceptoResolucion);

                    sqlcommand.Parameters.AddWithValue("@ExpedienteJudicial", sentencia.ExpedienteJudicial);
                    sqlcommand.Parameters.AddWithValue("@Sentencia", sentencia.Sentencia);
                    sqlcommand.Parameters.AddWithValue("@FechaSentencia", sentencia.FechaSentencia);
                    sqlcommand.Parameters.AddWithValue("@Monto", sentencia.Monto);

                    sqlcommand.Connection.Open();
                    var rowsAffected = sqlcommand.ExecuteNonQuery();
                    sqlcommand.Connection.Close();

                    return(rowsAffected > 0);
                }
            }
        }
Пример #2
0
        private void btnModificarResolucion_Click(object sender, EventArgs e)
        {
            try
            {
                // Validar resolucion y sentencia
                if (this.ValidateUpdate())
                {
                    ResolucionModel resolucionModel = new ResolucionModel()
                    {
                        NroProyecto          = txtModNroProyecto.Text.Trim(),
                        NroResolucion        = txtModNroResolucion.Text.Trim(),
                        TipoResolucion       = (TipoResolucion)cmbModTipo.SelectedValue,
                        TipoUGEL             = (TipoUGEL)cmbModUGEL.SelectedValue,
                        InstitucionEducativa = cmbModIIEE.SelectedIndex + 1,
                        ConceptoResolucion   = cmbModConcepto.SelectedIndex + 1,
                        SituacionResolucion  = (SituacionResolucion)cmbModSituacion.SelectedValue,
                        DNI = txtModDNI.Text.Trim(),
                    };

                    SentenciaModel sentenciaModel = new SentenciaModel()
                    {
                        FechaSentencia     = dtModFechaSentencia.Value,
                        Sentencia          = txtModSentencia.Text.Trim(),
                        ExpedienteJudicial = txtModExpedienteJudicial.Text.Trim(),
                        Monto = txtModMonto.Text.Trim() == string.Empty ? 0 : Convert.ToDecimal(txtModMonto.Text),
                    };

                    // LLama al metodo de servicio y lo asigna a una variable de retorno

                    var flag = this.resolucionService.UpdateResolucion(resolucionModel, sentenciaModel);

                    if (flag)
                    {
                        //DataTable data = this.resolucionService.GetAllResoluciones();
                        //this.LoadDataGridView(data);


                        // Mensaje de modificacion satisfactorio
                        MessageBox.Show(
                            Resources.Update_Satisfactorio_Mensaje,
                            Resources.Update_Satisfactorio_Mensaje_Titulo,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
                    }
                }
                else
                {
                    // Mensaje de error al modificar
                    MessageBox.Show(
                        this.errorMessage,
                        Resources.Registration_Error_Mensaje_Titulo,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }
        }
        private void btnRegistrarResolucion_Click(object sender, EventArgs e)
        {
            try
            {
                // Verifica si la validacion paso
                if (this.ValidateRegistrationResolucion())
                {
                    // Asignar controles a el modelo
                    ResolucionModel resolucionModel = new ResolucionModel()
                    {
                        NroProyecto          = txtNroProyecto.Text.Trim(),
                        NroResolucion        = txtNroResolucion.Text.Trim(),
                        TipoResolucion       = (TipoResolucion)cmbTipo.SelectedValue,
                        TipoUGEL             = (TipoUGEL)cmbUGEL.SelectedValue,
                        InstitucionEducativa = cmbIIEE.SelectedIndex + 1,
                        ConceptoResolucion   = cmbConcepto.SelectedIndex + 1,
                        SituacionResolucion  = (SituacionResolucion)cmbSituacion.SelectedValue,
                        DNI = txtDNIDocenteResolucion.Text.Trim(),
                    };

                    SentenciaModel sentenciaModel = new SentenciaModel()
                    {
                        FechaSentencia     = dtFechaSentencia.Value,
                        Sentencia          = txtSentencia.Text.Trim(),
                        ExpedienteJudicial = txtExpedienteJudicial.Text.Trim(),
                        Monto = txtMonto.Text.Trim() == string.Empty ? 0 : Convert.ToDecimal(txtMonto.Text),
                    };

                    // Llama para el registro de solucion por el metodo de servicio y asigna el valor retornado
                    var successResolucion = this.resolucionService.RegisterResolucion(resolucionModel, sentenciaModel);

                    // Si es verdadero se hizo el registro y se muestra el mensaje
                    if (successResolucion)
                    {
                        // Muestra la cajita con el mensaje de registro satisfactorio
                        MessageBox.Show(
                            Resources.Registration_Satisfactorio_Mensaje,
                            Resources.Registration_Satisfactorio_Mensaje_Titulo,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);

                        // Limpia los controles
                        ControlUtilities.ResetAllControls(groupBoxInfoResoluciones);
                        ControlUtilities.ResetAllControls(groupBoxInfoSentencia);
                    }
                    else
                    {
                        // Muestral el mensaje de error
                        MessageBox.Show(
                            Resources.Registration_Error_Mensaje,
                            Resources.Registration_Error_Mensaje_Titulo,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                }
                else
                {
                    // Muestra el mensaje de valifacion fallido
                    MessageBox.Show(
                        this.errorMessage,
                        Resources.Registration_Error_Mensaje_Titulo,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(new Exception(Resources.Error_DNIDocent_NotExist + ex));
            }
        }
 public bool UpdateResolucion(ResolucionModel resolucion, SentenciaModel sentencia)
 {
     return(this.resolucionAccess.UpdateResolucion(resolucion, sentencia));
 }
 public bool RegisterResolucion(ResolucionModel resolucion, SentenciaModel sentencia)
 {
     return(this.resolucionAccess.AddResolucion(resolucion, sentencia));
 }