Int64 IHREmployeeConfidentialInfoDataAccess.Add(HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(hREmployeeConfidentialInfoEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(hREmployeeConfidentialInfoEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void SaveHREmployeeConfidentialInfoEntity() { if (IsValid) { try { HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity = BuildHREmployeeConfidentialInfoEntity(); Int64 result = -1; if (hREmployeeConfidentialInfoEntity.IsNew) { result = FCCHREmployeeConfidentialInfo.GetFacadeCreate().Add(hREmployeeConfidentialInfoEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeConfidentialInfoEntity.FLD_NAME_EmployeeConfidentialInfoID, hREmployeeConfidentialInfoEntity.EmployeeConfidentialInfoID.ToString(), SQLMatchType.Equal); result = FCCHREmployeeConfidentialInfo.GetFacadeCreate().Update(hREmployeeConfidentialInfoEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _EmployeeConfidentialInfoID = result; _HREmployeeConfidentialInfoEntity = CurrentHREmployeeConfidentialInfoEntity; //PrepareInitialView(); BindHREmployeeConfidentialInfoList(); PrepareEditView(); if (hREmployeeConfidentialInfoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Confidential Info Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Confidential Info Information has been updated successfully.", false); } } else { if (hREmployeeConfidentialInfoEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Confidential Info Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Confidential Info Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 DeleteTran(HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeConfidentialInfo_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode >= 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }
private Int64 Delete(HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeConfidentialInfo_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeeConfidentialInfoEntity already exists. Please specify another HREmployeeConfidentialInfoEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeConfidentialInfoEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeConfidentialInfoEntity already exists. Please specify another HREmployeeConfidentialInfoEntity."); } } } } return(returnCode); }
private HREmployeeConfidentialInfoEntity BuildHREmployeeConfidentialInfoEntity() { HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity = CurrentHREmployeeConfidentialInfoEntity; hREmployeeConfidentialInfoEntity.EmployeeID = OverviewEmployeeID; if (!txtNumberofChildren.Text.Trim().IsNullOrEmpty()) { hREmployeeConfidentialInfoEntity.NumberofChildren = Int32.Parse(txtNumberofChildren.Text.Trim()); } else { hREmployeeConfidentialInfoEntity.NumberofChildren = null; } if (txtDateofBirth.Text.Trim().IsNotNullOrEmpty()) { hREmployeeConfidentialInfoEntity.DateofBirth = MiscUtil.ParseToDateTime(txtDateofBirth.Text); } else { hREmployeeConfidentialInfoEntity.DateofBirth = null; } if (ddlMaritalStatusID.Items.Count > 0) { if (ddlMaritalStatusID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.MaritalStatusID = null; } else { hREmployeeConfidentialInfoEntity.MaritalStatusID = Int64.Parse(ddlMaritalStatusID.SelectedValue); } } hREmployeeConfidentialInfoEntity.CityofBirth = txtCityofBirth.Text.Trim(); if (ddlBirthOfStateID.Items.Count > 0) { if (ddlBirthOfStateID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.District = null; } else { hREmployeeConfidentialInfoEntity.District = Int64.Parse(ddlBirthOfStateID.SelectedValue); } } if (ddlCountryOfBirthCountryID.Items.Count > 0) { if (ddlCountryOfBirthCountryID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.CountryOfBirthCountryID = null; } else { hREmployeeConfidentialInfoEntity.CountryOfBirthCountryID = Int64.Parse(ddlCountryOfBirthCountryID.SelectedValue); } } if (ddlResidenceCountryID.Items.Count > 0) { if (ddlResidenceCountryID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.ResidenceCountryID = null; } else { hREmployeeConfidentialInfoEntity.ResidenceCountryID = Int64.Parse(ddlResidenceCountryID.SelectedValue); } } hREmployeeConfidentialInfoEntity.PersonlTaxIdNumber = txtPersonlTaxIdNumber.Text.Trim(); hREmployeeConfidentialInfoEntity.NationalIdNumber = txtNationalIdNumber.Text.Trim(); if (ddlRegionID.Items.Count > 0) { if (ddlRegionID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.RegionID = null; } else { hREmployeeConfidentialInfoEntity.RegionID = Int64.Parse(ddlRegionID.SelectedValue); } } if (ddlReligionID.Items.Count > 0) { if (ddlReligionID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.ReligionID = null; } else { hREmployeeConfidentialInfoEntity.ReligionID = Int64.Parse(ddlReligionID.SelectedValue); } } hREmployeeConfidentialInfoEntity.BirthMark = txtBirthMark.Text.Trim(); if (ddlBloodGroupID.Items.Count > 0) { if (ddlBloodGroupID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.BloodGroupID = null; } else { hREmployeeConfidentialInfoEntity.BloodGroupID = Int64.Parse(ddlBloodGroupID.SelectedValue); } } hREmployeeConfidentialInfoEntity.DisabilityInformation = txtDisabilityInformation.Text.Trim(); if (ddlGenderID.Items.Count > 0) { if (ddlGenderID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.GenderID = null; } else { hREmployeeConfidentialInfoEntity.GenderID = Int64.Parse(ddlGenderID.SelectedValue); } } if (txtAnniversaryDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeConfidentialInfoEntity.AnniversaryDate = MiscUtil.ParseToDateTime(txtAnniversaryDate.Text); } else { hREmployeeConfidentialInfoEntity.AnniversaryDate = null; } hREmployeeConfidentialInfoEntity.Height = txtHeight.Text.Trim(); hREmployeeConfidentialInfoEntity.Weight = txtWeight.Text.Trim(); if (ddlCurrentNationalityCountryID.Items.Count > 0) { if (ddlCurrentNationalityCountryID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.CurrentNationalityCountryID = null; } else { hREmployeeConfidentialInfoEntity.CurrentNationalityCountryID = Int64.Parse(ddlCurrentNationalityCountryID.SelectedValue); } } if (ddlPreviousNationalityCountryID.Items.Count > 0) { if (ddlPreviousNationalityCountryID.SelectedValue == "0") { hREmployeeConfidentialInfoEntity.PreviousNationalityCountryID = null; } else { hREmployeeConfidentialInfoEntity.PreviousNationalityCountryID = Int64.Parse(ddlPreviousNationalityCountryID.SelectedValue); } } hREmployeeConfidentialInfoEntity.HasPassport = chkHasPassport.Checked; hREmployeeConfidentialInfoEntity.HasDrivingLisence = chkHasDrivingLisence.Checked; hREmployeeConfidentialInfoEntity.IsRemoved = chkIsRemoved.Checked; return(hREmployeeConfidentialInfoEntity); }
private void PrepareEditView() { HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity = CurrentHREmployeeConfidentialInfoEntity; if (!hREmployeeConfidentialInfoEntity.IsNew) { txtNumberofChildren.Text = hREmployeeConfidentialInfoEntity.NumberofChildren.ToString(); txtDateofBirth.Text = hREmployeeConfidentialInfoEntity.DateofBirth.ToStringDefault(); if (ddlMaritalStatusID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.MaritalStatusID != null) { ddlMaritalStatusID.SelectedValue = hREmployeeConfidentialInfoEntity.MaritalStatusID.ToString(); } txtCityofBirth.Text = hREmployeeConfidentialInfoEntity.CityofBirth.ToString(); if (ddlBirthOfStateID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.District != null) { ddlBirthOfStateID.SelectedValue = hREmployeeConfidentialInfoEntity.District.ToString(); } if (ddlCountryOfBirthCountryID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.CountryOfBirthCountryID != null) { ddlCountryOfBirthCountryID.SelectedValue = hREmployeeConfidentialInfoEntity.CountryOfBirthCountryID.ToString(); } if (ddlResidenceCountryID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.ResidenceCountryID != null) { ddlResidenceCountryID.SelectedValue = hREmployeeConfidentialInfoEntity.ResidenceCountryID.ToString(); } txtPersonlTaxIdNumber.Text = hREmployeeConfidentialInfoEntity.PersonlTaxIdNumber.ToString(); txtNationalIdNumber.Text = hREmployeeConfidentialInfoEntity.NationalIdNumber.ToString(); if (ddlRegionID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.RegionID != null) { ddlRegionID.SelectedValue = hREmployeeConfidentialInfoEntity.RegionID.ToString(); } if (ddlReligionID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.ReligionID != null) { ddlReligionID.SelectedValue = hREmployeeConfidentialInfoEntity.ReligionID.ToString(); } txtBirthMark.Text = hREmployeeConfidentialInfoEntity.BirthMark.ToString(); if (ddlBloodGroupID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.BloodGroupID != null) { ddlBloodGroupID.SelectedValue = hREmployeeConfidentialInfoEntity.BloodGroupID.ToString(); } txtDisabilityInformation.Text = hREmployeeConfidentialInfoEntity.DisabilityInformation.ToString(); if (ddlGenderID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.GenderID != null) { ddlGenderID.SelectedValue = hREmployeeConfidentialInfoEntity.GenderID.ToString(); } txtAnniversaryDate.Text = hREmployeeConfidentialInfoEntity.AnniversaryDate.ToStringDefault(); txtHeight.Text = hREmployeeConfidentialInfoEntity.Height.ToString(); txtWeight.Text = hREmployeeConfidentialInfoEntity.Weight.ToString(); if (ddlCurrentNationalityCountryID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.CurrentNationalityCountryID != null) { ddlCurrentNationalityCountryID.SelectedValue = hREmployeeConfidentialInfoEntity.CurrentNationalityCountryID.ToString(); } if (ddlPreviousNationalityCountryID.Items.Count > 0 && hREmployeeConfidentialInfoEntity.PreviousNationalityCountryID != null) { ddlPreviousNationalityCountryID.SelectedValue = hREmployeeConfidentialInfoEntity.PreviousNationalityCountryID.ToString(); } chkHasPassport.Checked = hREmployeeConfidentialInfoEntity.HasPassport; chkHasDrivingLisence.Checked = hREmployeeConfidentialInfoEntity.HasDrivingLisence; chkIsRemoved.Checked = hREmployeeConfidentialInfoEntity.IsRemoved; btnSubmit.Text = "Update"; } }
Int64 IHREmployeeConfidentialInfoFacade.Delete(HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeConfidentialInfoDataAccess().Delete(hREmployeeConfidentialInfoEntity, filterExpression, option, reqTran)); }
Int64 IHREmployeeConfidentialInfoFacade.Add(HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeConfidentialInfoDataAccess().Add(hREmployeeConfidentialInfoEntity, option, reqTran)); }
private Int64 Add(HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeConfidentialInfo_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddNullPrimaryKeyParameter(cmd, "EmployeeConfidentialInfoID"); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeConfidentialInfoEntity.EmployeeID); Database.AddInParameter(cmd, "@NumberofChildren", DbType.Int32, hREmployeeConfidentialInfoEntity.NumberofChildren); Database.AddInParameter(cmd, "@DateofBirth", DbType.DateTime, hREmployeeConfidentialInfoEntity.DateofBirth); Database.AddInParameter(cmd, "@MaritalStatusID", DbType.Int64, hREmployeeConfidentialInfoEntity.MaritalStatusID); Database.AddInParameter(cmd, "@CityofBirth", DbType.String, hREmployeeConfidentialInfoEntity.CityofBirth); Database.AddInParameter(cmd, "@BirthOfStateID", DbType.Int64, hREmployeeConfidentialInfoEntity.BirthOfStateID); Database.AddInParameter(cmd, "@CountryOfBirthCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.CountryOfBirthCountryID); Database.AddInParameter(cmd, "@ResidenceCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.ResidenceCountryID); Database.AddInParameter(cmd, "@PersonlTaxIdNumber", DbType.String, hREmployeeConfidentialInfoEntity.PersonlTaxIdNumber); Database.AddInParameter(cmd, "@NationalIdNumber", DbType.String, hREmployeeConfidentialInfoEntity.NationalIdNumber); Database.AddInParameter(cmd, "@RegionID", DbType.Int64, hREmployeeConfidentialInfoEntity.RegionID); Database.AddInParameter(cmd, "@ReligionID", DbType.Int64, hREmployeeConfidentialInfoEntity.ReligionID); Database.AddInParameter(cmd, "@BirthMark", DbType.String, hREmployeeConfidentialInfoEntity.BirthMark); Database.AddInParameter(cmd, "@BloodGroupID", DbType.Int64, hREmployeeConfidentialInfoEntity.BloodGroupID); Database.AddInParameter(cmd, "@DisabilityInformation", DbType.String, hREmployeeConfidentialInfoEntity.DisabilityInformation); Database.AddInParameter(cmd, "@GenderID", DbType.Int64, hREmployeeConfidentialInfoEntity.GenderID); Database.AddInParameter(cmd, "@AnniversaryDate", DbType.DateTime, hREmployeeConfidentialInfoEntity.AnniversaryDate); Database.AddInParameter(cmd, "@Height", DbType.String, hREmployeeConfidentialInfoEntity.Height); Database.AddInParameter(cmd, "@Weight", DbType.String, hREmployeeConfidentialInfoEntity.Weight); Database.AddInParameter(cmd, "@CurrentNationalityCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.CurrentNationalityCountryID); Database.AddInParameter(cmd, "@PreviousNationalityCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.PreviousNationalityCountryID); Database.AddInParameter(cmd, "@HasPassport", DbType.Boolean, hREmployeeConfidentialInfoEntity.HasPassport); Database.AddInParameter(cmd, "@HasDrivingLisence", DbType.Boolean, hREmployeeConfidentialInfoEntity.HasDrivingLisence); Database.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, hREmployeeConfidentialInfoEntity.IsRemoved); Database.AddInParameter(cmd, "@DistrictID", DbType.Int64, hREmployeeConfidentialInfoEntity.District); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeeConfidentialInfoEntity already exists. Please specify another HREmployeeConfidentialInfoEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeConfidentialInfoEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeConfidentialInfoEntity already exists. Please specify another HREmployeeConfidentialInfoEntity."); } } } } return(returnCode); }
private Int64 UpdateTran(HREmployeeConfidentialInfoEntity hREmployeeConfidentialInfoEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeConfidentialInfo_SET"; Database db = DatabaseFactory.CreateDatabase(); using (DbCommand cmd = db.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option, db); AddOutputParameter(cmd, db); AddFilterExpressionParameter(cmd, filterExpression, db); db.AddInParameter(cmd, "@EmployeeConfidentialInfoID", DbType.Int64, hREmployeeConfidentialInfoEntity.EmployeeConfidentialInfoID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeConfidentialInfoEntity.EmployeeID); db.AddInParameter(cmd, "@NumberofChildren", DbType.Int32, hREmployeeConfidentialInfoEntity.NumberofChildren); db.AddInParameter(cmd, "@DateofBirth", DbType.DateTime, hREmployeeConfidentialInfoEntity.DateofBirth); db.AddInParameter(cmd, "@MaritalStatusID", DbType.Int64, hREmployeeConfidentialInfoEntity.MaritalStatusID); db.AddInParameter(cmd, "@CityofBirth", DbType.String, hREmployeeConfidentialInfoEntity.CityofBirth); db.AddInParameter(cmd, "@BirthOfStateID", DbType.Int64, hREmployeeConfidentialInfoEntity.BirthOfStateID); db.AddInParameter(cmd, "@CountryOfBirthCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.CountryOfBirthCountryID); db.AddInParameter(cmd, "@ResidenceCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.ResidenceCountryID); db.AddInParameter(cmd, "@PersonlTaxIdNumber", DbType.String, hREmployeeConfidentialInfoEntity.PersonlTaxIdNumber); db.AddInParameter(cmd, "@NationalIdNumber", DbType.String, hREmployeeConfidentialInfoEntity.NationalIdNumber); db.AddInParameter(cmd, "@RegionID", DbType.Int64, hREmployeeConfidentialInfoEntity.RegionID); db.AddInParameter(cmd, "@ReligionID", DbType.Int64, hREmployeeConfidentialInfoEntity.ReligionID); db.AddInParameter(cmd, "@BirthMark", DbType.String, hREmployeeConfidentialInfoEntity.BirthMark); db.AddInParameter(cmd, "@BloodGroupID", DbType.Int64, hREmployeeConfidentialInfoEntity.BloodGroupID); db.AddInParameter(cmd, "@DisabilityInformation", DbType.String, hREmployeeConfidentialInfoEntity.DisabilityInformation); db.AddInParameter(cmd, "@GenderID", DbType.Int64, hREmployeeConfidentialInfoEntity.GenderID); db.AddInParameter(cmd, "@AnniversaryDate", DbType.DateTime, hREmployeeConfidentialInfoEntity.AnniversaryDate); db.AddInParameter(cmd, "@Height", DbType.String, hREmployeeConfidentialInfoEntity.Height); db.AddInParameter(cmd, "@Weight", DbType.String, hREmployeeConfidentialInfoEntity.Weight); db.AddInParameter(cmd, "@CurrentNationalityCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.CurrentNationalityCountryID); db.AddInParameter(cmd, "@PreviousNationalityCountryID", DbType.Int64, hREmployeeConfidentialInfoEntity.PreviousNationalityCountryID); db.AddInParameter(cmd, "@HasPassport", DbType.Boolean, hREmployeeConfidentialInfoEntity.HasPassport); db.AddInParameter(cmd, "@HasDrivingLisence", DbType.Boolean, hREmployeeConfidentialInfoEntity.HasDrivingLisence); db.AddInParameter(cmd, "@IsRemoved", DbType.Boolean, hREmployeeConfidentialInfoEntity.IsRemoved); db.AddInParameter(cmd, "@DistrictID", DbType.Int64, hREmployeeConfidentialInfoEntity.District); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { using (IDataReader reader = db.ExecuteReader(cmd, transaction)) { returnCode = GetReturnCodeFromParameter(cmd); } if (returnCode > 0) { transaction.Commit(); } else { throw new ArgumentException("Error Code." + returnCode.ToString()); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { transaction.Dispose(); connection.Close(); connection = null; } } return(returnCode); }