예제 #1
0
파일: frmAbonados.cs 프로젝트: GCA7/Asada07
 public frmAbonados(Usuario us, Abonado ab)
 {
     InitializeComponent();
     this.usu = us;
     this.abo = ab;
     this.Abo_Load(abo,usu);
 }
예제 #2
0
 public MySqlDataAdapter LoadAbonado()
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             abo = new Abonado();
             cn.Open();
             sql = "select * from asada.view_abonados";
             cmd = new MySqlCommand(sql, cn);                    
             MySqlDataAdapter dt = new MySqlDataAdapter(sql, cn);                    
             return dt;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
파일: AbonadoDAO.cs 프로젝트: GCA7/Asada07
        public bool InsertNew(Abonado abo)
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
                {
                    cn.Open();

                    if (!Exist(abo))
                    {
                        sql = "insert into asada.abonados (ID_ABONADO, NOMBRE, APELLIDO1, APELLIDO2, MOVIL, TELEFONO, EMAIL, FECHA_REGISTRO, DIRECCION)" +
                        "values (@Identification, @Name, @Firstname, @Lastname, @Movil, @Phonenum, @Email, @Dateregister, @Address)";
                        cmd = new MySqlCommand(sql, cn);
                        cmd.Parameters.Add(new MySqlParameter("@Identification", abo.Identification));
                        cmd.Parameters.Add(new MySqlParameter("@Name", abo.Name));
                        cmd.Parameters.Add(new MySqlParameter("@Firstname", abo.Firstname));
                        cmd.Parameters.Add(new MySqlParameter("@Lastname", abo.Lastname));
                        cmd.Parameters.Add(new MySqlParameter("@Movil", abo.Movil));
                        cmd.Parameters.Add(new MySqlParameter("@Phonenum", abo.Phonenum));
                        cmd.Parameters.Add(new MySqlParameter("@Email", abo.Email));
                        cmd.Parameters.Add(new MySqlParameter("@Dateregister", abo.Dateregister));
                        cmd.Parameters.Add(new MySqlParameter("@Addres", abo.Address));
                        result = cmd.ExecuteNonQuery();
                        return result > 0;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                Logs lg = new Logs();
                lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());

                return false;
                throw;
            }
        }
예제 #4
0
파일: AbonadoDAO.cs 프로젝트: GCA7/Asada07
        public MySqlDataAdapter LoadAbonado()
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
                {
                    abo = new Abonado();
                    cn.Open();
                    sql = "select * from asada.view_abonados";
                    cmd = new MySqlCommand(sql, cn);
                    MySqlDataAdapter dt = new MySqlDataAdapter(sql, cn);
                    return dt;
                }
            }
            catch (Exception e)
            {
                Logs lg = new Logs();
                lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());

                throw;
            }
        }
예제 #5
0
파일: frmAbonados.cs 프로젝트: GCA7/Asada07
        public void Abo_Load(Abonado ab, Usuario user)
        {
            abo = new Abonado();
            abo = ab;

            if (radioButton1.Checked == true)
            {
                MtxtIdentification.Mask = "00-0000-0000";
                
            }
            else
            {
                MtxtIdentification.Mask = "00-0000-0000-0000-0000";
            }

            if (abo.Identification == null)
            {
                btnSaveUpdate.Text = "Guardar";
                MtxtIdentification.Enabled = true;   // txt modo sin edicion
                MtxtIdentification.ReadOnly = false; // txt modo solo lectura 
                return;
            }
            else
            {
                btnSaveUpdate.Text = "Editar";
                MtxtIdentification.AppendText(abo.Identification.ToString());
                MtxtIdentification.Enabled = false; 
                MtxtIdentification.ReadOnly = true; 
                TxtName.Text = abo.Name.ToString();
                TxtFirstN.Text = abo.Firstname.ToString();
                TxtLastN.Text = abo.Lastname.ToString();
                MtxtMovil.Text = abo.Movil.ToString();
                MtxtPhone.AppendText(abo.Phonenum.ToString());
                TxtEmail.Text = abo.Email.ToString();
                dateTimePicker1.Text = abo.Dateregister.ToString();
                TxtAddress.Text = abo.Address.ToString();
            }            
        }
예제 #6
0
파일: AbonadoDAO.cs 프로젝트: GCA7/Asada07
 public Abonado SerchOneAbonado(string id)
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             cn.Open();
             sql = "select * from asada.abonados where ID_ABONADO=@Identification";
             cmd = new MySqlCommand(sql, cn);
             cmd.Parameters.Add(new MySqlParameter("@Identification", id));
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 abo = new Abonado();
                 abo.Identification = reader.GetString(0);
                 abo.Name = reader.GetString(1);
                 abo.Firstname = reader.GetString(2);
                 abo.Lastname = reader.GetString(3);
                 abo.Movil = reader.GetString(4);
                 abo.Phonenum = reader.GetString(5);
                 abo.Email = reader.GetString(6);
                 abo.Dateregister = reader.GetString(7);
                 abo.Address = reader.GetString(8);
             }
             reader.Close();
             return abo;
         }
     }
     catch (Exception e)
     {
         Asada.DAO.Logs lg = new Asada.DAO.Logs();
         lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());
         throw;
     }
 }
예제 #7
0
파일: AbonadoDAO.cs 프로젝트: GCA7/Asada07
 public List<Abonado> LoadAbonado1()
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             listAbo = new List<Abonado>();
             cn.Open();
             sql = "select * from asada.vw_abonados";
             cmd = new MySqlCommand(sql, cn);
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 abo = new Abonado();
                 abo.Identification = reader.GetString(0);
                 abo.Name = reader.GetString(1);
                 listAbo.Add(abo);
             }
             reader.Close();
             return listAbo;
         }
     }
     catch (Exception e)
     {
         Logs lg = new Logs();
         lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());
         throw;
     }
 }
예제 #8
0
파일: AbonadoDAO.cs 프로젝트: GCA7/Asada07
 private bool Exist(Abonado abo)
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             cn.Open();
             sql = "select count(ID_ABONADO) from asada.abonados where ID_ABONADO=@Identification";
             cmd = new MySqlCommand(sql, cn);
             cmd.Parameters.Add(new MySqlParameter("@Identification", abo.Identification));
             result = Int32.Parse(cmd.ExecuteScalar().ToString());
             return result > 0;
         }
     }
     catch (Exception e)
     {
         Logs lg = new Logs();
         lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());
         return false;
         throw;
     }
 }
예제 #9
0
 public bool Delete(Abonado abo)
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             cn.Open();
             sql = "delete from asada.abonados where ID_ABONADO=@Identification";
             cmd = new MySqlCommand(sql, cn);
             cmd.Parameters.Add(new MySqlParameter("@Identifcation", abo.Identification));
             result = cmd.ExecuteNonQuery();
             return result > 0;
         }
     }
     catch (Exception)
     {
         return false;
         throw;
     }
 }
예제 #10
0
 private void OutAction()
 {
     abo = new Abonado();
     frmAbo = (frmAbonados)this.Owner;
     frmAbo.Abo_Load(abo, usu);
     frmAbo.Show();
 }
예제 #11
0
 private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     abo = GetInfo();
     this.Hide();
     frmAbo = (frmAbonados)this.Owner;
     frmAbo.Abo_Load(abo,usu);
     frmAbo.Show();
 }
예제 #12
0
파일: frmAbonados.cs 프로젝트: GCA7/Asada07
        private void btnSaveUpdate_Click(object sender, EventArgs e)
        {
            btnSaveOption = btnSaveUpdate.Text;
            aboDao = new AbonadoDAO(this.usu);
            if (TxtName.Text.Trim() == "" || TxtFirstN.Text.Trim() == "" || TxtLastN.Text.Trim() == "" || MtxtPhone.Text.Trim() == "" || TxtAddress.Text == "")
            {
                MessageBox.Show(this, "Campos en blanco detectados, verifique!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {

                switch (btnSaveOption)
                {
                    case "Guardar":                        
                        if (!aboDao.InsertNew((abo = GetInfo())))
                        {
                            MessageBox.Show(this, "El número de identificación ya existe!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            MessageBox.Show(this, "Usuario agregado correctamente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.ReseTextBox();
                        }
                        break;

                    case "Editar":
                        aboDao.Update((abo = GetInfo()));
                        MessageBox.Show(this, "Datos actualizados correctamente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        abo = new Abonado();
                        this.ReseTextBox();
                        break;
                }
            }
        }
예제 #13
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     aboDao = new AbonadoDAO(this.usu);
     if (TxtName.Text.Trim() == "" || TxtFirstN.Text.Trim() == "" || TxtLastN.Text.Trim() == "" || MtxtPhone.Text.Trim() == "" || TxtAddress.Text == "")
     {
         MessageBox.Show(this, "Campos en blanco detectados, verifique!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         if (aboDao.Delete((abo = GetInfo())))
         {
             MessageBox.Show(this, "Usuario eliminado correctamente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             MessageBox.Show(this, "No se puede eliminar el usuario por motivo de ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }
예제 #14
0
 public bool Update(Abonado abo)
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             cn.Open();
             sql = "update asada.abonados set NOMBRE=@Name, APELLIDO1=@Firstname, APELLIDO2=@Lastname, MOVIL=@Movil, TELEFONO=@Phonenum, EMAIL=@Email, FECHA_REGISTRO=@Dateregister, DIRECCION=@Address where ID_ABONADO=@Identification";
             cmd = new MySqlCommand(sql, cn);
             cmd.Parameters.Add(new MySqlParameter("@Name", abo.Name));
             cmd.Parameters.Add(new MySqlParameter("@Firstname", abo.Firstname));
             cmd.Parameters.Add(new MySqlParameter("@Lastname", abo.Lastname));
             cmd.Parameters.Add(new MySqlParameter("@Movil", abo.Movil));
             cmd.Parameters.Add(new MySqlParameter("@Phonenum", abo.Phonenum));
             cmd.Parameters.Add(new MySqlParameter("@Email", abo.Email));
             cmd.Parameters.Add(new MySqlParameter("@Dateregister", abo.Dateregister));
             cmd.Parameters.Add(new MySqlParameter("@Address", abo.Address));
             cmd.Parameters.Add(new MySqlParameter("@Identification", abo.Identification));
             result = cmd.ExecuteNonQuery();
             return result > 0;    
         }                
     }
     catch (Exception)
     {
         return false;
         throw;
     }
 }
예제 #15
0
 public List<Abonado> LoadAbonado1()
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             listAbo = new List<Abonado>();
             cn.Open();
             sql = "select * from asada.vw_abonados";
             cmd = new MySqlCommand(sql, cn);
             reader = cmd.ExecuteReader();
             while (reader.Read())
             {
                 abo = new Abonado();
                 abo.Identification = reader.GetString(0);
                 abo.Name = reader.GetString(1);
                 listAbo.Add(abo);
             }
             reader.Close();
             return listAbo;
         }
     }
     catch (Exception)
     {                
         throw;
     }
 }
예제 #16
0
 private void SerchAbonado_Load(object sender, EventArgs e)
 {
     aboDao = new AbonadoDAO(usu);
     abo = new Abonado();
     dt = new DataTable();
     dts = new DataSet();
     // Con la información del adaptador, desde el metodo cargaAbonado se rellena el DataTable
     aboDao.LoadAbonado().Fill(dt);
     dts.Tables.Add(dt);
     // Se asigna el DataTable como origen de datos del DataGridView
     dataGridView1.DataSource = dts.Tables[0];
 }
예제 #17
0
파일: frmAbonados.cs 프로젝트: GCA7/Asada07
 private Abonado GetInfo()
 {
     abo = new Abonado();
     abo.Identification = MtxtIdentification.Text;
     abo.Name = TxtName.Text;
     abo.Firstname = TxtFirstN.Text;
     abo.Lastname = TxtLastN.Text;
     abo.Movil = MtxtMovil.Text;
     abo.Phonenum = MtxtPhone.Text;
     abo.Email = TxtEmail.Text;
     abo.Address = TxtAddress.Text;            
     abo.Dateregister = dateTimePicker1.Value.ToString("yyyy/MM/dd");
     return abo;
 }
예제 #18
0
 private void BtnAccept_Click(object sender, EventArgs e)
 {
     abo = GetInfo();
     this.Hide();
     frmAbo = (frmAbonados)this.Owner;
     frmAbo.Abo_Load(abo, usu);
     frmAbo.Show();
 }
예제 #19
0
파일: AbonadoDAO.cs 프로젝트: GCA7/Asada07
        public bool Update(Abonado abo)
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
                {
                    cn.Open();
                    sql = "update asada.abonados set NOMBRE=@Name, APELLIDO1=@Firstname, APELLIDO2=@Lastname, MOVIL=@Movil, TELEFONO=@Phonenum, EMAIL=@Email, FECHA_REGISTRO=@Dateregister, DIRECCION=@Address where ID_ABONADO=@Identification";
                    cmd = new MySqlCommand(sql, cn);
                    cmd.Parameters.Add(new MySqlParameter("@Name", abo.Name));
                    cmd.Parameters.Add(new MySqlParameter("@Firstname", abo.Firstname));
                    cmd.Parameters.Add(new MySqlParameter("@Lastname", abo.Lastname));
                    cmd.Parameters.Add(new MySqlParameter("@Movil", abo.Movil));
                    cmd.Parameters.Add(new MySqlParameter("@Phonenum", abo.Phonenum));
                    cmd.Parameters.Add(new MySqlParameter("@Email", abo.Email));
                    cmd.Parameters.Add(new MySqlParameter("@Dateregister", abo.Dateregister));
                    cmd.Parameters.Add(new MySqlParameter("@Address", abo.Address));
                    cmd.Parameters.Add(new MySqlParameter("@Identification", abo.Identification));
                    result = cmd.ExecuteNonQuery();

                    if (result > 0) // ¿ verificar estas líneas?
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
            catch (Exception e)
            {
                Logs lg = new Logs();
                lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());
                return false;
                throw;
            }
        }
예제 #20
0
        private Abonado GetInfo()
        {
            //abo.Identification = dataGridView1.CurrentRow.Cells[0].Value.ToString();  
            //abo.Name = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            //abo.Firstname = dataGridView1.CurrentRow.Cells[2].Value.ToString();      
            //abo.Lastname = dataGridView1.CurrentRow.Cells[3].Value.ToString();
            //abo.Movil = dataGridView1.CurrentRow.Cells[4].Value.ToString();         
            //abo.Phonenum = dataGridView1.CurrentRow.Cells[5].Value.ToString();
            //abo.Email = dataGridView1.CurrentRow.Cells[6].Value.ToString();        
            //abo.Dateregister = dataGridView1.CurrentRow.Cells[7].Value.ToString();
            //abo.Address = dataGridView1.CurrentRow.Cells[8].Value.ToString(); 
            //forma anterior de buscar, no permitia filtrar columna por ambos apellidos

            abo = aboDao.SerchOneAbonado(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            return abo;
        }
예제 #21
0
파일: Principal.cs 프로젝트: GCA7/Asada07
 private void asociadosToolStripMenuItem_Click(object sender, EventArgs e)
 {
     abo = new Abonado();
     frmAbo = new frmAbonados(usu, abo);
     frmAbo.ShowDialog(this);
 }