Int64 IHRSalaryAdjustmentDataAccess.Add(HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(hRSalaryAdjustmentEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(hRSalaryAdjustmentEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HRSalaryAdjustment_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, "@SalaryAdjustmentID", DbType.Int64, hRSalaryAdjustmentEntity.SalaryAdjustmentID); db.AddInParameter(cmd, "@FiscalYearID", DbType.Int64, hRSalaryAdjustmentEntity.FiscalYearID); db.AddInParameter(cmd, "@SalarySessionID", DbType.Int64, hRSalaryAdjustmentEntity.SalarySessionID); db.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hRSalaryAdjustmentEntity.EmployeeID); db.AddInParameter(cmd, "@SalaryLevel", DbType.Int32, hRSalaryAdjustmentEntity.SalaryLevel); db.AddInParameter(cmd, "@DesignationID", DbType.Int64, hRSalaryAdjustmentEntity.DesignationID); db.AddInParameter(cmd, "@EmployeeCode", DbType.String, hRSalaryAdjustmentEntity.EmployeeCode); db.AddInParameter(cmd, "@EmployeeJobTypeID", DbType.Int64, hRSalaryAdjustmentEntity.EmployeeJobTypeID); db.AddInParameter(cmd, "@AdjustmentAmount", DbType.Decimal, hRSalaryAdjustmentEntity.AdjustmentAmount); db.AddInParameter(cmd, "@Remarks", DbType.String, hRSalaryAdjustmentEntity.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 PrepareEditView() { HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity = CurrentHRSalaryAdjustmentEntity; if (!hRSalaryAdjustmentEntity.IsNew) { } }
private void SaveHRSalaryAdjustmentEntity() { if (IsValid) { try { HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity = BuildHRSalaryAdjustmentEntity(); Int64 result = -1; if (hRSalaryAdjustmentEntity.IsNew) { result = FCCHRSalaryAdjustment.GetFacadeCreate().Add(hRSalaryAdjustmentEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(HRSalaryAdjustmentEntity.FLD_NAME_SalaryAdjustmentID, hRSalaryAdjustmentEntity.SalaryAdjustmentID.ToString(), SQLMatchType.Equal); result = FCCHRSalaryAdjustment.GetFacadeCreate().Update(hRSalaryAdjustmentEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _SalaryAdjustmentID = 0; _HRSalaryAdjustmentEntity = new HRSalaryAdjustmentEntity(); PrepareInitialView(); BindHRSalaryAdjustmentList(); //if (hRSalaryAdjustmentEntity.IsNew) //{ // MiscUtil.ShowMessage(lblMessage, "Salary Adjustment Information has been added successfully.", false); //} //else //{ // MiscUtil.ShowMessage(lblMessage, "Salary Adjustment Information has been updated successfully.", false); //} } else { //if (hRSalaryAdjustmentEntity.IsNew) //{ // MiscUtil.ShowMessage(lblMessage, "Failed to add Salary Adjustment Information.", false); //} //else //{ // MiscUtil.ShowMessage(lblMessage, "Failed to update Salary Adjustment Information.", false); //} } } catch (Exception ex) { //MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private HRSalaryAdjustmentEntity BuildHRSalaryAdjustmentEntity() { HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity = CurrentHRSalaryAdjustmentEntity; //if (!txtSalaryAdjustmentID.Text.Trim().IsNullOrEmpty()) //{ // hRSalaryAdjustmentEntity.SalaryAdjustmentID = Int64.Parse(txtSalaryAdjustmentID.Text.Trim()); //} return(hRSalaryAdjustmentEntity); }
protected void lvHRSalaryAdjustment_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 SalaryAdjustmentID; Int64.TryParse(e.CommandArgument.ToString(), out SalaryAdjustmentID); if (SalaryAdjustmentID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _SalaryAdjustmentID = SalaryAdjustmentID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(HRSalaryAdjustmentEntity.FLD_NAME_SalaryAdjustmentID, SalaryAdjustmentID.ToString(), SQLMatchType.Equal); HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity = new HRSalaryAdjustmentEntity(); result = FCCHRSalaryAdjustment.GetFacadeCreate().Delete(hRSalaryAdjustmentEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _SalaryAdjustmentID = 0; _HRSalaryAdjustmentEntity = new HRSalaryAdjustmentEntity(); PrepareInitialView(); BindHRSalaryAdjustmentList(); MiscUtil.ShowMessage(lblMessage, "Salary Adjustment has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete Salary Adjustment.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HRSalaryAdjustment_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(HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HRSalaryAdjustment_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@SalaryAdjustmentID", DbType.Int64, hRSalaryAdjustmentEntity.SalaryAdjustmentID); Database.AddInParameter(cmd, "@FiscalYearID", DbType.Int64, hRSalaryAdjustmentEntity.FiscalYearID); Database.AddInParameter(cmd, "@SalarySessionID", DbType.Int64, hRSalaryAdjustmentEntity.SalarySessionID); Database.AddInParameter(cmd, "@EmployeeID", DbType.Int64, hRSalaryAdjustmentEntity.EmployeeID); Database.AddInParameter(cmd, "@SalaryLevel", DbType.Int32, hRSalaryAdjustmentEntity.SalaryLevel); Database.AddInParameter(cmd, "@DesignationID", DbType.Int64, hRSalaryAdjustmentEntity.DesignationID); Database.AddInParameter(cmd, "@EmployeeCode", DbType.String, hRSalaryAdjustmentEntity.EmployeeCode); Database.AddInParameter(cmd, "@EmployeeJobTypeID", DbType.Int64, hRSalaryAdjustmentEntity.EmployeeJobTypeID); Database.AddInParameter(cmd, "@AdjustmentAmount", DbType.Decimal, hRSalaryAdjustmentEntity.AdjustmentAmount); Database.AddInParameter(cmd, "@Remarks", DbType.String, hRSalaryAdjustmentEntity.Remarks); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("HRSalaryAdjustmentEntity already exists. Please specify another HRSalaryAdjustmentEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HRSalaryAdjustmentEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HRSalaryAdjustmentEntity already exists. Please specify another HRSalaryAdjustmentEntity."); } } } } return(returnCode); }
private Int64 Delete(HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.HRSalaryAdjustment_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("HRSalaryAdjustmentEntity already exists. Please specify another HRSalaryAdjustmentEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("HRSalaryAdjustmentEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("HRSalaryAdjustmentEntity already exists. Please specify another HRSalaryAdjustmentEntity."); } } } } return(returnCode); }
private void PrepareEditView() { HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity = CurrentHRSalaryAdjustmentEntity; if (!hRSalaryAdjustmentEntity.IsNew) { //txtSalaryAdjustmentID.Text = hRSalaryAdjustmentEntity.SalaryAdjustmentID.ToString(); if (ddlFiscalYearID.Items.Count > 0 && hRSalaryAdjustmentEntity.FiscalYearID != null) { ddlFiscalYearID.SelectedValue = hRSalaryAdjustmentEntity.FiscalYearID.ToString(); } if (ddlSalarySessionID.Items.Count > 0 && hRSalaryAdjustmentEntity.SalarySessionID != null) { ddlSalarySessionID.SelectedValue = hRSalaryAdjustmentEntity.SalarySessionID.ToString(); } if (ddlEmployeeID.Items.Count > 0 && hRSalaryAdjustmentEntity.EmployeeID != null) { ddlEmployeeID.SelectedValue = hRSalaryAdjustmentEntity.EmployeeID.ToString(); } txtSalaryLevel.Text = hRSalaryAdjustmentEntity.SalaryLevel.ToString(); if (hRSalaryAdjustmentEntity.DesignationID != null && ddlDesignationID.Items.Count > 0) { ddlDesignationID.SelectedValue = hRSalaryAdjustmentEntity.DesignationID.ToString(); } txtEmployeeCode.Text = hRSalaryAdjustmentEntity.EmployeeCode.ToString(); txtEmployeeJobTypeID.Text = hRSalaryAdjustmentEntity.EmployeeJobTypeID.ToString(); txtAdjustmentAmount.Text = hRSalaryAdjustmentEntity.AdjustmentAmount.ToString(); txtRemarks.Text = hRSalaryAdjustmentEntity.Remarks.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
protected void btnAddNew_Click(object sender, EventArgs e) { _SalaryAdjustmentID = 0; _HRSalaryAdjustmentEntity = new HRSalaryAdjustmentEntity(); PrepareInitialView(); }
private HRSalaryAdjustmentEntity BuildHRSalaryAdjustmentEntity() { HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity = CurrentHRSalaryAdjustmentEntity; //if (!txtSalaryAdjustmentID.Text.Trim().IsNullOrEmpty()) //{ // hRSalaryAdjustmentEntity.SalaryAdjustmentID = Int64.Parse(txtSalaryAdjustmentID.Text.Trim()); //} if (ddlFiscalYearID.Items.Count > 0) { if (ddlFiscalYearID.SelectedValue == "0") { } else { hRSalaryAdjustmentEntity.FiscalYearID = Int64.Parse(ddlFiscalYearID.SelectedValue); } } if (ddlSalarySessionID.Items.Count > 0) { if (ddlSalarySessionID.SelectedValue == "0") { } else { hRSalaryAdjustmentEntity.SalarySessionID = Int64.Parse(ddlSalarySessionID.SelectedValue); } } if (ddlEmployeeID.Items.Count > 0) { if (ddlEmployeeID.SelectedValue == "0") { } else { hRSalaryAdjustmentEntity.EmployeeID = Int64.Parse(ddlEmployeeID.SelectedValue); } } if (!txtSalaryLevel.Text.Trim().IsNullOrEmpty()) { hRSalaryAdjustmentEntity.SalaryLevel = Int32.Parse(txtSalaryLevel.Text.Trim()); } else { hRSalaryAdjustmentEntity.SalaryLevel = null; } if (ddlDesignationID.Items.Count > 0) { if (ddlDesignationID.SelectedValue == "0") { hRSalaryAdjustmentEntity.DesignationID = null; } else { hRSalaryAdjustmentEntity.DesignationID = Int64.Parse(ddlDesignationID.SelectedValue); } } hRSalaryAdjustmentEntity.EmployeeCode = txtEmployeeCode.Text.Trim(); if (!txtEmployeeJobTypeID.Text.Trim().IsNullOrEmpty()) { hRSalaryAdjustmentEntity.EmployeeJobTypeID = Int64.Parse(txtEmployeeJobTypeID.Text.Trim()); } if (!txtAdjustmentAmount.Text.Trim().IsNullOrEmpty()) { hRSalaryAdjustmentEntity.AdjustmentAmount = Decimal.Parse(txtAdjustmentAmount.Text.Trim()); } hRSalaryAdjustmentEntity.Remarks = txtRemarks.Text; return(hRSalaryAdjustmentEntity); }
Int64 IHRSalaryAdjustmentFacade.Delete(HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHRSalaryAdjustmentDataAccess().Delete(hRSalaryAdjustmentEntity, filterExpression, option, reqTran)); }
Int64 IHRSalaryAdjustmentFacade.Add(HRSalaryAdjustmentEntity hRSalaryAdjustmentEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateHRSalaryAdjustmentDataAccess().Add(hRSalaryAdjustmentEntity, option, reqTran)); }