private void button1_Click(object sender, EventArgs e) { if (!validacion()) { return; } rangofle c = new rangofle(); //c.cod= _id; c.vini = Convert.ToDecimal(this.numericUpDown2.Text); c.vfin = Convert.ToDecimal(this.numericUpDown1.Text); c.precio = Convert.ToDecimal(this.textBox1.Text); int recibe = 0; //if (string.IsNullOrEmpty(_id)) recibe = op_rangos.accion1(c, 1); //else //{ // this.textBox1.ReadOnly = true; // recibe = op_rangos.accion(c, 2); //} if (recibe > 0) { MessageBox.Show("Registro Grabado"); operacion(); button1.Enabled = false; //this.label10.Text = "EMPLEADO: " + c.NombreCompleto; } }
private static rangofle Loadrango1(IDataReader reader) { rangofle item = new rangofle(); item.cod = Convert.ToString(reader["cod"]); item.vini = Convert.ToDecimal(reader["vini"]); item.vfin = Convert.ToDecimal(reader["vfin"]); item.precio = Convert.ToDecimal(reader["costo"]); return(item); }
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 eliminar el registro", Application.ProductName.ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Information)); if (a == 6) { rangofle c = new rangofle(); c.cod = row.Cells[0].Value.ToString(); //c.rini = int.Parse(row.Cells[1].Value.ToString()); //c.rfin = int.Parse(row.Cells[2].Value.ToString()); op_rangos.accion1(c, 3); dataGridView1.AutoGenerateColumns = false; dataGridView1.DataSource = op_rangos.GellAllrango3("select * from rangos_fle where cod='" + c.cod + "'"); } } } } 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); } } }
public static int accion1(rangofle c, int op) { int rowsAffected = 0; try { using (MySqlConnection con = new MySqlConnection(ConfigurationManager.ConnectionStrings["default"].ToString())) { con.Open(); MySqlCommand command = new MySqlCommand("SP_rangos_fle", con); command.CommandType = CommandType.StoredProcedure; MySqlParameter paramId = new MySqlParameter("msj", MySqlDbType.Int32); paramId.Direction = ParameterDirection.Output; command.Parameters.Add(paramId); //command.Parameters.AddWithValue("cod1", null); command.Parameters.AddWithValue("vini1", c.vini); command.Parameters.AddWithValue("vfin1", c.vfin); command.Parameters.AddWithValue("costo1", c.precio); command.Parameters.AddWithValue("opc", op); command.ExecuteNonQuery(); rowsAffected = int.Parse(command.Parameters["msj"].Value.ToString()); } } catch (MySqlException ex) { MessageBox.Show("Error de acceso a datos: " + ex.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex1) { MessageBox.Show("Error: " + ex1.Message.ToString(), Application.ProductName.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } return(rowsAffected); }