Exemplo n.º 1
0
 private void SerchPrevista_FormClosed(object sender, FormClosedEventArgs e)
 {
     prv = new Prevista();
     this.Hide();
     fprv.Prev_Load(user, prv);
     fprv.Show();
 }
Exemplo n.º 2
0
        private void previstasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Prevista     pv   = new Prevista();
            frmPrevistas fprv = new frmPrevistas(usu, pv);

            fprv.ShowDialog(this);
        }
Exemplo n.º 3
0
        public bool UpdatePrv(Prevista prv)
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
                {
                    cn.Open();
                    sql = "update asada.prevista set ID_TARIFAS=@CodeRate, ID_ABONADO=@Identification, ID_SECTOR=@Sector, UBICACION=@Ubication, ESTADO=@IsActive where ID_PREVISTA=@Code";
                    cmd.Parameters.Add(new MySqlParameter("@CodeRate", prv.CodeRate));
                    cmd.Parameters.Add(new MySqlParameter("@Identification", prv.Identification));
                    cmd.Parameters.Add(new MySqlParameter("@Sector", prv.Sector));
                    cmd.Parameters.Add(new MySqlParameter("@Ubication", prv.Ubication));
                    cmd.Parameters.Add(new MySqlParameter("@IsActive", prv.IsActive));
                    cmd.Parameters.Add(new MySqlParameter("@Code", prv.Code));
                    result = cmd.ExecuteNonQuery();
                    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;
            }
        }
Exemplo n.º 4
0
        private void btnNewUpdate_Click(object sender, EventArgs e)
        {
            prvDao        = new PrevistaDAO(this.user);
            btnSaveOption = btnNewUpdate.Text;
            if (txtAddress.Text.Trim() == "")
            {
                MessageBox.Show(this, "Se detecto campos vacíos!  Verifique...", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                switch (btnSaveOption)
                {
                case "Guardar":
                    if (prvDao.InsertNew((prv = this.GetInfo())))
                    {
                        MessageBox.Show(this, "Datos almacenados correctamente!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //refrescar el combo de abonados sin prevista
                    }
                    else
                    {
                        MessageBox.Show(this, "Error al guardar los datos!  Verifique...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    break;

                case "Actualizar":
                    prvDao.UpdatePrv((prv = this.GetInfo()));
                    this.ValidUtils(prv);
                    break;
                }
            }
        }
Exemplo n.º 5
0
        public bool InsertNew(Prevista prv)
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
                {
                    cn.Open();

                    sql = "insert into asada.prevista (ID_PREVISTA, ID_TARIFAS, ID_ABONADO, ID_SECTOR, UBICACION, SALDO, ESTADO, TIPO_CEDULA, UBICACION)" +
                          "values(@Code, @CodeRate, @Identification, @ID_Sector, @Saldo, @IsActive, @Nacionality, @Ubication)";
                    cmd = new MySqlCommand(sql, cn);
                    cmd.Parameters.Add(new MySqlParameter("@Code", prv.Code));
                    cmd.Parameters.Add(new MySqlParameter("@CodeRate", prv.CodeRate));
                    cmd.Parameters.Add(new MySqlParameter("@Identification", prv.Identification));
                    cmd.Parameters.Add(new MySqlParameter("@ID_Sector", prv.Sector));
                    cmd.Parameters.Add(new MySqlParameter("@Saldo", prv.Balance));
                    cmd.Parameters.Add(new MySqlParameter("IsActive", prv.IsActive));
                    cmd.Parameters.Add(new MySqlParameter("@Nacionality", prv.Nacionality));
                    cmd.Parameters.Add(new MySqlParameter("Ubication", prv.Ubication));
                    result = cmd.ExecuteNonQuery();
                    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;
            }
        }
Exemplo n.º 6
0
        public Prevista SerchOnePrevista(string id)
        {
            try
            {
                using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
                {
                    cn.Open();
                    sql = "select * from asada.prevista where ID_PREVISTA=@id";
                    cmd = new MySqlCommand(sql, cn);
                    cmd.Parameters.AddWithValue("id", id);
                    reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        pre                = new Prevista();
                        pre.Code           = reader.GetString(0);
                        pre.CodeRate       = reader.GetString(1);
                        pre.Identification = reader.GetString(2);
                        pre.Sector         = reader.GetString(3);
                        pre.Balance        = float.Parse(reader.GetString(4));
                        pre.IsActive       = bool.Parse(reader.GetString(5));
                        pre.Nacionality    = reader.GetString(6);
                        pre.Ubication      = reader.GetString(7);
                    }
                    reader.Close();
                    return(pre);
                }
            }
            catch (Exception e)
            {
                Logs lg = new Logs();
                lg.Log(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + ", " + e.Message.ToString());

                throw;
            }
        }
Exemplo n.º 7
0
        private Prevista GetInfo()
        {
            prv                = new Prevista();
            trf                = new Tarifa();
            prv.Code           = txtCode.Text.Trim();
            prv.CodeRate       = cbxRate.SelectedIndex.ToString();
            prv.Sector         = cbxSector.SelectedValue.ToString();
            prv.Identification = cbxAbonado.SelectedValue.ToString();

            int n = cbxRate.SelectedIndex;

            if (n == 0)
            {
                trf.TypeApplication = true;
                prv.IsActive        = true;
            }
            else
            {
                trf.TypeApplication = false;
                prv.IsActive        = false;
            }

            prv.Ubication = txtAddress.Text;

            return(prv);
        }
Exemplo n.º 8
0
 public frmPrevistas(Usuario usu, Prevista pv)
 {
     InitializeComponent();
     this.user = usu;
     this.prv  = pv;
     this.ValidUtils(prv);
     this.Prev_Load(usu, prv);
 }
Exemplo n.º 9
0
        //Método de actualizar una prevista
        public void actualizar(int Id, int IdAbonado, int IdTarifa, int IdSector, string Direccion, string FolioReal)
        {
            Prevista prevista = this.encontrarPorId(Id);

            prevista.IdAbonado = IdAbonado;
            prevista.IdTarifa  = IdTarifa;
            prevista.IdSector  = IdSector;
            prevista.Direccion = Direccion;
            prevista.FolioReal = FolioReal;
            this.contexto.SaveChanges();
        }
Exemplo n.º 10
0
 private void SerchPrevista_Load(object sender, EventArgs e)
 {
     prv    = new Prevista();
     dt     = new DataTable();
     dts    = new DataSet();
     prvDao = new PrevistaDAO(this.user);
     // Con la información del adaptador se rellena el DataTable
     prvDao.LoadPrevista().Fill(dt);
     dts.Tables.Add(dt);
     // Se asigna el DataTable como origen de datos del DataGridView
     dataGridView1.DataSource = dts.Tables[0];
 }
Exemplo n.º 11
0
 //Evento del datagrid para seleccionar una prevista
 private void DgPrevistas_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     this.actualPrevista = this.DgPrevistas.CurrentItem as Prevista;
     if (null == this.actualPrevista)
     {
         return;
     }
     this.actualPrevista           = this.DgPrevistas.CurrentItem as Prevista;
     this.cmbAbonado.SelectedValue = Convert.ToInt32(this.actualPrevista.IdAbonado);
     this.cmbTarifa.SelectedValue  = Convert.ToInt32(this.actualPrevista.IdTarifa);
     this.cmbSector.SelectedValue  = Convert.ToInt32(this.actualPrevista.IdSector);
     this.txtDireccion.Text        = this.actualPrevista.Direccion;
     this.txtFolio.Text            = this.actualPrevista.FolioReal;
     this.habilitarCampos(false);
 }
Exemplo n.º 12
0
        private bool ValidUtils(Prevista pv)
        {
            prv = new Prevista();
            prv = pv;

            if (pv.Code == null)
            {
                btnNewUpdate.Text = "Guardar";
                return(false);
            }
            else
            {
                btnNewUpdate.Text     = "Actualizar";
                checkBoxState.Checked = true;

                return(true);
            }
        }
Exemplo n.º 13
0
 public MySqlDataAdapter LoadPrevista()
 {
     try
     {
         using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
         {
             pre = new Prevista();
             cn.Open();
             sql = "select * from asada.view_previstas";
             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;
     }
 }
Exemplo n.º 14
0
        public void Prev_Load(Usuario usu, Prevista prv)
        {
            // Llena el combobox tarifas
            //trfDao = new TarifaDAO(this.user);
            //cbxRate.DisplayMember = "TypeAppString";
            //cbxRate.ValueMember = "Code";
            //cbxRate.DataSource = trfDao.LoadTarifa();
            cbxRate.Items.Add("Mensual Fija");
            cbxRate.Items.Add("Metros Cúbicos");
            cbxRate.SelectedItem = 0;

            // LLena el combo de Abonados
            abnDao = new AbonadoDAO(this.user);
            cbxAbonado.DisplayMember = "Name";
            cbxAbonado.ValueMember   = "Identification";
            if (abnDao.LoadAbonado1().Count > 0)
            {
                cbxAbonado.DataSource = abnDao.LoadAbonado1();
            }
            else
            {
                MessageBox.Show("No hay abonados disponibles para asignar a las previstas!", "Atención");
                //mostrar popup, notificacion o mensaje en un label o formulario, por al menos 3 segundos
            }

            // obtiene el consecutivo de previstas
            prvDao           = new PrevistaDAO(this.user);
            txtCode.Text     = prvDao.ConsecutivePrv().ToString();
            txtCode.ReadOnly = true;
            txtCode.Enabled  = false;

            // se obtienen y establecen los sectores
            secDao = new SectorDAO(this.user);
            cbxSector.DisplayMember = "Description";
            cbxSector.ValueMember   = "Code";
            cbxSector.DataSource    = secDao.LoadSector();
        }
Exemplo n.º 15
0
        public void encontrarPorId()
        {
            Prevista prevista = this.previstas.encontrarPorId(this.Id);

            Console.WriteLine("Prevista encontrada: " + prevista.Id.ToString());
        }