private void btnEliminar_Click(object sender, EventArgs e) { try { DialogResult Opcion; Opcion = MessageBox.Show("Realmente quieres eliminar los registros", "Sistema RRHH", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { string Codigo; string Rpta = ""; foreach (DataGridViewRow row in dataListado.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { Codigo = Convert.ToString(row.Cells[1].Value); Rpta = NCandidatos.Eliminar(Convert.ToInt32(Codigo)); if (Rpta.Equals("OK")) { this.MensajeOk("Se elimino correctamente el registro"); } else { this.MensajeError(Rpta); } } } this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
//Metodo BuscarNombre private void BuscarNombre() { this.dataListado.DataSource = NCandidatos.BuscarNombre(this.txtBuscar.Text); this.OcultarColumnas(); lblTotal.Text = "Total de registro: " + Convert.ToString(dataListado.Rows.Count); }
private void btnGuardar_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtCedula.Text == string.Empty) { MensajeError("Faltan ingresar algunos datos, seran remarcados"); erroricono.SetError(txtCedula, "Ingrese un valor"); erroricono.SetError(txtNombre, "Ingrese un valor"); erroricono.SetError(txtApellido, "Ingrese un valor"); erroricono.SetError(txtSalario, "Ingrese un valor"); } else if (validarCampos() == 0 && validarCedula(txtCedula.Text) == 0) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); this.pbImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); byte[] image = ms.GetBuffer(); if (this.IsNuevo) { rpta = NCandidatos.Insertar(this.txtCedula.Text.Trim(), this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), Convert.ToDecimal(this.txtSalario.Text), image, this.txtRecomendado.Text.Trim().ToUpper(), Convert.ToInt32(this.txtIdIdioma.Text), Convert.ToInt32(this.txtIdCompetencias.Text), Convert.ToInt32(this.txtIdExperiencia.Text), Convert.ToInt32(this.cmbPuestos.SelectedValue), Convert.ToInt32(this.txtIdCapacitaciones.Text)); } else { rpta = NCandidatos.Editar(Convert.ToInt32(this.txtIdCandidatos.Text), this.txtCedula.Text.Trim(), this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), Convert.ToDecimal(this.txtSalario.Text), image, this.txtRecomendado.Text.Trim().ToUpper(), Convert.ToInt32(this.txtIdIdioma.Text), Convert.ToInt32(this.txtIdCompetencias.Text), Convert.ToInt32(this.txtIdExperiencia.Text), Convert.ToInt32(this.cmbPuestos.SelectedValue), Convert.ToInt32(this.txtIdCapacitaciones.Text)); } if (rpta.Equals("OK")) { if (this.IsNuevo) { this.MensajeOk("Se inserto de forma correcta el registro"); } else { this.MensajeOk("Se actualizo de forma correcta el registro"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.Limpiar(); this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
//Metodo mostrar private void Mostrar() { this.dataListado.DataSource = NCandidatos.Mostrar(); this.OcultarColumnas(); lblTotal.Text = "Total de registro: " + Convert.ToString(dataListado.Rows.Count); }
private void metroButton1_Click(object sender, EventArgs e) { try { string rpta = ""; if (this.txtCedula.Text == string.Empty) { MensajeError("Faltan ingresar algunos datos, seran remarcados"); } else { System.IO.MemoryStream ms = new System.IO.MemoryStream(); this.pbImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); byte[] image = ms.GetBuffer(); if (this.IsNuevo) { rpta = NEmpleados.Insertar(this.txtCedula.Text.Trim(), this.txtNombre.Text.Trim().ToUpper(), this.txtApellido.Text.Trim().ToUpper(), this.dtpFechaIngreso.Value.Date, Convert.ToInt32(this.cmbPuestos.SelectedValue), Convert.ToInt32(this.cmbDepartamentos.SelectedValue), image, Convert.ToDecimal(this.txtSalario.Text), this.chkEstado.Text.Trim()); } if (rpta.Equals("OK")) { //Aqui Eliminara de la tabla candidatos string Codigo; string RESPUESTA = ""; Codigo = Convert.ToString(this.txtCedula.Text); RESPUESTA = NCandidatos.EliminarCanByCedula(Codigo); if (RESPUESTA.Equals("OK")) { this.MensajeOk("Felicitaciones, paso a ser parte de esta empresa!"); // Command line argument must the the SMTP host. SmtpClient client = new SmtpClient(); client.Port = 587; client.Host = "smtp.gmail.com"; client.EnableSsl = true; client.Timeout = 10000; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "password"); MailMessage mm = new MailMessage("*****@*****.**", "*****@*****.**", "test", "test"); mm.BodyEncoding = UTF8Encoding.UTF8; mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; client.Send(mm); } else { this.MensajeError(RESPUESTA); } //this.MensajeOk("Se actualizo de forma correcta el registro"); } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; //this.Botones(); this.Limpiar(); //this.Mostrar(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }