public CompanyML GetEntity(DataRow row) { try { if (row != null) { CompanyML company = new CompanyML() { Id = (row[CompanyML.DataBase.id] != DBNull.Value) ? int.Parse(row[CompanyML.DataBase.id].ToString()) : 0, Rfc = (row[CompanyML.DataBase.rfc] != DBNull.Value) ? row[CompanyML.DataBase.rfc].ToString() : string.Empty, BusinessName = (row[CompanyML.DataBase.businessName] != DBNull.Value) ? row[CompanyML.DataBase.businessName].ToString() : string.Empty, Street = (row[CompanyML.DataBase.street] != DBNull.Value) ? row[CompanyML.DataBase.street].ToString() : string.Empty, Municipality = (row[CompanyML.DataBase.municipality] != DBNull.Value) ? row[CompanyML.DataBase.municipality].ToString() : string.Empty, State = (row[CompanyML.DataBase.state] != DBNull.Value) ? row[CompanyML.DataBase.state].ToString() : string.Empty, Country = (row[CompanyML.DataBase.country] != DBNull.Value) ? row[CompanyML.DataBase.country].ToString() : string.Empty, Email = (row[CompanyML.DataBase.email] != DBNull.Value) ? row[CompanyML.DataBase.email].ToString() : string.Empty, PostalCode = (row[CompanyML.DataBase.poltalCode] != DBNull.Value) ? row[CompanyML.DataBase.poltalCode].ToString() : string.Empty, Telephone = (row[CompanyML.DataBase.telephone] != DBNull.Value) ? row[CompanyML.DataBase.telephone].ToString() : string.Empty, Image = (row[CompanyML.DataBase.image] != DBNull.Value) ? row[CompanyML.DataBase.image].ToString() : string.Empty, NumberUserEmploye = (row[CompanyML.DataBase.numberUserEmploye] != DBNull.Value) ? row[CompanyML.DataBase.numberUserEmploye].ToString() : string.Empty, }; return(company); } return(null); } catch (Exception ex) { throw new Exception(string.Format("GetEntity: {0}", ex.Message)); } }
private void cFMSE110010_Load(object sender, EventArgs e) { try { companyBLL = new CompanyBLL(); companyML = companyBLL.GetEntity(); if (companyML != null) { RFCTextBox.Text = companyML.Rfc; RazonSocialTextBox.Text = companyML.BusinessName; CalleTextBox.Text = companyML.Street; MunicipioTextBox.Text = companyML.Municipality; PaisTextBox.Text = companyML.Country; CorreoTextBox.Text = companyML.Email; EstadoTextBox.Text = companyML.State; CodigoPostalTextBox.Text = companyML.PostalCode; TelefonoTextBox.Text = companyML.Telephone; textBoxNumberUsers.Text = companyML.NumberUserEmploye; if (!string.IsNullOrEmpty(companyML.Image)) { PathFileNameTextBox.Text = string.Format("{0}\\{1}", System.IO.Path.GetFullPath(GlobalBLL.DirectoryFiles), companyML.Image); if (System.IO.File.Exists(PathFileNameTextBox.Text)) { LogoPictureBox.BackgroundImage = new Bitmap(PathFileNameTextBox.Text); } else { throw new Exception("No se encontró la imagen"); } } } else { companyML = new CompanyML(); } LoadUser(); if (!System.IO.Directory.Exists(GlobalBLL.DirectoryFiles)) { System.IO.Directory.CreateDirectory(GlobalBLL.DirectoryFiles); } } catch (Exception ex) { Alerts.cFAT100010 alr = new Alerts.cFAT100010("EROR", string.Format("cFMSE110010_Load: {0}", ex.Message), MessageBoxIcon.Error); alr.ShowDialog(); } }
public int Delete(CompanyML Company) { try { return(CompanyDAL.Delete(Company)); } catch (Exception ex) { throw new Exception(String.Format("{0}.Delete: {1}", core, ex)); } }
public int Save(CompanyML company) { try { ModelDAL ModelDAL = new ModelDAL(); return(Convert.ToInt32(ModelDAL.InsertModel(company, TableName, IdUserSession, ConnectionString))); } catch (Exception ex) { throw new Exception(String.Format("{0}.save : {1}", core, ex)); } }
public int Delete(CompanyML Company) { try { ModelDAL ModelDAL = new ModelDAL(); ModelDAL.DeleteModel(Company, TableName, IdUserSession, ConnectionString); return(Company.Id); } catch (Exception ex) { throw new Exception(String.Format("{0}.delete: {1}", core, ex)); } }
public int Save(CompanyML Company) { try { if (Company.Id == 0) { return(CompanyDAL.Save(Company)); } else { return(CompanyDAL.Update(Company)); } } catch (Exception ex) { throw new Exception(String.Format("{0}.Save: {1}", core, ex)); } }
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); } }