Int64 IHREmployeeVisaInfomationDataAccess.Add(HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(hREmployeeVisaInfomationEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(hREmployeeVisaInfomationEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private HREmployeeVisaInfomationEntity BuildHREmployeeVisaInfomationEntity() { HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity = CurrentHREmployeeVisaInfomationEntity; hREmployeeVisaInfomationEntity.EmployeeID = OverviewEmployeeID; { if (ddlVisaStatusID.SelectedValue == "0") { } else { hREmployeeVisaInfomationEntity.VisaStatusID = Int64.Parse(ddlVisaStatusID.SelectedValue); } } hREmployeeVisaInfomationEntity.VisaTransferInfo = txtVisaTransferInfo.Text.Trim(); hREmployeeVisaInfomationEntity.ProfessionInVisa = txtProfessionInVisa.Text.Trim(); hREmployeeVisaInfomationEntity.VisaNumber = txtVisaNumber.Text.Trim(); if (txtVisaIssuedDate.Text.Trim().IsNotNullOrEmpty()) { hREmployeeVisaInfomationEntity.VisaIssuedDate = MiscUtil.ParseToDateTime(txtVisaIssuedDate.Text); } else { hREmployeeVisaInfomationEntity.VisaIssuedDate = null; } hREmployeeVisaInfomationEntity.Remarks = txtRemarks.Text.Trim(); return(hREmployeeVisaInfomationEntity); }
private Int64 UpdateTran(HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeVisaInfomation_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, "@EmployeeVisaInfomationID", DbType.Int64, hREmployeeVisaInfomationEntity.EmployeeVisaInfomationID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeVisaInfomationEntity.EmployeeID); db.AddInParameter(cmd, "@VisaStatusID", DbType.Int64, hREmployeeVisaInfomationEntity.VisaStatusID); db.AddInParameter(cmd, "@VisaTransferInfo", DbType.String, hREmployeeVisaInfomationEntity.VisaTransferInfo); db.AddInParameter(cmd, "@ProfessionInVisa", DbType.String, hREmployeeVisaInfomationEntity.ProfessionInVisa); db.AddInParameter(cmd, "@VisaNumber", DbType.String, hREmployeeVisaInfomationEntity.VisaNumber); db.AddInParameter(cmd, "@VisaIssuedDate", DbType.DateTime, hREmployeeVisaInfomationEntity.VisaIssuedDate); db.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeVisaInfomationEntity.Remarks); 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 void SaveHREmployeeVisaInfomationEntity() { if (IsValid) { try { HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity = BuildHREmployeeVisaInfomationEntity(); Int64 result = -1; if (hREmployeeVisaInfomationEntity.IsNew) { result = FCCHREmployeeVisaInfomation.GetFacadeCreate().Add(hREmployeeVisaInfomationEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeVisaInfomationEntity.FLD_NAME_EmployeeVisaInfomationID, hREmployeeVisaInfomationEntity.EmployeeVisaInfomationID.ToString(), SQLMatchType.Equal); result = FCCHREmployeeVisaInfomation.GetFacadeCreate().Update(hREmployeeVisaInfomationEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _EmployeeVisaInfomationID = 0; _HREmployeeVisaInfomationEntity = new HREmployeeVisaInfomationEntity(); PrepareInitialView(); BindHREmployeeVisaInfomationList(); if (hREmployeeVisaInfomationEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Visa Infomation Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Visa Infomation Information has been updated successfully.", false); } } else { if (hREmployeeVisaInfomationEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Visa Infomation Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Visa Infomation Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvHREmployeeVisaInfomation_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 EmployeeVisaInfomationID; Int64.TryParse(e.CommandArgument.ToString(), out EmployeeVisaInfomationID); if (EmployeeVisaInfomationID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _EmployeeVisaInfomationID = EmployeeVisaInfomationID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeVisaInfomationEntity.FLD_NAME_EmployeeVisaInfomationID, EmployeeVisaInfomationID.ToString(), SQLMatchType.Equal); HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity = new HREmployeeVisaInfomationEntity(); result = FCCHREmployeeVisaInfomation.GetFacadeCreate().Delete(hREmployeeVisaInfomationEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _EmployeeVisaInfomationID = 0; _HREmployeeVisaInfomationEntity = new HREmployeeVisaInfomationEntity(); PrepareInitialView(); BindHREmployeeVisaInfomationList(); MiscUtil.ShowMessage(lblMessage, "Employee Visa Infomation has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Visa Infomation.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeVisaInfomation_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 Update(HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeVisaInfomation_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@EmployeeVisaInfomationID", DbType.Int64, hREmployeeVisaInfomationEntity.EmployeeVisaInfomationID); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeVisaInfomationEntity.EmployeeID); Database.AddInParameter(cmd, "@VisaStatusID", DbType.Int64, hREmployeeVisaInfomationEntity.VisaStatusID); Database.AddInParameter(cmd, "@VisaTransferInfo", DbType.String, hREmployeeVisaInfomationEntity.VisaTransferInfo); Database.AddInParameter(cmd, "@ProfessionInVisa", DbType.String, hREmployeeVisaInfomationEntity.ProfessionInVisa); Database.AddInParameter(cmd, "@VisaNumber", DbType.String, hREmployeeVisaInfomationEntity.VisaNumber); Database.AddInParameter(cmd, "@VisaIssuedDate", DbType.DateTime, hREmployeeVisaInfomationEntity.VisaIssuedDate); Database.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeVisaInfomationEntity.Remarks); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeeVisaInfomationEntity already exists. Please specify another HREmployeeVisaInfomationEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeVisaInfomationEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeVisaInfomationEntity already exists. Please specify another HREmployeeVisaInfomationEntity."); } } } } return(returnCode); }
private void PrepareEditView() { HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity = CurrentHREmployeeVisaInfomationEntity; if (!hREmployeeVisaInfomationEntity.IsNew) { if (ddlVisaStatusID.Items.Count > 0 && hREmployeeVisaInfomationEntity.VisaStatusID != null) { ddlVisaStatusID.SelectedValue = hREmployeeVisaInfomationEntity.VisaStatusID.ToString(); } txtVisaTransferInfo.Text = hREmployeeVisaInfomationEntity.VisaTransferInfo.ToString(); txtProfessionInVisa.Text = hREmployeeVisaInfomationEntity.ProfessionInVisa.ToString(); txtVisaNumber.Text = hREmployeeVisaInfomationEntity.VisaNumber.ToString(); txtVisaIssuedDate.Text = hREmployeeVisaInfomationEntity.VisaIssuedDate.ToStringDefault(); txtRemarks.Text = hREmployeeVisaInfomationEntity.Remarks.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
private Int64 Delete(HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeVisaInfomation_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("HREmployeeVisaInfomationEntity already exists. Please specify another HREmployeeVisaInfomationEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeVisaInfomationEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeVisaInfomationEntity already exists. Please specify another HREmployeeVisaInfomationEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _EmployeeVisaInfomationID = 0; _HREmployeeVisaInfomationEntity = new HREmployeeVisaInfomationEntity(); PrepareInitialView(); }
Int64 IHREmployeeVisaInfomationFacade.Delete(HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeVisaInfomationDataAccess().Delete(hREmployeeVisaInfomationEntity, filterExpression, option, reqTran)); }
Int64 IHREmployeeVisaInfomationFacade.Add(HREmployeeVisaInfomationEntity hREmployeeVisaInfomationEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeVisaInfomationDataAccess().Add(hREmployeeVisaInfomationEntity, option, reqTran)); }