Пример #1
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.ColumnIndex >= 0)
         {
             DataGridViewRow row = dataGridView1.CurrentRow as DataGridViewRow;
             //this.toolStripLabel1.Text = row.Cells[0].Value.ToString();
             if (this.dataGridView1.Columns[e.ColumnIndex].Name == "eli")
             {
                 int a = Convert.ToInt32(MessageBox.Show("Está seguro que desea ANULAR el registro", Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Information));
                 if (a == 6)
                 {
                     op_distancias.distancias c = new op_distancias.distancias();
                     for (int i = 0; i < 5; i++)
                     {
                         c.tip1 = row.Cells[0].Value.ToString();
                     }
                     c.lug1 = row.Cells[1].Value.ToString();
                     c.tip2 = row.Cells[2].Value.ToString();
                     c.lug2 = row.Cells[3].Value.ToString();
                     op_sql.parametro1(@"DELETE FROM `logicop`.`distancias` WHERE `tip1` = '" + c.tip1 + "' and `lug1` = '" + c.lug1 + "' and `tip2` = '" + c.tip2 + "' AND `lug2` = '" + c.lug2 + "';");
                     this.dataGridView1.AutoGenerateColumns = false;
                     this.dataGridView1.DataSource          = op_distancias.GellAlldistancias();
                 }
             }
         }
     }
     catch (MySqlException ex)
     {
         if (ex.Number == 1451)
         {
             MessageBox.Show("El dato está siendo utilizado, por lo tanto es imposible de eliminar", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             MessageBox.Show(ex.Message, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool recibe1, recibe2 = false;

            if (!validacion())
            {
                return;
            }
            op_distancias.distancias a = new op_distancias.distancias();
            a.lug1 = this.comboBox2.Text;
            a.lug2 = this.comboBox3.Text;
            a.tip1 = this.comboBox1.Text;
            a.tip2 = this.comboBox4.Text;
            a.cant = int.Parse(this.textBox1.Text);

            if (a.lug1 == a.lug2)
            {
                MessageBox.Show("El lugar debe ser diferente", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            recibe1 = op_sql.comprobar("SELECT * FROM distancias WHERE `tip1` = '" + a.tip1 + "' and`lug1` = '" + a.lug1 + "' and`tip2` = '" + a.tip2 + "' and `lug2` = '" + a.lug2 + "'");
            if (recibe1)
            {
                MessageBox.Show(mensajes.MsjProc4, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            recibe2 = op_sql.comprobar("SELECT * FROM distancias WHERE `tip1` = '" + a.tip2 + "' and`lug1` = '" + a.lug2 + "' and`tip2` = '" + a.tip1 + "' and `lug2` = '" + a.lug1 + "'");
            if (recibe2)
            {
                MessageBox.Show("El origen y el destino se aplica de forma viceversa", Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            int c = op_distancias.accion(a, 1);

            if (c > 0)
            {
                if (c == 1)
                {
                    MessageBox.Show(mensajes.MsjProc1, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    borrar();
                }
                if (c == 2)
                {
                    MessageBox.Show(mensajes.MsjProc2, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    borrar();
                }
                if (c == 3)
                {
                    MessageBox.Show(mensajes.MsjProc3, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    borrar();
                }
                if (c == 4)
                {
                    //if (MessageBox.Show(mensajes.MsjProc4 + " " + mensajes.MsjProc5, Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    //{
                    //    rowsAffected = op_equipos.accion(a, 2);
                    //}
                    MessageBox.Show(mensajes.MsjProc4 + " " + mensajes.MsjProc5, Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show(mensajes.MsjProc0, Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            status fr = new status();

            fr.Show("Cargando Datos");
            this.dataGridView1.AutoGenerateColumns = false;
            this.dataGridView1.DataSource          = op_distancias.GellAlldistancias();
        }