Int64 IPRMPreBOQTemplateItemMapDataAccess.Add(PRMPreBOQTemplateItemMapEntity pRMPreBOQTemplateItemMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { try { long retValues = -99; switch (reqTran) { case TransactionRequired.No: { retValues = Add(pRMPreBOQTemplateItemMapEntity, option); break; } case TransactionRequired.Yes: { retValues = AddTran(pRMPreBOQTemplateItemMapEntity, option); break; } default: { retValues = -99; break; } } return(retValues); } catch (Exception ex) { throw ex; } }
private Int64 UpdateTran(PRMPreBOQTemplateItemMapEntity pRMPreBOQTemplateItemMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.PRMPreBOQTemplateItemMap_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, "@PreBOQTemplateItemMapID", DbType.Int64, pRMPreBOQTemplateItemMapEntity.PreBOQTemplateItemMapID); db.AddInParameter(cmd, "@PreBOQTemplateID", DbType.Int64, pRMPreBOQTemplateItemMapEntity.PreBOQTemplateID); db.AddInParameter(cmd, "@ItemID", DbType.Int64, pRMPreBOQTemplateItemMapEntity.ItemID); db.AddInParameter(cmd, "@SequenceNo", DbType.Int32, pRMPreBOQTemplateItemMapEntity.SequenceNo); 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 PrepareCurrentlyPopulatedMappedItems(TreeNode parentNode) { foreach (TreeNode node in parentNode.ChildNodes) { if (node.Depth == 2) { PRMPreBOQTemplateItemMapEntity ent = new PRMPreBOQTemplateItemMapEntity(); ent.ItemID = Int64.Parse(node.Value.ToString()); ent.PreBOQTemplateID = PreBOQTemplateID; currentlyPopulatedMappedItems.Add(ent); } PrepareCurrentlyPopulatedMappedItems(node); } }
private Int64 Update(PRMPreBOQTemplateItemMapEntity pRMPreBOQTemplateItemMapEntity, String filterExpression, DatabaseOperationType option) { long returnCode = -99; const string SP = "dbo.PRMPreBOQTemplateItemMap_SET"; using (DbCommand cmd = Database.GetStoredProcCommand(SP)) { AddOptionParameter(cmd, option); AddOutputParameter(cmd); AddFilterExpressionParameter(cmd, filterExpression); Database.AddInParameter(cmd, "@PreBOQTemplateItemMapID", DbType.Int64, pRMPreBOQTemplateItemMapEntity.PreBOQTemplateItemMapID); Database.AddInParameter(cmd, "@PreBOQTemplateID", DbType.Int64, pRMPreBOQTemplateItemMapEntity.PreBOQTemplateID); Database.AddInParameter(cmd, "@ItemID", DbType.Int64, pRMPreBOQTemplateItemMapEntity.ItemID); Database.AddInParameter(cmd, "@SequenceNo", DbType.Int32, pRMPreBOQTemplateItemMapEntity.SequenceNo); using (IDataReader reader = Database.ExecuteReader(cmd)) { returnCode = GetReturnCodeFromParameter(cmd); switch (returnCode) { case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST: { throw new ArgumentException("PRMPreBOQTemplateItemMapEntity already exists. Please specify another PRMPreBOQTemplateItemMapEntity."); } case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION: { throw new ArgumentException("PRMPreBOQTemplateItemMapEntity data already updated from different session."); } case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION: { throw new ArgumentException("PRMPreBOQTemplateItemMapEntity already exists. Please specify another PRMPreBOQTemplateItemMapEntity."); } } } } return(returnCode); }
private void SavePRMPreBOQTemplateItemMapEntity() { try { foreach (TreeNode catNode in treeItem.Nodes) { PrepareCurrentlyPopulatedMappedItems(catNode); } foreach (TreeNode tn in treeItem.CheckedNodes) { PRMPreBOQTemplateItemMapEntity ent = new PRMPreBOQTemplateItemMapEntity(); ent.ItemID = Int64.Parse(tn.Value.ToString()); ent.PreBOQTemplateID = PreBOQTemplateID; newMappedItems.Add(ent); } if (currentMappedItems.Count <= 0) { IList <PRMPreBOQTemplateItemMapEntity> unCheckedList = currentlyPopulatedMappedItems.Except(newMappedItems, new CustomerComparer()).ToList(); IList <PRMPreBOQTemplateItemMapEntity> templateItemList = new List <PRMPreBOQTemplateItemMapEntity>(); foreach (var v in temporaryMappedItems) { PRMPreBOQTemplateItemMapEntity ent = new PRMPreBOQTemplateItemMapEntity(); ent.ItemID = v.ItemID; ent.PreBOQTemplateID = PreBOQTemplateID; templateItemList.Add(ent); } IList <PRMPreBOQTemplateItemMapEntity> addCheckedList = templateItemList.Except(unCheckedList, new CustomerComparerAnother()).ToList(); Int64 i = 0; StringBuilder xmlStr = new StringBuilder(); xmlStr.Append("<m>"); String subXmlStr = null; foreach (PRMPreBOQTemplateItemMapEntity ent in addCheckedList) { i++; subXmlStr = subXmlStr + "<i><a>" + ent.PreBOQTemplateID + "</a><b>" + ent.ItemID + "</b><c>" + i + "</c></i>"; } xmlStr.Append(subXmlStr.ToString()); xmlStr.Append("</m>"); FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.PreBOQItemMapTableInfo); } else if (currentMappedItems.Count > 0) { currentlyPopulatedMappedItems = currentlyPopulatedMappedItems.Intersect(currentMappedItems, new CustomerComparer()).ToList(); IList <PRMPreBOQTemplateItemMapEntity> deleteList = currentlyPopulatedMappedItems.Except(newMappedItems, new CustomerComparer()).ToList(); IList <PRMPreBOQTemplateItemMapEntity> addNewList = newMappedItems.Except(currentlyPopulatedMappedItems, new CustomerComparer()).ToList(); if (deleteList != null && deleteList.Count > 0) { foreach (PRMPreBOQTemplateItemMapEntity ent in deleteList) { String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQTemplateItemMapEntity.FLD_NAME_PreBOQTemplateID, ent.PreBOQTemplateID.ToString(), SQLMatchType.Equal); String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMPreBOQTemplateItemMapEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal); String fe = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2); FCCPRMPreBOQTemplateItemMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No); } } if (addNewList != null && addNewList.Count > 0) { foreach (PRMPreBOQTemplateItemMapEntity ent in addNewList) { FCCPRMPreBOQTemplateItemMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No); } } } MiscUtil.ShowMessage(lblMessage, "Template BOQ Item Map Updated Successfully.", false); } catch (Exception ex) { MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true); } }
Int64 IPRMPreBOQTemplateItemMapFacade.Delete(PRMPreBOQTemplateItemMapEntity pRMPreBOQTemplateItemMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreatePRMPreBOQTemplateItemMapDataAccess().Delete(pRMPreBOQTemplateItemMapEntity, filterExpression, option, reqTran)); }
Int64 IPRMPreBOQTemplateItemMapFacade.Add(PRMPreBOQTemplateItemMapEntity pRMPreBOQTemplateItemMapEntity, DatabaseOperationType option, TransactionRequired reqTran) { return(DataAccessFactory.CreatePRMPreBOQTemplateItemMapDataAccess().Add(pRMPreBOQTemplateItemMapEntity, option, reqTran)); }