Exemple #1
0
        public List <Entities.Agenda> ListaAgenda(string Buscar)
        {
            List <Entities.Agenda> list = new List <Entities.Agenda>();

            DataEntities.SpAgendaGrd sp = new DataEntities.SpAgendaGrd();
            sp.Buscar = Buscar;
            DataTable dt = sp.GetDataTable(this.ConnectionString);

            foreach (DataRow dr in dt.Rows)
            {
                Entities.Agenda item = new Entities.Agenda(true);
                item.ID        = Utils.GetDataRowValue(dr, "IdContacto", 0);
                item.Nombre    = Utils.GetDataRowValue(dr, "Nombre", "");
                item.ApPaterno = Utils.GetDataRowValue(dr, "ApPaterno", "");
                item.ApMaterno = Utils.GetDataRowValue(dr, "ApMaterno", "");
                item.Telefeno1 = Utils.GetDataRowValue(dr, "Telefeno1", "");
                item.Telefeno2 = Utils.GetDataRowValue(dr, "Telefeno2", "");
                item.Email     = Utils.GetDataRowValue(dr, "Email", "");
                item.Direccion = Utils.GetDataRowValue(dr, "Direccion", "");

                list.Add(item);
            }

            return(list);
        }
Exemple #2
0
        private void Editar()
        {
            Entities.Agenda Med = Obtener();

            if (Med != null)
            {
                AgendaEdit New = new AgendaEdit();
                New.IdContacto = Med.ID;
                New.ShowDialog();
                LLenarGrid();
            }
        }
Exemple #3
0
 private void Eliminar()
 {
     Entities.Agenda Med = Obtener();
     Business.Agenda bo  = new Business.Agenda();
     if (Med != null)
     {
         DialogResult mnsj = MessageBox.Show("¿Desea eliminar el registro seleccionado?", "", MessageBoxButtons.YesNo);
         if (mnsj == DialogResult.Yes)
         {
             bo.Delete(Med);
             LLenarGrid();
         }
     }
 }
Exemple #4
0
        public override int Delete(Entity entity, DataTransaction tran)
        {
            DataEntities.SpAgendaDel sp   = new DataEntities.SpAgendaDel();
            Entities.Agenda          item = entity as Entities.Agenda;
            sp.IdContacto = item.ID;

            int rowsAffected = 0;

            if (tran != null)
            {
                rowsAffected = sp.ExecuteNonQuery(tran);
            }
            else
            {
                rowsAffected = sp.ExecuteNonQuery(this.ConnectionString);
            } return(rowsAffected);
        }
Exemple #5
0
 private void CargarDatos()
 {
     if (IdContacto != 0)
     {
         Entities.Agenda Med = new Entities.Agenda(true);
         Med.ID = this.IdContacto;
         Business.Agenda bo = new Business.Agenda();
         bo.PrepareEntityForEdition(Med);
         this.txtNombre.Text    = Med.Nombre;
         this.txtApPaterno.Text = Med.ApPaterno;
         this.txtApMaterno.Text = Med.ApMaterno;
         this.txtTel.Text       = Med.Telefeno1;
         this.txtTel2.Text      = Med.Telefeno2;
         this.txtCorreo.Text    = Med.Email;
         this.txtDirecion.Text  = Med.Direccion;
     }
 }
Exemple #6
0
        public override void PrepareEntityForEdition(Entity entity)
        {
            Entities.Agenda          item = entity as Entities.Agenda;
            DataEntities.SpAgendaSel sp   = new DataEntities.SpAgendaSel();
            sp.IdContacto = item.ID;
            DataTable dt = sp.GetDataTable(this.ConnectionString);

            if (dt.Rows.Count == 1)
            {
                DataRow dr = dt.Rows[0];
                item.Nombre    = Utils.GetDataRowValue(dr, "Nombre", "");
                item.ApPaterno = Utils.GetDataRowValue(dr, "ApPaterno", "");
                item.ApMaterno = Utils.GetDataRowValue(dr, "ApMaterno", "");
                item.Telefeno1 = Utils.GetDataRowValue(dr, "Telefeno1", "");
                item.Telefeno2 = Utils.GetDataRowValue(dr, "Telefeno2", "");
                item.Email     = Utils.GetDataRowValue(dr, "Email", "");
                item.Direccion = Utils.GetDataRowValue(dr, "Direccion", "");
            }
        }
Exemple #7
0
        public List <Entities.Agenda> Combo()
        {
            List <Entities.Agenda> list = new List <Entities.Agenda>();

            DataEntities.SpAgendaCmb sp = new DataEntities.SpAgendaCmb();
            DataTable dt = sp.GetDataTable(this.ConnectionString);

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    Entities.Agenda item = new Entities.Agenda(true);
                    item.ID     = Utils.GetDataRowValue(dr, "IdContacto", 0);
                    item.Nombre = Utils.GetDataRowValue(dr, "NombreCompleto", "");
                    list.Add(item);
                }
            }
            return(list);
        }
Exemple #8
0
        public override int Update(Entity entity, DataTransaction tran)
        {
            DataEntities.SpAgendaUpd sp   = new DataEntities.SpAgendaUpd();
            Entities.Agenda          item = entity as Entities.Agenda;
            sp.IdContacto = item.ID;
            sp.Nombre     = item.Nombre;
            sp.ApPaterno  = item.ApPaterno;
            sp.ApMaterno  = item.ApMaterno;
            sp.Telefeno1  = item.Telefeno1;
            sp.Telefeno2  = item.Telefeno2;
            sp.Email      = item.Email;
            sp.Direccion  = item.Direccion;
            int rowsAffected = 0;

            if (tran != null)
            {
                rowsAffected = sp.ExecuteNonQuery(tran);
            }
            else
            {
                rowsAffected = sp.ExecuteNonQuery(this.ConnectionString);
            } return(rowsAffected);
        }
Exemple #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ValidarDatos();
            bool valido;

            Business.Agenda Med = new Business.Agenda();
            valido = ValidarDatos();

            if (valido == true)
            {
                Entities.Agenda M = new Entities.Agenda(IdContacto != 0);
                M.ID        = this.IdContacto;
                M.Nombre    = txtNombre.Text;
                M.ApPaterno = txtApPaterno.Text;
                M.ApMaterno = txtApMaterno.Text;
                M.Telefeno1 = txtTel.Text;
                M.Telefeno2 = txtTel2.Text;
                M.Email     = txtCorreo.Text;
                M.Direccion = txtDirecion.Text;
                Med.Save(M);
                this.Close();
            }
        }