private void buttonGuardar_Click(object sender, EventArgs e) { try { if (FormValidate()) { AbsenteeismML Absenteeism = new AbsenteeismML(); Absenteeism.IsKey = textBoxClave.Text; Absenteeism.Concept = textBoxConcepto.Text; Absenteeism.description = textBoxDescripcion.Text; if (IdAbsenteeism > 0) { Absenteeism.Id = IdAbsenteeism; } AbsenteeismBLL.Save(Absenteeism); cFMCO100010 FrmDataGrid = this.Owner as cFMCO100010; FrmDataGrid.LoadDataGridView(); cFAT100010 Alert = new cFAT100010("Información", "Información Guardado con éxito!!", MessageBoxIcon.Information); Alert.ShowDialog(); Clear(); this.Close(); } } catch (Exception ex) { MessageBox.Show(String.Format("buttonGuardar_Click: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int Save(AbsenteeismML absenteeism) { try { ModelDAL ModelDAL = new ModelDAL(); String Response = ModelDAL.InsertModel(absenteeism, TableName, IdUserSession); SqlConnection Conexion = new SqlConnection() { ConnectionString = ConnectionString }; using (SqlCommand cmd2 = new SqlCommand(Response.ToString(), Conexion)) { Conexion.Open(); int newID = (Int32)cmd2.ExecuteScalar(); if (Conexion.State == System.Data.ConnectionState.Open) { Conexion.Close(); } return(newID); } } catch (Exception ex) { throw new Exception(String.Format("{0}.save : {1}", core, ex)); } }
private void buttonEliminar_Click(object sender, EventArgs e) { try { if (dataGridViewData.RowCount > 0) { IdRowSelect = dataGridViewData.CurrentRow.Index; cFAT100010 Alert = new cFAT100010("INFORMACION", String.Format("¿Desea eliminar el registro {0}?", dataGridViewData.Rows[IdRowSelect].Cells["Id"].Value.ToString()), MessageBoxIcon.Question); Alert.ShowDialog(); if (Alert.DialogResult == DialogResult.Yes) { AbsenteeismML Absenteeism = new AbsenteeismML { Id = Int32.Parse(dataGridViewData.Rows[IdRowSelect].Cells["Id"].Value.ToString()), }; AbsenteeismBLL.Delete(Absenteeism); dataGridViewData.Rows.Remove(dataGridViewData.CurrentRow); } } else { cFAT100010 Alert = new cFAT100010("Información", "No hay datos", MessageBoxIcon.Information); Alert.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(String.Format("buttonEliminar_Click: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Delete(AbsenteeismML absenteeism) { try { AbsenteeismDAL.Delete(absenteeism); } catch (Exception ex) { throw new Exception(String.Format("{0}.Delete: {1}", core, ex)); } }
public int Save(AbsenteeismML absenteeism) { try { if (absenteeism.Id == 0) { return(AbsenteeismDAL.Save(absenteeism)); } else { return(AbsenteeismDAL.Update(absenteeism)); } } catch (Exception ex) { throw new Exception(String.Format("{0}.Save: {1}", core, ex)); } }
public void Delete(AbsenteeismML absenteeism) { try { ModelDAL ModelDAL = new ModelDAL(); String Response = ModelDAL.DeleteModel(absenteeism, TableName, IdUserSession); SqlConnection Conexion = new SqlConnection() { ConnectionString = ConnectionString }; Conexion.Open(); SqlCommand cmd2 = new SqlCommand(Response.ToString(), Conexion); cmd2.ExecuteNonQuery(); Conexion.Close(); } catch (Exception ex) { throw new Exception(String.Format("{0}.delete: {1}", core, ex)); } }