private void PrepareEditView() { ACBankAccountEntity aCBankAccountEntity = CurrentACBankAccountEntity; if (!aCBankAccountEntity.IsNew) { if (ddlACCAccountID.Items.Count > 0 && aCBankAccountEntity.ACCAccountID != null) { ddlACCAccountID.SelectedValue = aCBankAccountEntity.ACCAccountID.ToString(); } txtBankAccountName.Text = aCBankAccountEntity.BankAccountName.ToString(); txtBankAccountNumber.Text = aCBankAccountEntity.BankAccountNumber.ToString(); if (ddlBankAccountTypeID.Items.Count > 0 && aCBankAccountEntity.BankAccountTypeID != null) { ddlBankAccountTypeID.SelectedValue = aCBankAccountEntity.BankAccountTypeID.ToString(); } if (ddlCurrencyID.Items.Count > 0 && aCBankAccountEntity.CurrencyID != null) { ddlCurrencyID.SelectedValue = aCBankAccountEntity.CurrencyID.ToString(); } chkIsDefaultCurrencyAccount.Checked = aCBankAccountEntity.IsDefaultCurrencyAccount; txtBankName.Text = aCBankAccountEntity.BankName.ToString(); txtBankAddress.Text = aCBankAccountEntity.BankAddress.ToString(); btnSubmit.Text = "Update"; btnAddNew.Visible = false; } }
Int64 IACBankAccountDataAccess.Add(ACBankAccountEntity aCBankAccountEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(aCBankAccountEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(aCBankAccountEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private void GetBankInfo() { ACBankAccountEntity entity = FCCACBankAccount.GetFacadeCreate().GetByID(Int64.Parse(ddlBankList.SelectedValue)); txtBankName.Text = entity.BankAccountName; txtBankAddress.Text = entity.BankAddress; }
Int64 IACBankAccountDataAccess.Delete(ACBankAccountEntity aCBankAccountEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Delete(aCBankAccountEntity, filterExpression, option); break; } case TransactionRequired.Yes: { retValues = DeleteTran(aCBankAccountEntity, filterExpression, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(ACBankAccountEntity aCBankAccountEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACBankAccount_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, "@BankAccountID", DbType.Int64, aCBankAccountEntity.BankAccountID); db.AddInParameter(cmd, "@ACCAccountID", DbType.Int64, aCBankAccountEntity.ACCAccountID); db.AddInParameter(cmd, "@BankAccountName", DbType.String, aCBankAccountEntity.BankAccountName); db.AddInParameter(cmd, "@BankAccountNumber", DbType.String, aCBankAccountEntity.BankAccountNumber); db.AddInParameter(cmd, "@BankAccountTypeID", DbType.Int64, aCBankAccountEntity.BankAccountTypeID); db.AddInParameter(cmd, "@CurrencyID", DbType.Int64, aCBankAccountEntity.CurrencyID); db.AddInParameter(cmd, "@IsDefaultCurrencyAccount", DbType.Boolean, aCBankAccountEntity.IsDefaultCurrencyAccount); db.AddInParameter(cmd, "@BankName", DbType.String, aCBankAccountEntity.BankName); db.AddInParameter(cmd, "@BankAddress", DbType.String, aCBankAccountEntity.BankAddress); 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 SaveACBankAccountEntity() { if (IsValid) { try { ACBankAccountEntity aCBankAccountEntity = BuildACBankAccountEntity(); Int64 result = -1; if (aCBankAccountEntity.IsNew) { result = FCCACBankAccount.GetFacadeCreate().Add(aCBankAccountEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(ACBankAccountEntity.FLD_NAME_BankAccountID, aCBankAccountEntity.BankAccountID.ToString(), SQLMatchType.Equal); result = FCCACBankAccount.GetFacadeCreate().Update(aCBankAccountEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _BankAccountID = 0; _ACBankAccountEntity = new ACBankAccountEntity(); PrepareInitialView(); BindACBankAccountList(); if (aCBankAccountEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "A CBank Account Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "A CBank Account Information has been updated successfully.", false); } } else { if (aCBankAccountEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add A CBank Account Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update A CBank Account Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
protected void lvACBankAccount_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 BankAccountID; Int64.TryParse(e.CommandArgument.ToString(), out BankAccountID); if (BankAccountID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _BankAccountID = BankAccountID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(ACBankAccountEntity.FLD_NAME_BankAccountID, BankAccountID.ToString(), SQLMatchType.Equal); ACBankAccountEntity aCBankAccountEntity = new ACBankAccountEntity(); result = FCCACBankAccount.GetFacadeCreate().Delete(aCBankAccountEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _BankAccountID = 0; _ACBankAccountEntity = new ACBankAccountEntity(); PrepareInitialView(); BindACBankAccountList(); MiscUtil.ShowMessage(lblMessage, "A CBank Account has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete A CBank Account.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 DeleteTran(ACBankAccountEntity aCBankAccountEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACBankAccount_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(ACBankAccountEntity aCBankAccountEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACBankAccount_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@BankAccountID", DbType.Int64, aCBankAccountEntity.BankAccountID); Database.AddInParameter(cmd, "@ACCAccountID", DbType.Int64, aCBankAccountEntity.ACCAccountID); Database.AddInParameter(cmd, "@BankAccountName", DbType.String, aCBankAccountEntity.BankAccountName); Database.AddInParameter(cmd, "@BankAccountNumber", DbType.String, aCBankAccountEntity.BankAccountNumber); Database.AddInParameter(cmd, "@BankAccountTypeID", DbType.Int64, aCBankAccountEntity.BankAccountTypeID); Database.AddInParameter(cmd, "@CurrencyID", DbType.Int64, aCBankAccountEntity.CurrencyID); Database.AddInParameter(cmd, "@IsDefaultCurrencyAccount", DbType.Boolean, aCBankAccountEntity.IsDefaultCurrencyAccount); Database.AddInParameter(cmd, "@BankName", DbType.String, aCBankAccountEntity.BankName); Database.AddInParameter(cmd, "@BankAddress", DbType.String, aCBankAccountEntity.BankAddress); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("ACBankAccountEntity already exists. Please specify another ACBankAccountEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("ACBankAccountEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("ACBankAccountEntity already exists. Please specify another ACBankAccountEntity."); } } } } return(returnCode); }
private ACBankAccountEntity BuildACBankAccountEntity() { ACBankAccountEntity aCBankAccountEntity = CurrentACBankAccountEntity; if (ddlACCAccountID.Items.Count > 0) { if (ddlACCAccountID.SelectedValue == "0") { } else { aCBankAccountEntity.ACCAccountID = Int64.Parse(ddlACCAccountID.SelectedValue); } } aCBankAccountEntity.BankAccountName = txtBankAccountName.Text.Trim(); aCBankAccountEntity.BankAccountNumber = txtBankAccountNumber.Text.Trim(); if (ddlBankAccountTypeID.Items.Count > 0) { if (ddlBankAccountTypeID.SelectedValue == "0") { } else { aCBankAccountEntity.BankAccountTypeID = Int64.Parse(ddlBankAccountTypeID.SelectedValue); } } if (ddlCurrencyID.Items.Count > 0) { if (ddlCurrencyID.SelectedValue == "0") { } else { aCBankAccountEntity.CurrencyID = Int64.Parse(ddlCurrencyID.SelectedValue); } } aCBankAccountEntity.IsDefaultCurrencyAccount = chkIsDefaultCurrencyAccount.Checked; aCBankAccountEntity.BankName = txtBankName.Text.Trim(); aCBankAccountEntity.BankAddress = txtBankAddress.Text.Trim(); return(aCBankAccountEntity); }
private Int64 Delete(ACBankAccountEntity aCBankAccountEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.ACBankAccount_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("ACBankAccountEntity already exists. Please specify another ACBankAccountEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("ACBankAccountEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("ACBankAccountEntity already exists. Please specify another ACBankAccountEntity."); } } } } return(returnCode); }
protected void btnAddNew_Click(object sender, EventArgs e) { _BankAccountID = 0; _ACBankAccountEntity = new ACBankAccountEntity(); PrepareInitialView(); }
Int64 IACBankAccountFacade.Delete(ACBankAccountEntity aCBankAccountEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateACBankAccountDataAccess().Delete(aCBankAccountEntity, filterExpression, option, reqTran)); }
Int64 IACBankAccountFacade.Add(ACBankAccountEntity aCBankAccountEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateACBankAccountDataAccess().Add(aCBankAccountEntity, option, reqTran)); }