コード例 #1
0
ファイル: dPersona.cs プロジェクト: marriagap/Argentino
        public DataTable ConsultarXSegundoNombre(csPersona p)
        {
            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = con.getConexion();
                    cmd.CommandText = "operar_Tabla";

                    cmd.Parameters.AddWithValue("tabla", "Persona");
                    cmd.Parameters.AddWithValue("parm", p.Apellidos);
                    cmd.Parameters.AddWithValue("t_accion", "C");
                    cmd.Parameters.AddWithValue("att", "Apellido_NE");
                    cmd.Parameters.AddWithValue("cod", -1);

                    con.getConexion().Open();

                    DataTable        dt = new DataTable();
                    MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                    da.Fill(dt);
                    return(dt);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    con.getConexion().Close();
                }
            }
        }
コード例 #2
0
ファイル: dPersona.cs プロジェクト: marriagap/Argentino
        /**********************************ELIMINACION******************************/
        public void EliminarPersona(csPersona p)
        {
            using (MySqlCommand cmd = new MySqlCommand())
            {
                try
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Connection  = con.getConexion();
                    cmd.CommandText = "operar_Tabla";

                    cmd.Parameters.AddWithValue("tabla", "Persona");
                    cmd.Parameters.AddWithValue("parm", p.Eliminado);
                    cmd.Parameters.AddWithValue("t_accion", "E");
                    cmd.Parameters.AddWithValue("att", "Eliminado");
                    cmd.Parameters.AddWithValue("cod", p.IdPersona);

                    con.getConexion().Open();
                    e = cmd.ExecuteNonQuery();
                    if (e == 0)
                    {
                        MessageBox.Show("No se pudo realizar la Modificación, ERROR!");
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    con.getConexion().Close();
                }
            }
        }
コード例 #3
0
ファイル: dPersona.cs プロジェクト: marriagap/Argentino
        /****************************INSERCIONES****************************/
        public void InsertarNuevaPersona(csPersona p)
        {
            string sqlquery =
                "INSERT INTO FACTORES(primerNombre,segundoNombre,fechaNacimiento,direccionRasonSocial,telefono,nroIdentificacion,tipoIdentificacion,fechaRegistro,eliminado)"
                + "VALUES(@primerNombre,@segundoNombre,@fechaNacimiento,@direccionRasonSocial,@telefono,@nroIdentificacion,@tipoIdentificacion,@fechaRegistro,@eliminado)";
            MySqlConnection cn = con.getConexion();

            cn.Open();

            try
            {
                MySqlCommand cmd = new MySqlCommand(sqlquery, con.getConexion());
                cmd.Parameters.Add("@primerNombre", p.Nombres);
                cmd.Parameters.Add("@segundoNombre", p.Apellidos);
                cmd.Parameters.Add("@fechaNacimiento", p.FchNacimiento);
                cmd.Parameters.Add("@direccionRasonSocial", p.DireccionRasonSocial);
                cmd.Parameters.Add("@telefono", p.Telefono);
                cmd.Parameters.Add("@nroIdentificacion", p.NroIdentificacion);
                cmd.Parameters.Add("@tipoIdentificacion", p.TipoIdentificacion);
                cmd.Parameters.Add("@fechaRegistro", p.FechaRegistro);
                cmd.Parameters.Add("@eliminado", p.Eliminado);
                cmd.ExecuteNonQuery();

                cmd.Parameters.Clear();
                cmd.CommandText = "SELECT @@IDENTITY";

                int ID_Insertado = Convert.ToInt32(cmd.ExecuteScalar());

                cmd.Dispose();
                cmd = null;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString(), ex);
            }
            finally
            {
                cn.Close();
            }
            MessageBox.Show("La Inserción se realizó Existosamente!");
        }