Int64 IAPPanelItemCategoryMapDataAccess.Add(APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(aPPanelItemCategoryMapEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(aPPanelItemCategoryMapEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private APPanelItemCategoryMapEntity BuildAPPanelItemCategoryMapEntity() { APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity = CurrentAPPanelItemCategoryMapEntity; if (ddlAPPanelID.Items.Count > 0) { if (ddlAPPanelID.SelectedValue == "0") { } else { aPPanelItemCategoryMapEntity.APPanelID = Int64.Parse(ddlAPPanelID.SelectedValue); } } if (ddlItemCategoryID.Items.Count > 0) { if (ddlItemCategoryID.SelectedValue == "0") { } else { aPPanelItemCategoryMapEntity.ItemCategoryID = Int64.Parse(ddlItemCategoryID.SelectedValue); } } return(aPPanelItemCategoryMapEntity); }
private void SaveAPPanelItemCategoryMapEntity() { if (IsValid) { try { APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity = BuildAPPanelItemCategoryMapEntity(); Int64 result = -1; if (aPPanelItemCategoryMapEntity.IsNew) { result = FCCAPPanelItemCategoryMap.GetFacadeCreate().Add(aPPanelItemCategoryMapEntity, DatabaseOperationType.Add, TransactionRequired.No); } else { String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(APPanelItemCategoryMapEntity.FLD_NAME_APPanelItemCategoryMapID, aPPanelItemCategoryMapEntity.APPanelItemCategoryMapID.ToString(), SQLMatchType.Equal); result = FCCAPPanelItemCategoryMap.GetFacadeCreate().Update(aPPanelItemCategoryMapEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No); } if (result > 0) { _APPanelItemCategoryMapID = 0; _APPanelItemCategoryMapEntity = new APPanelItemCategoryMapEntity(); PrepareInitialView(); BindAPPanelItemCategoryMapList(); if (aPPanelItemCategoryMapEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "A PPanel Item Category Map Information has been added successfully.", false); } else { MiscUtil.ShowMessage(lblMessage, "A PPanel Item Category Map Information has been updated successfully.", false); } } else { if (aPPanelItemCategoryMapEntity.IsNew) { MiscUtil.ShowMessage(lblMessage, "Failed to add A PPanel Item Category Map Information.", false); } else { MiscUtil.ShowMessage(lblMessage, "Failed to update A PPanel Item Category Map Information.", false); } } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } }
private Int64 UpdateTran(APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.APPanelItemCategoryMap_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, "@APPanelItemCategoryMapID", DbType.Int64, aPPanelItemCategoryMapEntity.APPanelItemCategoryMapID); db.AddInParameter(cmd, "@APPanelID", DbType.Int64, aPPanelItemCategoryMapEntity.APPanelID); db.AddInParameter(cmd, "@ItemCategoryID", DbType.Int64, aPPanelItemCategoryMapEntity.ItemCategoryID); 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 lvAPPanelItemCategoryMap_ItemCommand(object sender, ListViewCommandEventArgs e) { Int64 APPanelItemCategoryMapID; Int64.TryParse(e.CommandArgument.ToString(), out APPanelItemCategoryMapID); if (APPanelItemCategoryMapID > 0) { if (string.Equals(e.CommandName, "EditItem")) { _APPanelItemCategoryMapID = APPanelItemCategoryMapID; PrepareEditView(); cpeEditor.Collapsed = false; cpeEditor.ClientState = "false"; } else if (string.Equals(e.CommandName, "DeleteItem")) { try { Int64 result = -1; String fe = SqlExpressionBuilder.PrepareFilterExpression(APPanelItemCategoryMapEntity.FLD_NAME_APPanelItemCategoryMapID, APPanelItemCategoryMapID.ToString(), SQLMatchType.Equal); APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity = new APPanelItemCategoryMapEntity(); result = FCCAPPanelItemCategoryMap.GetFacadeCreate().Delete(aPPanelItemCategoryMapEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No); if (result == 0) { _APPanelItemCategoryMapID = 0; _APPanelItemCategoryMapEntity = new APPanelItemCategoryMapEntity(); PrepareInitialView(); BindAPPanelItemCategoryMapList(); MiscUtil.ShowMessage(lblMessage, "A PPanel Item Category Map has been successfully deleted.", true); } else { MiscUtil.ShowMessage(lblMessage, "Failed to delete A PPanel Item Category Map.", true); } } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, ex.Message, true); } } } }
private Int64 Update(APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.APPanelItemCategoryMap_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@APPanelItemCategoryMapID", DbType.Int64, aPPanelItemCategoryMapEntity.APPanelItemCategoryMapID); Database.AddInParameter(cmd, "@APPanelID", DbType.Int64, aPPanelItemCategoryMapEntity.APPanelID); Database.AddInParameter(cmd, "@ItemCategoryID", DbType.Int64, aPPanelItemCategoryMapEntity.ItemCategoryID); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("APPanelItemCategoryMapEntity already exists. Please specify another APPanelItemCategoryMapEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("APPanelItemCategoryMapEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("APPanelItemCategoryMapEntity already exists. Please specify another APPanelItemCategoryMapEntity."); } } } } return(returnCode); }
private void PrepareEditView() { APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity = CurrentAPPanelItemCategoryMapEntity; if (!aPPanelItemCategoryMapEntity.IsNew) { if (ddlAPPanelID.Items.Count > 0 && aPPanelItemCategoryMapEntity.APPanelID != null) { ddlAPPanelID.SelectedValue = aPPanelItemCategoryMapEntity.APPanelID.ToString(); } if (ddlItemCategoryID.Items.Count > 0 && aPPanelItemCategoryMapEntity.ItemCategoryID != null) { ddlItemCategoryID.SelectedValue = aPPanelItemCategoryMapEntity.ItemCategoryID.ToString(); } btnSubmit.Text = "Update"; btnAddNew.Visible = true; } }
protected void btnAddNew_Click(object sender, EventArgs e) { _APPanelItemCategoryMapID = 0; _APPanelItemCategoryMapEntity = new APPanelItemCategoryMapEntity(); PrepareInitialView(); }
Int64 IAPPanelItemCategoryMapFacade.Delete(APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateAPPanelItemCategoryMapDataAccess().Delete(aPPanelItemCategoryMapEntity, filterExpression, option, reqTran)); }
Int64 IAPPanelItemCategoryMapFacade.Add(APPanelItemCategoryMapEntity aPPanelItemCategoryMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateAPPanelItemCategoryMapDataAccess().Add(aPPanelItemCategoryMapEntity, option, reqTran)); }