private void PrepareEditView() { HREmployeeAllowanceEntity hREmployeeAllowanceEntity = CurrentHREmployeeAllowanceEntity; if (!hREmployeeAllowanceEntity.IsNew) { if (ddlEmployeeID.Items.Count > 0 && hREmployeeAllowanceEntity.EmployeeID != null) { ddlEmployeeID.SelectedValue = hREmployeeAllowanceEntity.EmployeeID.ToString(); } if (ddlFiscalYearID.Items.Count > 0 && hREmployeeAllowanceEntity.FiscalYearID != null) { ddlFiscalYearID.SelectedValue = hREmployeeAllowanceEntity.FiscalYearID.ToString(); } if (ddlAllowanceCategoryID.Items.Count > 0 && hREmployeeAllowanceEntity.AllowanceCategoryID != null) { ddlAllowanceCategoryID.SelectedValue = hREmployeeAllowanceEntity.AllowanceCategoryID.ToString(); } txtAmount.Text = hREmployeeAllowanceEntity.Amount.ToString(); txtRemarks.Text = hREmployeeAllowanceEntity.Remarks.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
Int64 IHREmployeeAllowanceDataAccess.Add(HREmployeeAllowanceEntity hREmployeeAllowanceEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(hREmployeeAllowanceEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(hREmployeeAllowanceEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private HREmployeeAllowanceEntity BuildHREmployeeAllowanceEntity() { HREmployeeAllowanceEntity hREmployeeAllowanceEntity = CurrentHREmployeeAllowanceEntity; return(hREmployeeAllowanceEntity); }
private void PrepareEditView() { HREmployeeAllowanceEntity hREmployeeAllowanceEntity = CurrentHREmployeeAllowanceEntity; if (!hREmployeeAllowanceEntity.IsNew) { } }
private Int64 UpdateTran(HREmployeeAllowanceEntity hREmployeeAllowanceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeAllowance_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, "@EmployeeAllowanceID", DbType.Int64, hREmployeeAllowanceEntity.EmployeeAllowanceID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeAllowanceEntity.EmployeeID); db.AddInParameter(cmd, "@FiscalYearID", DbType.Int64, hREmployeeAllowanceEntity.FiscalYearID); db.AddInParameter(cmd, "@AllowanceCategoryID", DbType.Int64, hREmployeeAllowanceEntity.AllowanceCategoryID); db.AddInParameter(cmd, "@Amount", DbType.Decimal, hREmployeeAllowanceEntity.Amount); db.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeAllowanceEntity.Remarks); db.AddInParameter(cmd, "@CreateDate", DbType.DateTime, hREmployeeAllowanceEntity.CreateDate); 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 SaveHREmployeeAllowanceEntity() { if (IsValid) { try { HREmployeeAllowanceEntity hREmployeeAllowanceEntity = BuildHREmployeeAllowanceEntity(); Int64 result = -1; if (hREmployeeAllowanceEntity.IsNew) { result = FCCHREmployeeAllowance.GetFacadeCreate().Add(hREmployeeAllowanceEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeAllowanceEntity.FLD_NAME_EmployeeAllowanceID, hREmployeeAllowanceEntity.EmployeeAllowanceID.ToString(), SQLMatchType.Equal); result = FCCHREmployeeAllowance.GetFacadeCreate().Update(hREmployeeAllowanceEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _EmployeeAllowanceID = 0; _HREmployeeAllowanceEntity = new HREmployeeAllowanceEntity(); PrepareInitialView(); BindHREmployeeAllowanceList(); if (hREmployeeAllowanceEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Employee Allowance Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "Employee Allowance Information has been updated successfully.", false); } } else { if (hREmployeeAllowanceEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add Employee Allowance Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update Employee Allowance Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 DeleteTran(HREmployeeAllowanceEntity hREmployeeAllowanceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeAllowance_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); }
protected void lvHREmployeeAllowance_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 EmployeeAllowanceID; Int64.TryParse(e.CommandArgument.ToString(), out EmployeeAllowanceID); if (EmployeeAllowanceID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _EmployeeAllowanceID = EmployeeAllowanceID; PrepareEditView(); } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(HREmployeeAllowanceEntity.FLD_NAME_EmployeeAllowanceID, EmployeeAllowanceID.ToString(), SQLMatchType.Equal); HREmployeeAllowanceEntity hREmployeeAllowanceEntity = new HREmployeeAllowanceEntity(); result = FCCHREmployeeAllowance.GetFacadeCreate().Delete(hREmployeeAllowanceEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _EmployeeAllowanceID = 0; _HREmployeeAllowanceEntity = new HREmployeeAllowanceEntity(); PrepareInitialView(); BindHREmployeeAllowanceList(); MiscUtil.ShowMessage(lblMessage, "Employee Allowance has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Employee Allowance.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private HREmployeeAllowanceEntity BuildHREmployeeAllowanceEntity() { HREmployeeAllowanceEntity hREmployeeAllowanceEntity = CurrentHREmployeeAllowanceEntity; if (ddlEmployeeID.Items.Count > 0) { if (ddlEmployeeID.SelectedValue == "0") { } else { hREmployeeAllowanceEntity.EmployeeID = Int64.Parse(ddlEmployeeID.SelectedValue); } } if (ddlFiscalYearID.Items.Count > 0) { if (ddlFiscalYearID.SelectedValue == "0") { } else { hREmployeeAllowanceEntity.FiscalYearID = Int64.Parse(ddlFiscalYearID.SelectedValue); } } if (ddlAllowanceCategoryID.Items.Count > 0) { if (ddlAllowanceCategoryID.SelectedValue == "0") { } else { hREmployeeAllowanceEntity.AllowanceCategoryID = Int64.Parse(ddlAllowanceCategoryID.SelectedValue); } } if (!txtAmount.Text.Trim().IsNullOrEmpty()) { hREmployeeAllowanceEntity.Amount = Decimal.Parse(txtAmount.Text.Trim()); } hREmployeeAllowanceEntity.Remarks = txtRemarks.Text.Trim(); hREmployeeAllowanceEntity.CreateDate = System.DateTime.Now; return(hREmployeeAllowanceEntity); }
private Int64 Update(HREmployeeAllowanceEntity hREmployeeAllowanceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeAllowance_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@EmployeeAllowanceID", DbType.Int64, hREmployeeAllowanceEntity.EmployeeAllowanceID); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hREmployeeAllowanceEntity.EmployeeID); Database.AddInParameter(cmd, "@FiscalYearID", DbType.Int64, hREmployeeAllowanceEntity.FiscalYearID); Database.AddInParameter(cmd, "@AllowanceCategoryID", DbType.Int64, hREmployeeAllowanceEntity.AllowanceCategoryID); Database.AddInParameter(cmd, "@Amount", DbType.Decimal, hREmployeeAllowanceEntity.Amount); Database.AddInParameter(cmd, "@Remarks", DbType.String, hREmployeeAllowanceEntity.Remarks); Database.AddInParameter(cmd, "@CreateDate", DbType.DateTime, hREmployeeAllowanceEntity.CreateDate); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HREmployeeAllowanceEntity already exists. Please specify another HREmployeeAllowanceEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeAllowanceEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeAllowanceEntity already exists. Please specify another HREmployeeAllowanceEntity."); } } } } return(returnCode); }
private Int64 Delete(HREmployeeAllowanceEntity hREmployeeAllowanceEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HREmployeeAllowance_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("HREmployeeAllowanceEntity already exists. Please specify another HREmployeeAllowanceEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HREmployeeAllowanceEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HREmployeeAllowanceEntity already exists. Please specify another HREmployeeAllowanceEntity."); } } } } return(returnCode); }
Int64 IHREmployeeAllowanceFacade.Delete(HREmployeeAllowanceEntity hREmployeeAllowanceEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeAllowanceDataAccess().Delete(hREmployeeAllowanceEntity, filterExpression, option, reqTran)); }
Int64 IHREmployeeAllowanceFacade.Add(HREmployeeAllowanceEntity hREmployeeAllowanceEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHREmployeeAllowanceDataAccess().Add(hREmployeeAllowanceEntity, option, reqTran)); }
protected void btnAddNew_Click(object sender, EventArgs e) { _EmployeeAllowanceID = 0; _HREmployeeAllowanceEntity = new HREmployeeAllowanceEntity(); PrepareInitialView(); }