Int64 IBDTaskTemplateItemMapDataAccess.Add(BDTaskTemplateItemMapEntity bDTaskTemplateItemMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(bDTaskTemplateItemMapEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(bDTaskTemplateItemMapEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(BDTaskTemplateItemMapEntity bDTaskTemplateItemMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDTaskTemplateItemMap_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, "@TaskTemplateItemMap", DbType.Int64, bDTaskTemplateItemMapEntity.TaskTemplateItemMap); db.AddInParameter(cmd, "@TaskTemplateID", DbType.Int64, bDTaskTemplateItemMapEntity.TaskTemplateID); db.AddInParameter(cmd, "@TaskID", DbType.Int64, bDTaskTemplateItemMapEntity.TaskID); 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 SaveBDTaskTemplateItemMapEntity() { try { newMappedNodes = treeDocument.CheckedNodes; foreach (TreeNode tn in treeDocument.CheckedNodes) { BayTreeNodeValue bayTreeNodeValue = new BayTreeNodeValue(); bayTreeNodeValue.SetValuesFromString(tn.Value); BDTaskTemplateItemMapEntity ent = new BDTaskTemplateItemMapEntity(); ent.TaskID = Int64.Parse(bayTreeNodeValue.Value); ent.TaskTemplateID = OverviewTaskTemplateID; newMappedDocuments.Add(ent); } IList <BDTaskTemplateItemMapEntity> deleteList = currentMappedDocuments.Except(newMappedDocuments, new CustomerComparer()).ToList(); IList <BDTaskTemplateItemMapEntity> addNewList = newMappedDocuments.Except(currentMappedDocuments, new CustomerComparer()).ToList(); if (deleteList != null && deleteList.Count > 0) { foreach (BDTaskTemplateItemMapEntity ent in deleteList) { String fe1 = SqlExpressionBuilder.PrepareFilterExpression(BDTaskTemplateItemMapEntity.FLD_NAME_TaskTemplateID, ent.TaskTemplateID.ToString(), SQLMatchType.Equal); String fe2 = SqlExpressionBuilder.PrepareFilterExpression(BDTaskTemplateItemMapEntity.FLD_NAME_TaskID, ent.TaskID.ToString(), SQLMatchType.Equal); String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); FCCBDTaskTemplateItemMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No); } } if (addNewList != null && addNewList.Count > 0) { foreach (BDTaskTemplateItemMapEntity ent in addNewList) { FCCBDTaskTemplateItemMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No); } } MiscUtil.ShowMessage(lblMessage, "Template Task Map Updated Successfully.", false); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true); } }
private Int64 Update(BDTaskTemplateItemMapEntity bDTaskTemplateItemMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.BDTaskTemplateItemMap_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@TaskTemplateItemMap", DbType.Int64, bDTaskTemplateItemMapEntity.TaskTemplateItemMap); Database.AddInParameter(cmd, "@TaskTemplateID", DbType.Int64, bDTaskTemplateItemMapEntity.TaskTemplateID); Database.AddInParameter(cmd, "@TaskID", DbType.Int64, bDTaskTemplateItemMapEntity.TaskID); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("BDTaskTemplateItemMapEntity already exists. Please specify another BDTaskTemplateItemMapEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("BDTaskTemplateItemMapEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("BDTaskTemplateItemMapEntity already exists. Please specify another BDTaskTemplateItemMapEntity."); } } } } return(returnCode); }
Int64 IBDTaskTemplateItemMapFacade.Delete(BDTaskTemplateItemMapEntity bDTaskTemplateItemMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDTaskTemplateItemMapDataAccess().Delete(bDTaskTemplateItemMapEntity, filterExpression, option, reqTran)); }
Int64 IBDTaskTemplateItemMapFacade.Add(BDTaskTemplateItemMapEntity bDTaskTemplateItemMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreateBDTaskTemplateItemMapDataAccess().Add(bDTaskTemplateItemMapEntity, option, reqTran)); }