예제 #1
0
        public int Delete(TurnsOfEmployeeML turnsOfEmployee, String ConnectionString)
        {
            try
            {
                int           id    = 0;
                StringBuilder Query = new StringBuilder();
                Query.AppendFormat("UPDATE {0} ", TableName);
                Query.AppendLine(" SET ");
                Query.AppendLine("_registry = 2");
                Query.AppendFormat("idUserDelete = {0}", turnsOfEmployee.IdUserDelete);
                Query.AppendLine("dateDelete = GETDATE()");
                Query.AppendFormat("WHERE id={0}", turnsOfEmployee.Id);

                SqlConnection Conexion = new SqlConnection
                {
                    ConnectionString = ConnectionString
                };
                Conexion.Open();
                SqlCommand cmd2 = new SqlCommand(Query.ToString(), Conexion);
                id = cmd2.ExecuteNonQuery();
                return(id);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("{0}.delete: {1}", core, ex.Message));
            }
        }
예제 #2
0
 public int Delete(TurnsOfEmployeeML TurnsOfEmployee)
 {
     try
     {
         return(TurnsOfEmployeeDAL.Delete(TurnsOfEmployee, ConnectionStrings));
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Delete: {1}", core, ex));
     }
 }
예제 #3
0
 public int Save(TurnsOfEmployeeML TurnsOfEmployee)
 {
     try
     {
         if (TurnsOfEmployee.Id == 0)
         {
             return(TurnsOfEmployeeDAL.Save(TurnsOfEmployee, ConnectionStrings));
         }
         else
         {
             return(TurnsOfEmployeeDAL.Update(TurnsOfEmployee, ConnectionStrings));
         }
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.Save: {1}", core, ex));
     }
 }
예제 #4
0
 public int Save(TurnsOfEmployeeML turnsOfEmployee, String ConnectionString)
 {
     try
     {
         int           id    = 0;
         StringBuilder Query = new StringBuilder();
         Query.AppendFormat("INSERT INTO {0}", TableName);
         Query.AppendLine("( idTurn,idEmployee,_registry,idUserInsert,dateInsert)");
         Query.AppendFormat(" VALUES({0},{1},1,{2},getdate())", turnsOfEmployee.IdTurn, turnsOfEmployee.IdEmployee, turnsOfEmployee.IdUserInsert);
         Query.AppendLine(" SELECT CAST(scope_identity() AS int)");
         SqlConnection Conexion = new SqlConnection
         {
             ConnectionString = ConnectionString
         };
         Conexion.Open();
         SqlCommand cmd2 = new SqlCommand(Query.ToString(), Conexion);
         id = (Int32)cmd2.ExecuteScalar();
         return(id);
     }
     catch (Exception ex)
     {
         throw new Exception(String.Format("{0}.save : {1}", core, ex.Message));
     }
 }
예제 #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);
            }
        }