Int64 IPRMBOQTemplateItemMapDataAccess.Add(PRMBOQTemplateItemMapEntity pRMBOQTemplateItemMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(pRMBOQTemplateItemMapEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(pRMBOQTemplateItemMapEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private Int64 UpdateTran(PRMBOQTemplateItemMapEntity pRMBOQTemplateItemMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMBOQTemplateItemMap_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, "@BOQTemplateItemMapID", DbType.Int64, pRMBOQTemplateItemMapEntity.BOQTemplateItemMapID);
                db.AddInParameter(cmd, "@BOQTemplateID", DbType.Int64, pRMBOQTemplateItemMapEntity.BOQTemplateID);
                db.AddInParameter(cmd, "@ItemID", DbType.Int64, pRMBOQTemplateItemMapEntity.ItemID);
                db.AddInParameter(cmd, "@SequenceNo", DbType.Int32, pRMBOQTemplateItemMapEntity.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);
        }
示例#3
0
        private void PrepareCurrentlyPopulatedMappedItems(TreeNode parentNode)
        {
            foreach (TreeNode node in parentNode.ChildNodes)
            {
                if (node.Depth == 2)
                {
                    PRMBOQTemplateItemMapEntity ent = new PRMBOQTemplateItemMapEntity();
                    ent.ItemID        = Int64.Parse(node.Value.ToString());
                    ent.BOQTemplateID = BOQTemplateID;
                    currentlyPopulatedMappedItems.Add(ent);
                }

                PrepareCurrentlyPopulatedMappedItems(node);
            }
        }
        private Int64 Update(PRMBOQTemplateItemMapEntity pRMBOQTemplateItemMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.PRMBOQTemplateItemMap_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@BOQTemplateItemMapID", DbType.Int64, pRMBOQTemplateItemMapEntity.BOQTemplateItemMapID);
                Database.AddInParameter(cmd, "@BOQTemplateID", DbType.Int64, pRMBOQTemplateItemMapEntity.BOQTemplateID);
                Database.AddInParameter(cmd, "@ItemID", DbType.Int64, pRMBOQTemplateItemMapEntity.ItemID);
                Database.AddInParameter(cmd, "@SequenceNo", DbType.Int32, pRMBOQTemplateItemMapEntity.SequenceNo);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("PRMBOQTemplateItemMapEntity already exists. Please specify another PRMBOQTemplateItemMapEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("PRMBOQTemplateItemMapEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("PRMBOQTemplateItemMapEntity already exists. Please specify another PRMBOQTemplateItemMapEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
示例#5
0
        private void SavePRMBOQTemplateItemMapEntity()
        {
            try
            {
                foreach (TreeNode catNode in treeItem.Nodes)
                {
                    PrepareCurrentlyPopulatedMappedItems(catNode);
                }

                foreach (TreeNode tn in treeItem.CheckedNodes)
                {
                    PRMBOQTemplateItemMapEntity ent = new PRMBOQTemplateItemMapEntity();
                    ent.ItemID        = Int64.Parse(tn.Value.ToString());
                    ent.BOQTemplateID = BOQTemplateID;
                    newMappedItems.Add(ent);
                }

                if (currentMappedItems.Count <= 0)
                {
                    IList <PRMBOQTemplateItemMapEntity> unCheckedList    = currentlyPopulatedMappedItems.Except(newMappedItems, new CustomerComparer()).ToList();
                    IList <PRMBOQTemplateItemMapEntity> templateItemList = new List <PRMBOQTemplateItemMapEntity>();
                    foreach (var v in temporaryMappedItems)
                    {
                        PRMBOQTemplateItemMapEntity ent = new PRMBOQTemplateItemMapEntity();
                        ent.ItemID        = v.ItemID;
                        ent.BOQTemplateID = BOQTemplateID;
                        templateItemList.Add(ent);
                    }
                    IList <PRMBOQTemplateItemMapEntity> addCheckedList = templateItemList.Except(unCheckedList, new CustomerComparerAnother()).ToList();
                    Int64 i = 0;

                    StringBuilder xmlStr = new StringBuilder();
                    xmlStr.Append("<m>");
                    String subXmlStr = null;

                    foreach (PRMBOQTemplateItemMapEntity ent in addCheckedList)
                    {
                        i++;
                        subXmlStr = subXmlStr + "<i><a>" + ent.BOQTemplateID + "</a><b>" + ent.ItemID + "</b><c>" + i + "</c></i>";
                    }
                    xmlStr.Append(subXmlStr.ToString());
                    xmlStr.Append("</m>");
                    FCCBulkInsertXML.GetFacadeCreate().GetIL(xmlStr.ToString(), CommonConstants.BOQItemMapTableInfo);
                }

                else if (currentMappedItems.Count > 0)
                {
                    currentlyPopulatedMappedItems = currentlyPopulatedMappedItems.Intersect(currentMappedItems, new CustomerComparer()).ToList();

                    IList <PRMBOQTemplateItemMapEntity> deleteList = currentlyPopulatedMappedItems.Except(newMappedItems, new CustomerComparer()).ToList();
                    IList <PRMBOQTemplateItemMapEntity> addNewList = newMappedItems.Except(currentlyPopulatedMappedItems, new CustomerComparer()).ToList();

                    if (deleteList != null && deleteList.Count > 0)
                    {
                        foreach (PRMBOQTemplateItemMapEntity ent in deleteList)
                        {
                            String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQTemplateItemMapEntity.FLD_NAME_BOQTemplateID, ent.BOQTemplateID.ToString(), SQLMatchType.Equal);
                            String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMBOQTemplateItemMapEntity.FLD_NAME_ItemID, ent.ItemID.ToString(), SQLMatchType.Equal);
                            String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);

                            FCCPRMBOQTemplateItemMap.GetFacadeCreate().Delete(ent, fe, DatabaseOperationType.Delete, TransactionRequired.No);
                        }
                    }

                    if (addNewList != null && addNewList.Count > 0)
                    {
                        foreach (PRMBOQTemplateItemMapEntity ent in addNewList)
                        {
                            FCCPRMBOQTemplateItemMap.GetFacadeCreate().Add(ent, DatabaseOperationType.Add, TransactionRequired.No);
                        }
                    }
                }

                MiscUtil.ShowMessage(lblMessage, "Template Project Cost Item Map Updated Successfully.", false);
            }
            catch (Exception ex)
            {
                MiscUtil.ShowMessage(lblMessage, "An Error Occoured.", true);
            }
        }
 Int64 IPRMBOQTemplateItemMapFacade.Delete(PRMBOQTemplateItemMapEntity pRMBOQTemplateItemMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMBOQTemplateItemMapDataAccess().Delete(pRMBOQTemplateItemMapEntity, filterExpression, option, reqTran));
 }
 Int64 IPRMBOQTemplateItemMapFacade.Add(PRMBOQTemplateItemMapEntity pRMBOQTemplateItemMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreatePRMBOQTemplateItemMapDataAccess().Add(pRMBOQTemplateItemMapEntity, option, reqTran));
 }