public int Save(AbsenteeismAssignmentML Absenteeismassignment) { try { ModelDAL ModelDAL = new ModelDAL(); String Response = ModelDAL.InsertModel(Absenteeismassignment, 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)); } }
public AbsenteeismAssignmentML GetEntityId(DataRow row) { try { if (row != null) { AbsenteeismAssignmentML AbsenteeismAssignmentML = new AbsenteeismAssignmentML() { Id = (row[AbsenteeismAssignmentML.DataBase.Id] != DBNull.Value) ? Convert.ToInt32(row[AbsenteeismAssignmentML.DataBase.Id]) : 0, ControlNumber = (row[AbsenteeismAssignmentML.DataBase.controlNumber] != DBNull.Value) ? row[AbsenteeismAssignmentML.DataBase.controlNumber].ToString() : string.Empty, KeyAbsenteeism = (row[AbsenteeismAssignmentML.DataBase.KeyAbsenteeism] != DBNull.Value) ? row[AbsenteeismAssignmentML.DataBase.KeyAbsenteeism].ToString() : string.Empty, Description = (row[AbsenteeismAssignmentML.DataBase.Description] != DBNull.Value) ? row[AbsenteeismAssignmentML.DataBase.Description].ToString() : string.Empty, Status = (row[AbsenteeismAssignmentML.DataBase.Status] != DBNull.Value) ? row[AbsenteeismAssignmentML.DataBase.Status].ToString() : string.Empty, DateStar = (row[AbsenteeismAssignmentML.DataBase.DateStar] != DBNull.Value) ? Convert.ToDateTime(row[AbsenteeismAssignmentML.DataBase.DateStar]) : Convert.ToDateTime(row[AbsenteeismAssignmentML.DataBase.DateStar]), DateEnd = (row[AbsenteeismAssignmentML.DataBase.DateEnd] != DBNull.Value) ? Convert.ToDateTime(row[AbsenteeismAssignmentML.DataBase.DateEnd]) : Convert.ToDateTime(row[AbsenteeismAssignmentML.DataBase.DateEnd]), }; return(AbsenteeismAssignmentML); } return(null); } catch (Exception ex) { throw new Exception(String.Format("{0}.GetIdEntity : {1}", ex.Message)); } }
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) { AbsenteeismAssignmentML AbsenteeismAssignment = new AbsenteeismAssignmentML { Id = Int32.Parse(dataGridViewData.Rows[IdRowSelect].Cells["Id"].Value.ToString()), }; AbsenteeismAssignmentBLL.Delete(AbsenteeismAssignment); 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(AbsenteeismAssignmentML Absenteeismassignment) { try { AbsenteeismAssignmentDAL.Delete(Absenteeismassignment); } catch (Exception ex) { throw new Exception(String.Format("{0}.Delete: {1}", core, ex)); } }
public int Save(AbsenteeismAssignmentML Absenteeismassignment) { try { if (Absenteeismassignment.Id == 0) { return(AbsenteeismAssignmentDAL.Save(Absenteeismassignment)); } else { return(AbsenteeismAssignmentDAL.Update(Absenteeismassignment)); } } catch (Exception ex) { throw new Exception(String.Format("{0}.Save: {1}", core, ex)); } }
public void Delete(AbsenteeismAssignmentML Absenteeismassignment) { try { ModelDAL ModelDAL = new ModelDAL(); String Response = ModelDAL.DeleteModel(Absenteeismassignment, 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)); } }
public void LoadAbsenteeism() { try { //IdAbsenteeismAssignment AbsenteeismAssignmentML AbsenteeismAssignment = AbsenteeismAssignmentBLL.GetEntityId(IdAbsenteeismAssignment); if (!String.IsNullOrEmpty(AbsenteeismAssignment.ControlNumber)) { LoadObject(Convert.ToInt32(AbsenteeismAssignment.ControlNumber)); } comboBoxAusentismo.SelectedValue = AbsenteeismAssignment.KeyAbsenteeism.ToString(); comboBoxEstadoAsig.SelectedValue = AbsenteeismAssignment.Status.ToString(); dateTimeFechaInicio.Text = Convert.ToDateTime(AbsenteeismAssignment.DateStar).ToString(); dateTimeFechaFin.Text = Convert.ToDateTime(AbsenteeismAssignment.DateEnd).ToString(); textBoxDescripcion.Text = AbsenteeismAssignment.Description.ToString(); } catch (Exception ex) { MessageBox.Show(String.Format("LoadAbsenteeism: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonGuardar_Click(object sender, EventArgs e) { try { if (FormValidate()) { AbsenteeismAssignmentML AsigAusentismo = new AbsenteeismAssignmentML { ControlNumber = textBoxNumControl.Text.ToString(), KeyAbsenteeism = comboBoxAusentismo.SelectedValue.ToString(), Status = comboBoxEstadoAsig.SelectedValue.ToString(), DateStar = dateTimeFechaInicio.Value, DateEnd = dateTimeFechaFin.Value, Description = textBoxDescripcion.Text }; if (IdAbsenteeismAssignment > 0) { AsigAusentismo.Id = IdAbsenteeismAssignment; } AbsenteeismAssignmentBLL.Save(AsigAusentismo); cFMAA100010 FrmDataGrid = this.Owner as cFMAA100010; 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); } }