Exemplo n.º 1
0
 private void btnAddAddres_Click(object sender, EventArgs e)
 {
     if (txtAddAddress.Text.Equals(""))
     {
         MessageBox.Show("Direccion agregada con exito", "Error", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
     else
     {
         ADDRESS address = new ADDRESS();
         address.idUser  = usuario.idUser;
         address.address = txtAddAddress.Text;
         try
         {
             ConsultaADDRESS.Add(address);
             this.Close();
             MessageBox.Show("Acceso concedido, Binevenido", "Confirmacion", MessageBoxButtons.OK,
                             MessageBoxIcon.Asterisk);
         }
         catch (Exception exception)
         {
             MessageBox.Show("Ha ocurrido un error", "ERROR",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        private void btnDeleteAddress_Click(object sender, EventArgs e)
        {
            string  dir = (string)cmbAddress.SelectedItem;
            ADDRESS ad  = new ADDRESS();

            foreach (var d in list)
            {
                if (d.address.Equals(dir))
                {
                    ad.address   = d.address;
                    ad.idAddress = d.idAddress;
                    ad.idUser    = d.idUser;
                }
            }

            try
            {
                string sql = "DELETE FROM ADDRESS WHERE idAddress = " + ad.idAddress;
                ConnectionDB.ExecuteNonQuery(sql);
                this.Close();
                MessageBox.Show("Direccion eliminada con exito", "Confirmacion", MessageBoxButtons.OK,
                                MessageBoxIcon.Asterisk);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ha ocurrido un error", "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void btnAddOrder_Click(object sender, EventArgs e)
        {
            string  dir = (string)cmbSAddress.SelectedItem;
            ADDRESS ad  = new ADDRESS();

            foreach (var d in list)
            {
                if (d.address.Equals(dir))
                {
                    ad.address   = d.address;
                    ad.idAddress = d.idAddress;
                    ad.idUser    = d.idUser;
                }
            }

            string  dira = (string)cmbProducts.SelectedItem;
            PRODUCT ada  = new PRODUCT();

            foreach (var d in lista)
            {
                if (d.name.Equals(dira))
                {
                    ada.idProduct  = d.idProduct;
                    ada.idBusiness = d.idBusiness;
                    ada.name       = d.name;
                }
            }

            APPORDER NOrder = new APPORDER();
            DateTime today  = DateTime.Today;
            string   fecha  = today.ToString("yyyy/MM/dd");

            NOrder.createDate = DateTime.Today;
            NOrder.idProduct  = ada.idProduct;
            NOrder.idAddress  = ad.idAddress;

            try
            {
                string sql = String.Format("INSERT INTO APPORDER(createDate, idProduct, idAddress) " +
                                           "VALUES('{0}', {1}, {2});", fecha, NOrder.idProduct, NOrder.idAddress);
                ConnectionDB.ExecuteNonQuery(sql);
                this.Close();
                MessageBox.Show("Orden agregada exitosamente", "Confirmacion", MessageBoxButtons.OK,
                                MessageBoxIcon.Asterisk);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ha ocurrido un error", "ERROR",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
        private void btnUpdateAddress_Click(object sender, EventArgs e)
        {
            if (txtNewA.Text.Equals(""))
            {
                MessageBox.Show("No puede dejar campos vacios", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                string  dir = (string)cmbAddress.SelectedItem;
                ADDRESS ad  = new ADDRESS();
                foreach (var d in list)
                {
                    if (d.address.Equals(dir))
                    {
                        ad.address   = d.address;
                        ad.idAddress = d.idAddress;
                        ad.idUser    = d.idUser;
                    }
                }

                try
                {
                    string sql = String.Format("UPDATE ADDRESS SET address = '{0}' WHERE idAddress = "
                                               + ad.idAddress, txtNewA.Text).ToString();
                    ConnectionDB.ExecuteNonQuery(sql);
                    this.Close();
                    MessageBox.Show("Direccion actualizada con exito", "Confirmacion", MessageBoxButtons.OK,
                                    MessageBoxIcon.Asterisk);
                }
                catch (Exception exception)
                {
                    MessageBox.Show("Ha ocurrido un error", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }