Example #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);
     }
 }
Example #2
0
 private void buttonEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         if (dataGridViewDataPuesto.RowCount > 0)
         {
             IdRowSelect = dataGridViewDataPuesto.CurrentRow.Index;
             int        IdJob = Int32.Parse(dataGridViewDataPuesto.Rows[IdRowSelect].Cells[JobML.DataBase.Id].Value.ToString());
             cFAT100010 Alert = new cFAT100010("Información", String.Format("¿Desea eliminar el registro {0}?", IdJob), MessageBoxIcon.Question);
             Alert.ShowDialog();
             if (Alert.DialogResult == DialogResult.Yes)
             {
                 JobML Job = new JobML
                 {
                     Id = IdJob,
                 };
                 JobBLL.Delete(Job);
                 dataGridViewDataPuesto.Rows.Remove(dataGridViewDataPuesto.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);
     }
 }
Example #3
0
        public int Save(JobML Job)
        {
            try
            {
                ModelDAL      ModelDAL = new ModelDAL();
                String        Response = ModelDAL.InsertModel(Job, 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));
            }
        }
Example #4
0
 public void Delete(JobML Job)
 {
     try
     {
         JobDAL.Delete(Job);
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
Example #5
0
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            JobML job = new JobML
            {
                Id          = 0,
                Name        = textBoxNombre.Text,
                Description = textBoxDescripcion.Text,
                //IdUserInsert = 1
            };

            JobBll.Save(job);
        }
Example #6
0
 public int Save(JobML Job)
 {
     try
     {
         if (Job.Id == 0)
         {
             return(JobDAL.Save(Job));
         }
         else
         {
             return(JobDAL.Update(Job));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Save: {1}", core, ex));
     }
 }
Example #7
0
 public void Delete(JobML Job)
 {
     try
     {
         ModelDAL      ModelDAL = new ModelDAL();
         String        Response = ModelDAL.DeleteModel(Job, 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));
     }
 }
Example #8
0
        public JobML GetEntity(DataRow row)
        {
            try
            {
                if (row != null)
                {
                    JobML Job = new JobML()
                    {
                        Id          = (row[JobML.DataBase.Id] != DBNull.Value) ? int.Parse(row[JobML.DataBase.Id].ToString()) : 0,
                        Name        = (row[JobML.DataBase.Name] != DBNull.Value) ? row[JobML.DataBase.Name].ToString() : string.Empty,
                        Description = (row[JobML.DataBase.Description] != DBNull.Value) ? row[JobML.DataBase.Description].ToString() : string.Empty
                    };

                    return(Job);
                }
                return(null);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("{0}.GetEntity : {1}", core, ex));
            }
        }
Example #9
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (FormValidate())
                {
                    JobML Job = new JobML();

                    Job.Name        = textBoxPuesto.Text;
                    Job.Description = textBoxDescripcion.Text;

                    if (IdJob > 0)
                    {
                        Job.Id          = IdJob;
                        Job.Name        = textBoxPuesto.Text;
                        Job.Description = textBoxDescripcion.Text;
                        //Job.IdUserUpdate = 1;
                    }

                    JobBLL.Save(Job);

                    cFMPU100010 FrmDataGrid = this.Owner as cFMPU100010;
                    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), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }