internal bool MtdAgregarEmpleado(Cls_E_Proveedor objE) { try { ClsConexionSQL objConexion = new ClsConexionSQL(); SqlCommand objComando = new SqlCommand(); objComando.Connection = objConexion.conectar(); objComando.CommandText = "USP_I_AgregarProveedor"; objComando.CommandType = CommandType.StoredProcedure; objComando.Parameters.Add(new SqlParameter("ruc", SqlDbType.VarChar)); objComando.Parameters.Add(new SqlParameter("des", SqlDbType.VarChar)); objComando.Parameters.Add(new SqlParameter("est", SqlDbType.VarChar)); objComando.Parameters["ruc"].Value = objE.Ruc; objComando.Parameters["des"].Value = objE.Descripcion.ToUpper(); objComando.Parameters["est"].Value = objE.Estado; objComando.Connection = objConexion.conectar(); objComando.ExecuteNonQuery(); return(true); } catch (Exception ex) { return(false); throw ex; } }
private void DgProveedor_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (this.dgProveedor.Columns[e.ColumnIndex].Name == "Guardar") { if (MessageBox.Show("¿Seguro que desea Agregar?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { { foreach (DataRow fila in proveedor.Rows) { if (dgProveedor.CurrentRow.Cells[0].Value.ToString() == fila[0].ToString()) { modificar = true; bool existir = false; Cls_E_Proveedor objE = new Cls_E_Proveedor(); objE.Ruc = dgProveedor.CurrentRow.Cells[0].Value.ToString(); objE.Descripcion = dgProveedor.CurrentRow.Cells[1].Value.ToString(); objE.Estado = dgProveedor.CurrentRow.Cells[2].Value.ToString(); Cls_N_Proveedor objN = new Cls_N_Proveedor(); existir = objN.MtdActualizarEmpleado(objE); if (existir == true) { MessageBox.Show("Modificado exitosamente"); btnRefrescar.PerformClick(); dgProveedor.Columns[0].ReadOnly = true; } break; } else { bool existir; Cls_E_Proveedor objE = new Cls_E_Proveedor(); objE.Ruc = dgProveedor.CurrentRow.Cells[0].Value.ToString(); objE.Descripcion = dgProveedor.CurrentRow.Cells[1].Value.ToString(); objE.Estado = dgProveedor.CurrentRow.Cells[2].Value.ToString(); Cls_N_Proveedor objN = new Cls_N_Proveedor(); existir = objN.MtdAgregarEmpleado(objE); if (existir == true) { MessageBox.Show("Guardado exitosamente"); btnRefrescar.PerformClick(); dgProveedor.Columns[0].ReadOnly = true; } } } } } } else if (this.dgProveedor.Columns[e.ColumnIndex].Name == "Deshabilitar") { dgProveedor.CurrentRow.Cells[2].Value = "0"; mtdPintar(); } } catch { //nada } }