예제 #1
0
        private void btnCrearVentanilla_Click(object sender, EventArgs e)
        {
            epValidarCampos.SetError(txtNombreVentanilla, "");

            if (string.IsNullOrEmpty(txtNombreVentanilla.Text.Trim()))
            {
                epValidarCampos.SetError(txtNombreVentanilla, "Debe proporcionarle un nombre a la Ventanilla.");
                return;
            }
            else
            {
                epValidarCampos.SetError(txtNombreVentanilla, "");
            }

            ventanillaMethods = new VentanillaMethods();
            ventanilla        = new VentanillaModel();

            ventanilla.Descripcion = txtNombreVentanilla.Text;
            if (cbEstado.SelectedIndex == 0)
            {
                ventanilla.EstadoVentanilla = false;
            }
            else if (cbEstado.SelectedIndex == 1)
            {
                ventanilla.EstadoVentanilla = true;
            }

            DialogResult SiNo = MetroFramework.MetroMessageBox.Show(
                this,
                "¿Está seguro que desea crear una nueva ventanilla?",
                "Crear",
                MessageBoxButtons.YesNo, MessageBoxIcon.Question, 170);

            if (SiNo == DialogResult.No)
            {
                return;
            }


            var tuplaTurnos = ventanillaMethods.GuardarVentanilla(ventanilla, Session.UserName);
            var a           = tuplaTurnos.Item1;

            if (tuplaTurnos.Item2 != 0)
            {
                ventanilla.Id_ventanilla = tuplaTurnos.Item2;
            }

            if (a.Equals("Ventanilla Guardada"))
            {
                MensajeAviso.Show(MessageType.SUCCESSFUL, "Ventanilla guardada correctamente.");

                ObtenerVentanillas();
                LimpiarControles();
            }
            else
            {
                MensajeAviso.Show(MessageType.WARNING, "No se pudo guardar la ventanilla: " + a);
            }
        }
예제 #2
0
        /// <summary>
        /// Selects the Single object of VentanillaModel table.
        /// </summary>
        public VentanillaModel GetVentanillaModel(int aID_VentanillaModel)
        {
            VentanillaModel VentanillaModel = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();

                    command.Parameters.AddWithValue("@ID_VentanillaModel", aID_VentanillaModel);


                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "VentanillaModelSelect";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            int      ID_VentanillaModel  = (int)(reader["ID_VentanillaModel"]);
                            string   Descripcion         = (string)(reader["Descripcion"]);
                            int      IdSucursal          = (int)(reader["IdSucursal"]);
                            DateTime FECHA_CREACION      = (DateTime)(reader["FECHA_CREACION"]);
                            DateTime?FECHA_MODIFICACION  = reader["FECHA_MODIFICACION"] as DateTime?;
                            string   USUARIO_CREADOR     = (string)(reader["USUARIO_CREADOR"]);
                            string   USUARIO_MODIFICADOR = (string)(reader["USUARIO_MODIFICADOR"]);

                            VentanillaModel = new VentanillaModel
                            {
                                Id_ventanilla       = ID_VentanillaModel,
                                Descripcion         = Descripcion,
                                Idsucursal          = IdSucursal,
                                Fecha_creacion      = FECHA_CREACION,
                                Fecha_modificacion  = FECHA_MODIFICACION,
                                Usuario_creador     = USUARIO_CREADOR,
                                Usuario_modificador = USUARIO_MODIFICADOR,
                            };
                        }
                    }
                }

                return(VentanillaModel);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        /// <summary>
        /// Updates a record to the VentanillaModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Update(VentanillaModel aVentanillaModel, int ID_user)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@pMode", 5);
                    command.Parameters.AddWithValue("@ID_user", ID_user);
                    command.Parameters.AddWithValue("@ID_Ventanilla", aVentanillaModel.Id_ventanilla);
                    command.Parameters.AddWithValue("@Descripcion", aVentanillaModel.Descripcion);
                    command.Parameters.AddWithValue("@IdSucursal", aVentanillaModel.Idsucursal);

                    SqlParameter paramId = new SqlParameter("@IDENTITY", SqlDbType.Int);
                    paramId.Direction = ParameterDirection.Output;
                    command.Parameters.Add(paramId);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "sp_tVentanilla";

                    int afectados = command.ExecuteNonQuery();
                    int identity  = Convert.ToInt32(command.Parameters["@IDENTITY"].Value.ToString());

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #4
0
        private void btnBorrarVentanilla_Click(object sender, EventArgs e)
        {
            epValidarCampos.SetError(txtNombreVentanilla, "");

            if (string.IsNullOrEmpty(txtNombreVentanilla.Text.Trim()))
            {
                epValidarCampos.SetError(txtNombreVentanilla, "Debe seleccionar una ventanilla para poder eliminarla.");
                return;
            }
            else
            {
                epValidarCampos.SetError(txtNombreVentanilla, "");
            }

            if (ventanilla != null)
            {
                ventanillaMethods = new VentanillaMethods();

                ventanilla.Descripcion = txtNombreVentanilla.Text;

                DialogResult SiNo = MetroFramework.MetroMessageBox.Show(
                    this,
                    "¿Está seguro que desea eliminar la ventanilla?",
                    "Eliminar",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Error, 170);
                if (SiNo == DialogResult.No)
                {
                    return;
                }

                var a = ventanillaMethods.EliminarVentanilla(ventanilla);
                if (a.Equals("Ventanilla Eliminada"))
                {
                    MensajeAviso.Show(MessageType.SUCCESSFUL, "Ventanilla eliminada correctamente.");

                    txtNombreVentanilla.Text = "";
                    cbEstado.SelectedIndex   = 1;
                    ventanilla = null;
                    ObtenerVentanillas();
                    LimpiarControles();
                }
                else
                {
                    MensajeAviso.Show(MessageType.ERROR, "No se pudo eliminar la ventanilla: " + a);
                }
            }
            else
            {
                MensajeAviso.Show(MessageType.WARNING, "Seleccione una ventanilla para borrar.");
            }
        }
예제 #5
0
        public string ActualizarVentanilla(VentanillaModel ventanilla, string usuario)
        {
            string afectados;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;


                    command.Parameters.AddWithValue("@Id", ventanilla.Id_ventanilla);
                    command.Parameters.AddWithValue("@Descripcion", ventanilla.Descripcion);
                    command.Parameters.AddWithValue("@Estado", ventanilla.EstadoVentanilla);
                    command.Parameters.AddWithValue("@Usuario", usuario);

                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "ActualizarVentanilla";

                    object a = command.ExecuteScalar();

                    if (a != null)
                    {
                        afectados = (string)a;
                    }
                    else
                    {
                        afectados = "Ventanilla Actualizada";
                    }

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    return(afectados);
                }
            }
            catch (SqlException ex)
            {
                afectados = ex.Errors[0].Message.ToString();
                return(afectados);
            }
        }
예제 #6
0
 private void dgvVentanilla_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     ventanilla = (VentanillaModel)dgvVentanilla.CurrentRow.DataBoundItem;
     txtNombreVentanilla.Text = ventanilla.Descripcion;
     if (ventanilla.Estado == "Habilitada")
     {
         cbEstado.SelectedIndex = 1;
     }
     else if (ventanilla.Estado == "Deshabilitada")
     {
         cbEstado.SelectedIndex = 0;
     }
     ModoEliminarBorrar();
 }
예제 #7
0
        /// <summary>
        /// Updates a record to the VentanillaModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Update(VentanillaModel aVentanillaModel)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@ID_VentanillaModel", aVentanillaModel.Id_ventanilla);
                    command.Parameters.AddWithValue("@Descripcion", aVentanillaModel.Descripcion);
                    command.Parameters.AddWithValue("@IdSucursal", aVentanillaModel.Idsucursal);
                    command.Parameters.AddWithValue("@FECHA_CREACION", aVentanillaModel.Fecha_creacion);
                    command.Parameters.AddWithValue("@FECHA_MODIFICACION", aVentanillaModel.Fecha_modificacion == null ? (object)DBNull.Value : aVentanillaModel.Fecha_modificacion);
                    command.Parameters.AddWithValue("@USUARIO_CREADOR", aVentanillaModel.Usuario_creador);
                    command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", aVentanillaModel.Usuario_modificador == null ? (object)DBNull.Value : aVentanillaModel.Usuario_modificador);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "VentanillaModelUpdate";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
        /// <summary>
        /// Selects the Single object of VentanillaModel table.
        /// </summary>
        public VentanillaModel GetVentanillaModel(int aID_VentanillaModel)
        {
            VentanillaModel VentanillaModel = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();

                    command.Parameters.AddWithValue("@pMode", 2);
                    command.Parameters.AddWithValue("@ID_Ventanilla", aID_VentanillaModel);


                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "sp_tVentanilla";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            int    ID_VentanillaModel = (int)(reader["ID_Ventanilla"]);
                            string Descripcion        = (string)(reader["Descripcion"]);
                            int    IdSucursal         = (int)(reader["IdSucursal"]);

                            VentanillaModel = new VentanillaModel
                            {
                                Id_ventanilla = ID_VentanillaModel,
                                Descripcion   = Descripcion,
                                Idsucursal    = IdSucursal,
                            };
                        }
                    }
                }

                return(VentanillaModel);
            }
            catch (Exception)
            {
                return(null);
            }
        }
        /// <summary>
        /// Saves a record to the VentanillaModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Insert(VentanillaModel aVentanillaModel, int ID_user)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@pMode", 4);
                    command.Parameters.AddWithValue("@ID_user", ID_user);
                    command.Parameters.AddWithValue("@Descripcion", aVentanillaModel.Descripcion);
                    command.Parameters.AddWithValue("@IdSucursal", aVentanillaModel.Idsucursal);

                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "sp_tVentanilla";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #10
0
        public VentanillaModel GetVentanillaModelxUsuario(int ID_Usuario)
        {
            VentanillaModel VentanillaModel = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();
                    command.Parameters.AddWithValue("@PId_Usuario", ID_Usuario);


                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "SelectVentanillaXUsuario";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            int    ID_VentanillaModel = (int)(reader["ID_Ventanilla"]);
                            string Descripcion        = (string)(reader["Descripcion"]);

                            VentanillaModel = new VentanillaModel
                            {
                                Id_ventanilla = ID_VentanillaModel,
                                Descripcion   = Descripcion
                            };
                        }
                    }
                }

                return(VentanillaModel);
            }
            catch (Exception)
            {
                return(null);
            }
        }
 bool IVentanillaService.Ventanilla_Editar(VentanillaModel aVentanilla, int id_user)
 {
     return(BLVentanila.Editar(aVentanilla, id_user));
 }
예제 #12
0
 public bool Editar(VentanillaModel aVentanilla)
 {
     return(ADVentanillaManager.Update(aVentanilla));
 }
예제 #13
0
 public bool Crear(VentanillaModel aVentanilla)
 {
     return(ADVentanillaManager.Insert(aVentanilla));
 }
예제 #14
0
 public string EliminarVentanilla(VentanillaModel ventanilla)
 {
     return(ADVentanillaManager.EliminarVentanilla(ventanilla));
 }
예제 #15
0
 public Tuple <string, int> GuardarVentanilla(VentanillaModel ventanilla, string usuario)
 {
     return(ADVentanillaManager.GuardarVentanilla(ventanilla, usuario));
 }
예제 #16
0
 bool IVentanillaService.Ventanilla_Crear(VentanillaModel aVentanilla)
 {
     return(BLVentanila.Crear(aVentanilla));
 }
예제 #17
0
        public Tuple <string, int> GuardarVentanilla(VentanillaModel ventanilla, string usuario)
        {
            int    idRegistro = 0;
            string afectados;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;



                    command.Parameters.AddWithValue("@Descripcion", ventanilla.Descripcion);
                    command.Parameters.AddWithValue("@Estado", ventanilla.EstadoVentanilla);
                    command.Parameters.AddWithValue("@Usuario", usuario);
                    command.CommandType = CommandType.StoredProcedure;



                    command.Parameters.Add("@IdRegistro", SqlDbType.Int, 20).Direction = ParameterDirection.Output;
                    command.CommandText = "GuardarVentanilla";

                    object a = command.ExecuteScalar();

                    if (command.Parameters["@IdRegistro"].Value != DBNull.Value)
                    {
                        idRegistro = Convert.ToInt32(command.Parameters["@IdRegistro"].Value);
                    }



                    if (a != null)
                    {
                        afectados = (string)a;
                    }
                    else
                    {
                        afectados = "Ventanilla Guardada";
                    }

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();


                    return(Tuple.Create(afectados, idRegistro));
                }
            }
            catch (SqlException ex)
            {
                idRegistro = 0;
                afectados  = ex.Errors[0].Message.ToString();
                return(Tuple.Create(afectados, idRegistro));
            }
        }
예제 #18
0
 public bool Editar(VentanillaModel aVentanilla, int id_user)
 {
     return(ADVentanillaManager.Update(aVentanilla, id_user));
 }
예제 #19
0
 public bool Crear(VentanillaModel aVentanilla, int id_user)
 {
     return(ADVentanillaManager.Insert(aVentanilla, id_user));
 }
예제 #20
0
 public string ActualizarVentanilla(VentanillaModel ventanilla, string usuario)
 {
     return(ADVentanillaManager.ActualizarVentanilla(ventanilla, usuario));
 }
예제 #21
0
 bool IVentanillaService.Ventanilla_Editar(VentanillaModel aVentanilla)
 {
     return(BLVentanila.Editar(aVentanilla));
 }
예제 #22
0
 public bool ObtenerMovimientos(VentanillaModel aVentanilla, int id_user)
 {
     return(ADVentanillaManager.Insert(aVentanilla, id_user));
 }