private void PrepareEditView() { HREmployeeExperienceEntity hREmployeeExperienceEntity = CurrentHREmployeeExperienceEntity; if (!hREmployeeExperienceEntity.IsNew) { if (ddlCompanyCountryID.Items.Count > 0 && hREmployeeExperienceEntity.CompanyCountryID != null) { ddlCompanyCountryID.SelectedValue = hREmployeeExperienceEntity.CompanyCountryID.ToString(); } txtCompanyName.Text = hREmployeeExperienceEntity.CompanyName.ToString(); txtAddress.Text = hREmployeeExperienceEntity.Address.ToString(); if (ddlEmployeeJobTypeID.Items.Count > 0 && hREmployeeExperienceEntity.EmployeeJobTypeID != null) { ddlEmployeeJobTypeID.SelectedValue = hREmployeeExperienceEntity.EmployeeJobTypeID.ToString(); } txtJobEndDate.Text = hREmployeeExperienceEntity.JobEndDate.ToStringDefault(); txtJobStartDate.Text = hREmployeeExperienceEntity.JobStartDate.ToStringDefault(); txtContactNo.Text = hREmployeeExperienceEntity.ContactNo.ToString(); txtWebLink.Text = hREmployeeExperienceEntity.WebLink.ToString(); chkIsLastCompany.Checked = hREmployeeExperienceEntity.IsLastCompany; txtDesignation.Text = hREmployeeExperienceEntity.Designation.ToString(); txtResponsibility.Text = hREmployeeExperienceEntity.Responsibility.ToString(); txtSupervisorName.Text = hREmployeeExperienceEntity.SupervisorName.ToString(); txtSalaryOrBenefits.Text = hREmployeeExperienceEntity.SalaryOrBenefits.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
Int64 IHREmployeeExperienceDataAccess.Add(HREmployeeExperienceEntity hREmployeeExperienceEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(hREmployeeExperienceEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(hREmployeeExperienceEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private HREmployeeExperienceEntity BuildHREmployeeExperienceEntity() { HREmployeeExperienceEntity hREmployeeExperienceEntity = CurrentHREmployeeExperienceEntity; hREmployeeExperienceEntity.EmployeeID = OverviewEmployeeID; if (ddlCompanyCountryID.Items.Count > 0) { if (ddlCompanyCountryID.SelectedValue == "0") { } else { hREmployeeExperienceEntity.CompanyCountryID = Int64.Parse(ddlCompanyCountryID.SelectedValue); } } hREmployeeExperienceEntity.CompanyName = txtCompanyName.Text.Trim(); hREmployeeExperienceEntity.Address = txtAddress.Text.Trim(); if (ddlEmployeeJobTypeID.Items.Count > 0) { if (ddlEmployeeJobTypeID.SelectedValue == "0") { } else { hREmployeeExperienceEntity.EmployeeJobTypeID = Int64.Parse(ddlEmployeeJobTypeID.SelectedValue); } } if (txtJobEndDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeExperienceEntity.JobEndDate = MiscUtil.ParseToDateTime(txtJobEndDate.Text); } else { hREmployeeExperienceEntity.JobEndDate = null; } if (txtJobStartDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeExperienceEntity.JobStartDate = MiscUtil.ParseToDateTime(txtJobStartDate.Text); } hREmployeeExperienceEntity.ContactNo = txtContactNo.Text.Trim(); hREmployeeExperienceEntity.WebLink = txtWebLink.Text.Trim(); hREmployeeExperienceEntity.IsLastCompany = chkIsLastCompany.Checked; hREmployeeExperienceEntity.Designation = txtDesignation.Text.Trim(); hREmployeeExperienceEntity.SupervisorName = txtSupervisorName.Text.Trim(); hREmployeeExperienceEntity.SalaryOrBenefits = txtSalaryOrBenefits.Text.Trim(); hREmployeeExperienceEntity.Responsibility = txtResponsibility.Text.Trim(); return(hREmployeeExperienceEntity); }
private void SaveHREmployeeExperienceEntity() { if (IsValid) { try { HREmployeeExperienceEntity hREmployeeExperienceEntity = BuildHREmployeeExperienceEntity(); Int64 result = -1; if (hREmployeeExperienceEntity.IsNew) { result = FCCHREmployeeExperience.GetFacadeCreate().Add(hREmployeeExperienceEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeExperienceEntity.FLD_NAME_EmployeeExperienceID, hREmployeeExperienceEntity.EmployeeExperienceID.ToString(), SQLMatchType.Equal); result = FCCHREmployeeExperience.GetFacadeCreate().Update(hREmployeeExperienceEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _EmployeeExperienceID = 0; _HREmployeeExperienceEntity = new HREmployeeExperienceEntity(); PrepareInitialView(); BindHREmployeeExperienceList(); if (hREmployeeExperienceEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Experience Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Experience Information has been updated successfully.", false); } } else { if (hREmployeeExperienceEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Experience Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Experience Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 Update(HREmployeeExperienceEntity hREmployeeExperienceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeExperience_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@EmployeeExperienceID", DbType.Int64, hREmployeeExperienceEntity.EmployeeExperienceID); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeExperienceEntity.EmployeeID); Database.AddInParameter(cmd, "@CompanyCountryID", DbType.Int64, hREmployeeExperienceEntity.CompanyCountryID); Database.AddInParameter(cmd, "@CompanyName", DbType.String, hREmployeeExperienceEntity.CompanyName); Database.AddInParameter(cmd, "@Address", DbType.String, hREmployeeExperienceEntity.Address); Database.AddInParameter(cmd, "@EmployeeJobTypeID", DbType.Int64, hREmployeeExperienceEntity.EmployeeJobTypeID); Database.AddInParameter(cmd, "@JobEndDate", DbType.DateTime, hREmployeeExperienceEntity.JobEndDate); Database.AddInParameter(cmd, "@JobStartDate", DbType.DateTime, hREmployeeExperienceEntity.JobStartDate); Database.AddInParameter(cmd, "@ContactNo", DbType.String, hREmployeeExperienceEntity.ContactNo); Database.AddInParameter(cmd, "@WebLink", DbType.String, hREmployeeExperienceEntity.WebLink); Database.AddInParameter(cmd, "@IsLastCompany", DbType.Boolean, hREmployeeExperienceEntity.IsLastCompany); Database.AddInParameter(cmd, "@Designation", DbType.String, hREmployeeExperienceEntity.Designation); Database.AddInParameter(cmd, "@Responsibility", DbType.String, hREmployeeExperienceEntity.Responsibility); Database.AddInParameter(cmd, "@SupervisorName", DbType.String, hREmployeeExperienceEntity.SupervisorName); Database.AddInParameter(cmd, "@SalaryOrBenefits", DbType.String, hREmployeeExperienceEntity.SalaryOrBenefits); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeeExperienceEntity already exists. Please specify another HREmployeeExperienceEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeExperienceEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeExperienceEntity already exists. Please specify another HREmployeeExperienceEntity."); } } } } return(returnCode); }
protected void lvHREmployeeExperience_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 EmployeeExperienceID; Int64.TryParse(e.CommandArgument.ToString(), out EmployeeExperienceID); if (EmployeeExperienceID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _EmployeeExperienceID = EmployeeExperienceID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeExperienceEntity.FLD_NAME_EmployeeExperienceID, EmployeeExperienceID.ToString(), SQLMatchType.Equal); HREmployeeExperienceEntity hREmployeeExperienceEntity = new HREmployeeExperienceEntity(); result = FCCHREmployeeExperience.GetFacadeCreate().Delete(hREmployeeExperienceEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _EmployeeExperienceID = 0; _HREmployeeExperienceEntity = new HREmployeeExperienceEntity(); PrepareInitialView(); BindHREmployeeExperienceList(); MiscUtil.ShowMessage(lblMessage, "Employee Experience has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Experience.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(HREmployeeExperienceEntity hREmployeeExperienceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeExperience_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(HREmployeeExperienceEntity hREmployeeExperienceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeExperience_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("HREmployeeExperienceEntity already exists. Please specify another HREmployeeExperienceEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeExperienceEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeExperienceEntity already exists. Please specify another HREmployeeExperienceEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _EmployeeExperienceID = 0; _HREmployeeExperienceEntity = new HREmployeeExperienceEntity(); PrepareInitialView(); }
Int64 IHREmployeeExperienceFacade.Delete(HREmployeeExperienceEntity hREmployeeExperienceEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeExperienceDataAccess().Delete(hREmployeeExperienceEntity, filterExpression, option, reqTran)); }
Int64 IHREmployeeExperienceFacade.Add(HREmployeeExperienceEntity hREmployeeExperienceEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeExperienceDataAccess().Add(hREmployeeExperienceEntity, option, reqTran)); }
private Int64 UpdateTran(HREmployeeExperienceEntity hREmployeeExperienceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeExperience_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, "@EmployeeExperienceID", DbType.Int64, hREmployeeExperienceEntity.EmployeeExperienceID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeExperienceEntity.EmployeeID); db.AddInParameter(cmd, "@CompanyCountryID", DbType.Int64, hREmployeeExperienceEntity.CompanyCountryID); db.AddInParameter(cmd, "@CompanyName", DbType.String, hREmployeeExperienceEntity.CompanyName); db.AddInParameter(cmd, "@Address", DbType.String, hREmployeeExperienceEntity.Address); db.AddInParameter(cmd, "@EmployeeJobTypeID", DbType.Int64, hREmployeeExperienceEntity.EmployeeJobTypeID); db.AddInParameter(cmd, "@JobEndDate", DbType.DateTime, hREmployeeExperienceEntity.JobEndDate); db.AddInParameter(cmd, "@JobStartDate", DbType.DateTime, hREmployeeExperienceEntity.JobStartDate); db.AddInParameter(cmd, "@ContactNo", DbType.String, hREmployeeExperienceEntity.ContactNo); db.AddInParameter(cmd, "@WebLink", DbType.String, hREmployeeExperienceEntity.WebLink); db.AddInParameter(cmd, "@IsLastCompany", DbType.Boolean, hREmployeeExperienceEntity.IsLastCompany); db.AddInParameter(cmd, "@Designation", DbType.String, hREmployeeExperienceEntity.Designation); db.AddInParameter(cmd, "@Responsibility", DbType.String, hREmployeeExperienceEntity.Responsibility); db.AddInParameter(cmd, "@SupervisorName", DbType.String, hREmployeeExperienceEntity.SupervisorName); db.AddInParameter(cmd, "@SalaryOrBenefits", DbType.String, hREmployeeExperienceEntity.SalaryOrBenefits); 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); }