Beispiel #1
0
 public void LoadObject(int IdObject)
 {
     try
     {
         EmployeeBLL EmployeeBLL = new EmployeeBLL();
         if (EmployeeBLL.GetIdEntity(IdObject) != null)
         {
             EmployeeML Employee = EmployeeBLL.GetIdEntity(IdObject);
             textBoxNumControl.Text = Employee.Id.ToString();
             textBoxNombre.Text     = Employee.Name.ToString();
             textBoxApellidoP.Text  = Employee.LastName.ToString();
             DepartamentBLL DepartamentBLL = new DepartamentBLL();
             DepartamentML  Departament    = DepartamentBLL.GetIdEntity(Employee.IdDepartament);
             textBoxDepartamento.Text = Departament.Name.ToString();
             JobBLL JobBLL = new JobBLL();
             JobML  Job    = JobBLL.GetIdEntity(Employee.IdJob);
             textBoxPuesto.Text = Job.Name;
         }
         else
         {
             cFAT100010 Alert = new cFAT100010("Información", "El empleado no existe", MessageBoxIcon.Information);
             Alert.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(String.Format("LoadObject: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (FormValidate())
                {
                    DepartamentML Departament = new DepartamentML();
                    Departament.Name        = textBoxNombre.Text;
                    Departament.Manager     = textBoxEncargado.Text;
                    Departament.Description = textBoxDescripcion.Text;

                    if (IdDepartament > 0)
                    {
                        Departament.Id = IdDepartament;
                    }

                    DepartamentBLL.Save(Departament);

                    cFMDE100010 FrmDataGrid = this.Owner as cFMDE100010;
                    FrmDataGrid.LoadDataGridView();

                    cFAT100010 Alert = new cFAT100010("Información", "Información Guardado con exito!!", MessageBoxIcon.Information);
                    Alert.ShowDialog();

                    Clear();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("buttonGuardar_Click: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
 private void buttonEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridViewDepartamento.RowCount > 0)
         {
             IdRowSelect = dataGridViewDepartamento.CurrentRow.Index;
             int        idDepartament = Int32.Parse(dataGridViewDepartamento.Rows[IdRowSelect].Cells["Id"].Value.ToString());
             cFAT100010 Alert         = new cFAT100010("Información", String.Format("¿Desea eliminar el registro {0}?", idDepartament), MessageBoxIcon.Question);
             Alert.ShowDialog();
             if (Alert.DialogResult == DialogResult.Yes)
             {
                 DepartamentML Departament = new DepartamentML
                 {
                     Id = idDepartament,
                 };
                 DepartamentBLL.Delete(Departament);
                 dataGridViewDepartamento.Rows.Remove(dataGridViewDepartamento.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);
     }
 }
Beispiel #4
0
 public void Delete(DepartamentML departament)
 {
     try
     {
         DepartamentDAL.Delete(departament);
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
Beispiel #5
0
 private void buttonEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         IdRowSelect = dataGridViewData.CurrentRow.Index;
         DepartamentML Departament = new DepartamentML();
         Departament.Id           = Int32.Parse(dataGridViewData.Rows[IdRowSelect].Cells["Id"].Value.ToString());
         Departament.IdUserDelete = 1;
         DepartamentBLL.Delete(Departament);
         dataGridViewData.Rows.Remove(dataGridViewData.CurrentRow);
     }
     catch (Exception ex)
     {
         MessageBox.Show(String.Format("buttonEliminar_Click: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #6
0
 public int Save(DepartamentML departament)
 {
     try
     {
         if (departament.Id == 0)
         {
             return(DepartamentDAL.Save(departament));
         }
         else
         {
             return(DepartamentDAL.Update(departament));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Save: {1}", core, ex));
     }
 }
Beispiel #7
0
 public void Delete(DepartamentML Departament)
 {
     try
     {
         ModelDAL      ModelDAL = new ModelDAL();
         String        Response = ModelDAL.DeleteModel(Departament, 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));
     }
 }
Beispiel #8
0
        public int Save(DepartamentML Departament)
        {
            ModelDAL      data     = new ModelDAL();
            String        Response = data.InsertModel(Departament, 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);
            }
        }
Beispiel #9
0
        public DepartamentML GetDepartament(DataRow row)
        {
            try
            {
                if (row != null)
                {
                    DepartamentML Departament = new DepartamentML()
                    {
                        Id          = (row[DepartamentML.DataBase.Id] != DBNull.Value) ? int.Parse(row[DepartamentML.DataBase.Id].ToString()) : 0,
                        Name        = (row[DepartamentML.DataBase.Name] != DBNull.Value) ? row[DepartamentML.DataBase.Name].ToString() : string.Empty,
                        Manager     = (row[DepartamentML.DataBase.Manager] != DBNull.Value) ? row[DepartamentML.DataBase.Manager].ToString() : string.Empty,
                        Description = (row[DepartamentML.DataBase.Description] != DBNull.Value) ? row[DepartamentML.DataBase.Description].ToString() : string.Empty
                    };

                    return(Departament);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("{0}.GetDepartament : {1}", core, ex));
            }
        }