public void Delete(DaysOfWorkEmployeeML DaysOfWorkEmployee)
 {
     try
     {
         DaysOfWorkEmployeeDAL.Delete(DaysOfWorkEmployee);
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
 public int Save(DaysOfWorkEmployeeML DaysOfWorkEmployee)
 {
     try
     {
         if (DaysOfWorkEmployee.Id == 0)
         {
             return(DaysOfWorkEmployeeDAL.Save(DaysOfWorkEmployee));
         }
         else
         {
             return(DaysOfWorkEmployeeDAL.Update(DaysOfWorkEmployee));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Save: {1}", core, ex));
     }
 }
 public int Save(DaysOfWorkEmployeeML DaysOfWorkEmployee)
 {
     try
     {
         ModelDAL      ModelDAL = new ModelDAL();
         String        Response = ModelDAL.InsertModel(DaysOfWorkEmployee, TableName, IdUserSession);
         SqlConnection Conexion = new SqlConnection
         {
             ConnectionString = ConnectionString
         };
         Conexion.Open();
         SqlCommand cmd2 = new SqlCommand(Response.ToString(), Conexion);
         return(cmd2.ExecuteNonQuery());
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.save : {1}", core, ex));
     }
 }
 public void Delete(DaysOfWorkEmployeeML DaysOfWorkEmployee)
 {
     try
     {
         ModelDAL      ModelDAL = new ModelDAL();
         String        Response = ModelDAL.DeleteModel(DaysOfWorkEmployee, 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 #5
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                if (FormValidate())
                {
                    CompanyBLL CompanyBLL = new CompanyBLL();
                    CompanyML  Company    = CompanyBLL.GetEntity();

                    UsersML User = new UsersML
                    {
                        UserName = textBoxUsuario.Text,
                        Password = textBoxPassword.Text,
                        Image    = System.IO.Path.GetFileName(PathFileNameTextBox.Text),
                        Rol      = int.Parse(comboBoxRol.SelectedValue.ToString())
                    };

                    if (IdUser > 0)
                    {
                        User.Id = IdUser;
                    }

                    UsersBLL   UsersBALL = new UsersBLL();
                    EmployeeML Employee  = new EmployeeML
                    {
                        RFC           = textBoxRfc.Text,
                        Curp          = textBoxCurp.Text,
                        Name          = textBoxNombre.Text,
                        LastName      = textBoxApellidos.Text,
                        Scholarship   = comboBoxEscolaridad.SelectedValue.ToString(),
                        Birthdate     = dateTimeFechaNacimiento.Value,
                        Nationality   = textBoxNacionalidad.Text,
                        Address       = textBoxCalle.Text,
                        Municipality  = textBoxMunicipio.Text,
                        Country       = textBoxPais.Text,
                        Email         = textBoxEmail.Text,
                        Telephone     = textBoxTelefono.Text,
                        CivilStatus   = comboBoxEstadoCivil.SelectedValue.ToString(),
                        PostalCode    = (String.IsNullOrEmpty(textBoxCodigoPostal.Text))?0: int.Parse(textBoxCodigoPostal.Text),
                        Colony        = textBoxColonia.Text,
                        StateCountry  = textBoxEstado.Text,
                        AdmissionDate = dateTimeFechaIngreso.Value,
                        IdDepartament = Int32.Parse(comboBoxDepartamento.SelectedValue.ToString()),
                        IdJob         = Int32.Parse(comboBoxPuesto.SelectedValue.ToString()),
                        SureType      = comboBoxTipoSeguro.SelectedValue.ToString(),
                        NumberSure    = textBoxNumSeguro.Text,
                        Salary        = Convert.ToDecimal(textBoxSueldo.Text),
                        HoursDay      = Convert.ToDateTime(textBoxNumHours.Text),
                    };

                    if (radioButtonHombre.Checked)
                    {
                        Employee.Gender = "Hombre";
                    }
                    else
                    {
                        Employee.Gender = "Mujer";
                    }

                    if (IdEmployee > 0)
                    {
                        Employee.Id = IdEmployee;
                    }
                    Employee.IdUser = UsersBALL.Save(User);
                    EmployeeBLL EmployeeBLL   = new EmployeeBLL();
                    int         IdNewEmployee = EmployeeBLL.Save(Employee);

                    DaysOfWorkEmployeeBLL DaysOfWorkEmployeeBLL = new DaysOfWorkEmployeeBLL();
                    DaysOfWorkEmployeeBLL.DeleteRegistrys(IdEmployee);
                    foreach (object item in checkedListBoxDias.CheckedItems)
                    {
                        DaysOfWorkEmployeeML DaysOfWorkEmployee = new DaysOfWorkEmployeeML()
                        {
                            IdDays     = Int32.Parse(item.GetType().GetProperty("Value").GetValue(item, null).ToString()),
                            IdEmployee = IdNewEmployee
                        };
                        DaysOfWorkEmployeeBLL.Save(DaysOfWorkEmployee);
                    }

                    TurnsOfEmployeeBLL TurnsOfEmployeeBLL = new TurnsOfEmployeeBLL();
                    TurnsOfEmployeeBLL.DeleteRegistrys(IdEmployee);
                    foreach (object item in checkedListBoxTurns.CheckedItems)
                    {
                        TurnsOfEmployeeML TurnsOfEmployee = new TurnsOfEmployeeML()
                        {
                            IdTurn       = Int32.Parse(item.GetType().GetProperty("Value").GetValue(item, null).ToString()),
                            IdEmployee   = IdNewEmployee,
                            IdUserInsert = GlobalBLL.userML.Id
                        };
                        TurnsOfEmployeeBLL.Save(TurnsOfEmployee);
                    }

                    if (!string.IsNullOrEmpty(PathFileNameTextBox.Text) && !string.IsNullOrEmpty(PathFileImage) && System.IO.Path.GetFileName(PathFileImageOld) != PathFileImage)
                    {
                        if (!System.IO.Directory.Exists(DirectoryFiles))
                        {
                            System.IO.Directory.CreateDirectory(DirectoryFiles);
                        }

                        System.IO.File.Delete(string.Format("{0}/{1}", DirectoryFiles, PathFileNameTextBox.Text));
                        System.IO.File.Copy(PathFileImage, string.Format("{0}/{1}", DirectoryFiles, System.IO.Path.GetFileName(PathFileNameTextBox.Text)));
                    }

                    ZKTecoDeviceBLL        zKTecoDevice = new ZKTecoDeviceBLL();
                    BiometricCore.UserInfo _userInfo    = new BiometricCore.UserInfo()
                    {
                        EnrollNumber = string.Format("{0}", IdNewEmployee),
                        Name         = Employee.Name,
                        Privelage    = (int)BiometricCore.Enums.Privileges.CommonUser,
                        TmpData      = "",
                        Password     = string.Format("{0}", IdNewEmployee)
                    };
                    zKTecoDevice.SetUserInfo(_userInfo, Convert.ToInt32(Company.NumberUserEmploye));

                    cFMEM100010 FrmDataGrid = this.Owner as cFMEM100010;
                    FrmDataGrid.LoadDataGridView();
                    cFAT100010 Alert = new cFAT100010("Información", "Información Guardado con exito!!", MessageBoxIcon.Information);
                    Alert.ShowDialog();
                    Alert.Dispose();
                    Clear();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("buttonGuardar_Click: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }