示例#1
0
        public IActionResult SaveNotaria([FromBody] FormNotaria entrada)
        {
            if (entrada == null)
            {
                throw new ArgumentNullException(nameof(entrada));
            }

            Notaria notari;

            if (!string.IsNullOrEmpty(entrada.Id) && entrada.Id != null && Convert.ToInt32(entrada.Id) > 0)
            {
                notari        = _context.Notarias.Find(Convert.ToInt32(entrada.Id));
                notari.Nombre = entrada.Nombre;
                notari.Comuna = _context.Comunas.Find(Convert.ToInt32(entrada.Comuna));
                _context.Notarias.Update(notari);
            }
            else
            {
                notari = new Notaria
                {
                    Nombre = entrada.Nombre,
                    Comuna = _context.Comunas.Find(Convert.ToInt32(entrada.Comuna))
                };
                _context.Notarias.Add(notari);
            }

            _context.SaveChanges();

            return(Ok());
        }
示例#2
0
        public List <Notaria> getNotaria()
        {
            try
            {
                using (SqlConnection sqlConn = new SqlConnection(this.strConn))
                {
                    sqlConn.Open();
                    SqlCommand cmd = new SqlCommand(strConn, sqlConn);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "sp_r_notaria";
                    SqlDataReader  reader  = cmd.ExecuteReader();
                    List <Notaria> lmatriz = new List <Notaria>();
                    while (reader.Read())
                    {
                        Notaria mmatriz = new Notaria();

                        mmatriz.Cod_notaria = reader["cod_notaria"].ToString();
                        mmatriz.Nombre      = reader["nombre"].ToString();


                        lmatriz.Add(mmatriz);
                        mmatriz = null;
                    }
                    return(lmatriz);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#3
0
        private void getnotaria(DropDownList combo)
        {
            Notaria mnotaria = new Notaria();

            mnotaria.Cod_notaria = "0";
            mnotaria.Nombre      = "Seleccionar";
            List <Notaria> lmatriz = new NotariaBC().getNotaria();

            lmatriz.Add(mnotaria);
            combo.DataSource     = lmatriz;
            combo.DataValueField = "cod_notaria";
            combo.DataTextField  = "nombre";
            combo.DataBind();
            combo.SelectedValue = "0";
            return;
        }