Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
 public void Delete(AbsenteeismML absenteeism)
 {
     try
     {
         AbsenteeismDAL.Delete(absenteeism);
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
Exemplo n.º 5
0
 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));
     }
 }
Exemplo n.º 6
0
 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));
     }
 }