public static string PrepareCause(CauseObject_MCE_B_ASSETS_CONTRACT_D cause, out OracleParameter[] parameters)
        {
            //平台自动生成代码
            System.Text.StringBuilder strBuf = new System.Text.StringBuilder();
            ArrayList       paramList        = new ArrayList();
            OracleParameter param            = null;

            #region Push Block
            if (!string.IsNullOrEmpty(cause.ASSET_ID))
            {
                strBuf.Append(" And MCE_B_ASSETS_CONTRACT_D.ASSET_ID ").Append((cause.ASSET_ID.StartsWith("%") || cause.ASSET_ID.EndsWith("%")) ? " like " : " = ").Append(" :C_ASSET_ID");
                param = new OracleParameter();
                param.ParameterName = ":C_ASSET_ID";
                param.OracleType    = System.Data.OracleClient.OracleType.Char;
                param.Size          = 36;
                param.Value         = cause.ASSET_ID;
                paramList.Add(param);
            }
            if (cause.HasINValue("ASSET_ID"))
            {
                strBuf.Append(cause.GetINSQL("MCE_B_ASSETS_CONTRACT_D", "ASSET_ID"));
            }
            if (!string.IsNullOrEmpty(cause.BASE_ID))
            {
                strBuf.Append(" And MCE_B_ASSETS_CONTRACT_D.BASE_ID ").Append((cause.BASE_ID.StartsWith("%") || cause.BASE_ID.EndsWith("%")) ? " like " : " = ").Append(" :C_BASE_ID");
                param = new OracleParameter();
                param.ParameterName = ":C_BASE_ID";
                param.OracleType    = System.Data.OracleClient.OracleType.Char;
                param.Size          = 36;
                param.Value         = cause.BASE_ID;
                paramList.Add(param);
            }
            if (cause.HasINValue("BASE_ID"))
            {
                strBuf.Append(cause.GetINSQL("MCE_B_ASSETS_CONTRACT_D", "BASE_ID"));
            }
            if (!string.IsNullOrEmpty(cause.ID))
            {
                strBuf.Append(" And MCE_B_ASSETS_CONTRACT_D.ID ").Append((cause.ID.StartsWith("%") || cause.ID.EndsWith("%")) ? " like " : " = ").Append(" :C_ID");
                param = new OracleParameter();
                param.ParameterName = ":C_ID";
                param.OracleType    = System.Data.OracleClient.OracleType.Char;
                param.Size          = 36;
                param.Value         = cause.ID;
                paramList.Add(param);
            }
            if (cause.HasINValue("ID"))
            {
                strBuf.Append(cause.GetINSQL("MCE_B_ASSETS_CONTRACT_D", "ID"));
            }
            if (!string.IsNullOrEmpty(cause.GetCustomCondition()))
            {
                strBuf.Append(cause.GetCustomCondition());
            }
            #endregion
            parameters = new OracleParameter[paramList.Count];
            paramList.CopyTo(parameters);
            return(strBuf.ToString());
        }
 public static int Delete(CauseObject_MCE_B_ASSETS_CONTRACT_D cause, IDbTransaction trans)
 {
     //平台自动生成代码
     #region Parameters Block
     OracleParameter[] parameters = null;
     #endregion
     string sSql = "delete from MCE_B_ASSETS_CONTRACT_D where (1=1)";
     sSql += PrepareCause(cause, out parameters);
     return(IDALProvider.IDAL.ExecuteNonQuery(sSql, parameters, trans));
 }
 public int DeleteByTrans2(CauseObject_MCE_B_ASSETS_CONTRACT_D cause, IDbTransaction transaction)
 {
     if (LocalMode)
     {
         return(HelperObject_MCE_B_ASSETS_CONTRACT_D.Delete(cause, transaction));
         //平台自动生成代码
     }
     else
     {
         throw new InvalidConstraintException();
     }
 }
 public static DisplayObject_MCE_B_ASSETS_CONTRACT_D[] Query(CauseObject_MCE_B_ASSETS_CONTRACT_D cause)
 {
     //平台自动生成代码
     #region Parameters Block
     OracleParameter[] parameters = null;
     #endregion
     string sSql = " select  MCE_B_ASSETS_CONTRACT_D.ASSET_ID, MCE_B_ASSETS_CONTRACT_D.BASE_ID, MCE_B_ASSETS_CONTRACT_D.ID, MCE_B_ASSETS_ASSET_ID.ASSETS_NAME as ASSET_ID_NAME, MCE_B_ASSETS_CONTRACT_BASE_ID.NAME as BASE_ID_NAME from MCE_B_ASSETS_CONTRACT_D left join MCE_B_ASSETS   MCE_B_ASSETS_ASSET_ID on MCE_B_ASSETS_CONTRACT_D.ASSET_ID = MCE_B_ASSETS_ASSET_ID.ID left join MCE_B_ASSETS_CONTRACT   MCE_B_ASSETS_CONTRACT_BASE_ID on MCE_B_ASSETS_CONTRACT_D.BASE_ID = MCE_B_ASSETS_CONTRACT_BASE_ID.ID where (1=1)";
     sSql += PrepareCause(cause, out parameters);
     if (cause.Recursion != null && !string.IsNullOrEmpty(cause.Recursion.RecursionFieldValue))
     {
         sSql = "select t.* from (" + sSql + ") t,( select t." + cause.Recursion.TargetKeyFieldName + " from " + cause.Recursion.TargetDataObjectName + " t start with t." + cause.Recursion.TargetKeyFieldName + " = '" + cause.Recursion.RecursionFieldValue + "' connect by  t." + cause.Recursion.TargetLevelFieldName + "  = PRIOR t." + cause.Recursion.TargetKeyFieldName + "  ) t1 where t." + cause.Recursion.RecursionFieldName + " = t1." + cause.Recursion.TargetKeyFieldName;
     }
     #region Push Block
     DisplayObject_MCE_B_ASSETS_CONTRACT_D dataObj = null;
     ArrayList     objArray   = new ArrayList();
     IDbConnection connection = IDALProvider.IDAL.PopConnection();
     IDataReader   sqlReader  = IDALProvider.IDAL.ExecuteReader(sSql, parameters, connection);
     while (sqlReader.Read())
     {
         dataObj = new DisplayObject_MCE_B_ASSETS_CONTRACT_D();
         if (!sqlReader.IsDBNull(0))
         {
             dataObj.ASSET_ID = sqlReader.GetString(0);
         }
         if (!sqlReader.IsDBNull(1))
         {
             dataObj.BASE_ID = sqlReader.GetString(1);
         }
         if (!sqlReader.IsDBNull(2))
         {
             dataObj.ID = sqlReader.GetString(2);
         }
         if (!sqlReader.IsDBNull(3))
         {
             dataObj.ASSET_ID_NAME = sqlReader.GetString(3);
         }
         if (!sqlReader.IsDBNull(4))
         {
             dataObj.BASE_ID_NAME = sqlReader.GetString(4);
         }
         objArray.Add(dataObj);
     }
     sqlReader.Close();
     IDALProvider.IDAL.PushConnection(connection);
     #endregion
     DisplayObject_MCE_B_ASSETS_CONTRACT_D[] objs = new DisplayObject_MCE_B_ASSETS_CONTRACT_D[objArray.Count];
     objArray.CopyTo(0, objs, 0, objs.Length);
     return(objs);
 }
 public static int Update(EntityObject_MCE_B_ASSETS_CONTRACT_D obj, CauseObject_MCE_B_ASSETS_CONTRACT_D cause, IDbTransaction trans)
 {
     //平台自动生成代码
     #region Parameters Block
     List <OracleParameter> list       = new List <OracleParameter>();
     OracleParameter[]      parameters = null;
     #endregion
     string sSql = "update MCE_B_ASSETS_CONTRACT_D set ";
     sSql += PrepareUpdate(obj, out parameters, false);
     list.AddRange(parameters);
     sSql += " where 1=1 ";
     sSql += PrepareCause(cause, out parameters);
     list.AddRange(parameters);
     parameters = list.ToArray();
     return(IDALProvider.IDAL.ExecuteNonQuery(sSql, parameters, trans));
 }
        public DisplayObject_MCE_B_ASSETS_CONTRACT_D[] Query(CauseObject_MCE_B_ASSETS_CONTRACT_D cause, PagingParamter paging, OrderByParameter order)
        {
            if (LocalMode)
            {
                SystemLogic.Proxy.AuditQuery(cause);

                //平台自动生成代码
                return(HelperObject_MCE_B_ASSETS_CONTRACT_D.Query(cause, paging, order));
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_B_ASSETS_CONTRACT_D> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_CONTRACT_D>(ServiceUri))
                {
                    return(smgr.Service.Query(cause, paging, order));
                }
            }
        }
 public BizLogicMsg Delete(CauseObject_MCE_B_ASSETS_CONTRACT_D cause)
 {
     if (LocalMode)
     {
         BizLogicMsg msg = new BizLogicMsg();
         using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
         {
             using (IDbTransaction transaction = connection.BeginTransaction())
             {
                 try
                 {
                     int amount = HelperObject_MCE_B_ASSETS_CONTRACT_D.Delete(cause, transaction);
                     //平台自动生成代码
                     transaction.Commit();
                 }
                 catch (Exception expt)
                 {
                     transaction.Rollback();
                     msg = new BizLogicMsg(false, expt.Message);
                     Error(expt);
                 }
                 finally
                 {
                     IDALProvider.IDAL.PushConnection(connection);
                 }
             }
         }
         return(msg);
     }
     else
     {
         using (ServiceManager <ServiceContract_MCE_B_ASSETS_CONTRACT_D> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_CONTRACT_D>(ServiceUri))
         {
             return(smgr.Service.Delete(cause));
         }
     }
 }
 public static DisplayObject_MCE_B_ASSETS_CONTRACT_D[] Query(CauseObject_MCE_B_ASSETS_CONTRACT_D cause, PagingParamter paging, OrderByParameter order, IDbTransaction trans)
 {
     //平台自动生成代码
     #region Parameters Block
     OracleParameter[] parameters = null;
     IDataReader       sqlReader  = null;
     #endregion
     string sSql      = " select  MCE_B_ASSETS_CONTRACT_D.ASSET_ID, MCE_B_ASSETS_CONTRACT_D.BASE_ID, MCE_B_ASSETS_CONTRACT_D.ID, MCE_B_ASSETS_ASSET_ID.ASSETS_NAME as ASSET_ID_NAME, MCE_B_ASSETS_CONTRACT_BASE_ID.NAME as BASE_ID_NAME from MCE_B_ASSETS_CONTRACT_D left join MCE_B_ASSETS   MCE_B_ASSETS_ASSET_ID on MCE_B_ASSETS_CONTRACT_D.ASSET_ID = MCE_B_ASSETS_ASSET_ID.ID left join MCE_B_ASSETS_CONTRACT   MCE_B_ASSETS_CONTRACT_BASE_ID on MCE_B_ASSETS_CONTRACT_D.BASE_ID = MCE_B_ASSETS_CONTRACT_BASE_ID.ID where (1=1)";
     string sCauseSql = PrepareCause(cause, out parameters);
     sSql += sCauseSql;
     if (cause.Recursion != null && !string.IsNullOrEmpty(cause.Recursion.RecursionFieldValue))
     {
         sSql = "select t.* from (" + sSql + ") t,( select t." + cause.Recursion.TargetKeyFieldName + " from " + cause.Recursion.TargetDataObjectName + " t start with t." + cause.Recursion.TargetKeyFieldName + " = '" + cause.Recursion.RecursionFieldValue + "' connect by  t." + cause.Recursion.TargetLevelFieldName + "  = PRIOR t." + cause.Recursion.TargetKeyFieldName + "  ) t1 where t." + cause.Recursion.RecursionFieldName + " = t1." + cause.Recursion.TargetKeyFieldName;
     }
     #region Push Block
     if (paging != null)
     {
         string countSql = string.Empty;
         if (cause.Recursion != null && !string.IsNullOrEmpty(cause.Recursion.RecursionFieldValue))
         {
             countSql = "Select Count(*) From (" + sSql + ") t";
         }
         else
         {
             countSql = "Select Count(*) From (" + sSql + ") t";
         }
         if (paging.TotalRecords == 0)
         {
             paging.TotalRecords = IDALProvider.IDAL.DatabaseType == Ipedf.Common.DatabaseType.SqlServer || IDALProvider.IDAL.DatabaseType == Ipedf.Common.DatabaseType.Db2? (int)IDALProvider.IDAL.ExecuteScalar(countSql, parameters, trans) : (int)(decimal)IDALProvider.IDAL.ExecuteScalar(countSql, parameters, trans);
         }
         sqlReader = IDALProvider.IDAL.ExecutePagingReader("MCE_B_ASSETS_CONTRACT_D", paging, order, sSql, parameters, trans);
     }
     else if (order != null)
     {
         sSql     += order.ToString();
         sqlReader = IDALProvider.IDAL.ExecuteReader(sSql, parameters, trans);
     }
     else
     {
         sqlReader = IDALProvider.IDAL.ExecuteReader(sSql, parameters, trans);
     }
     DisplayObject_MCE_B_ASSETS_CONTRACT_D dataObj = null;
     ArrayList objArray = new ArrayList();
     while (sqlReader.Read())
     {
         dataObj = new DisplayObject_MCE_B_ASSETS_CONTRACT_D();
         if (!sqlReader.IsDBNull(0))
         {
             dataObj.ASSET_ID = sqlReader.GetString(0);
         }
         if (!sqlReader.IsDBNull(1))
         {
             dataObj.BASE_ID = sqlReader.GetString(1);
         }
         if (!sqlReader.IsDBNull(2))
         {
             dataObj.ID = sqlReader.GetString(2);
         }
         if (!sqlReader.IsDBNull(3))
         {
             dataObj.ASSET_ID_NAME = sqlReader.GetString(3);
         }
         if (!sqlReader.IsDBNull(4))
         {
             dataObj.BASE_ID_NAME = sqlReader.GetString(4);
         }
         objArray.Add(dataObj);
     }
     sqlReader.Close();
     #endregion
     DisplayObject_MCE_B_ASSETS_CONTRACT_D[] objs = new DisplayObject_MCE_B_ASSETS_CONTRACT_D[objArray.Count];
     objArray.CopyTo(0, objs, 0, objs.Length);
     return(objs);
 }
Exemple #9
0
        public BizLogicMsg Save_Ext2(JsonMCE_Contract json)
        {
            if (LocalMode)
            {
                BizLogicMsg msg = new BizLogicMsg();
                using (IDbConnection connection = IDALProvider.IDAL.PopConnection())
                {
                    using (IDbTransaction transaction = connection.BeginTransaction())
                    {
                        try
                        {
                            EntityObject_MCE_B_ASSETS_CONTRACT entity = new EntityObject_MCE_B_ASSETS_CONTRACT();


                            if (!string.IsNullOrEmpty(json.ID))
                            {
                                entity.ID = json.ID;

                                entity = HelperObject_MCE_B_ASSETS_CONTRACT.Get(entity);

                                if (entity == null)
                                {
                                    throw new Exception("获取数据出错.");
                                }
                            }

                            entity.CODE = json.CODE;
                            entity.NAME = json.NAME;

                            if (!string.IsNullOrEmpty(json.SIGN_DATE))
                            {
                                entity.SIGN_DATE = DateTime.Parse(json.SIGN_DATE);
                            }
                            if (!string.IsNullOrEmpty(json.EXPIRE_DATE))
                            {
                                entity.EXPIRE_DATE = DateTime.Parse(json.EXPIRE_DATE);
                            }
                            entity.TYPE_ID     = json.TYPE_ID;
                            entity.FIRST_PARTY = json.FIRST_PARTY;

                            entity.SECOND_PARTY       = json.SECOND_PARTY;
                            entity.SECOND_LINK_PERSON = json.SECOND_LINK_PERSON;
                            entity.SECOND_LINK_PHONE  = json.SECOND_LINK_PHONE;

                            if (!string.IsNullOrEmpty(json.MONEY))
                            {
                                entity.MONEY = decimal.Parse(json.MONEY);
                            }

                            entity.ARCHIVE_NO = json.ARCHIVE_NO;

                            if (!string.IsNullOrEmpty(json.CHECK_DATE))
                            {
                                entity.CHECK_DATE = DateTime.Parse(json.CHECK_DATE);
                            }
                            entity.ARCHIVIST        = json.ARCHIVIST;
                            entity.INPUT_PERSON     = json.INPUT_PERSON;
                            entity.CONTRACT_CONTENT = json.CONTRACT_CONTENT;


                            entity.STATE = 1;

                            if (string.IsNullOrEmpty(json.ID))
                            {
                                entity.CONTRACT_STATE = 1;
                                entity.CREATE_TIME    = DateTime.Now;
                                entity.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                int amount = HelperObject_MCE_B_ASSETS_CONTRACT.Save(entity, transaction);
                            }
                            else
                            {
                                entity.MODIFY_TIME    = DateTime.Now;
                                entity.MODIFY_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                int amount = HelperObject_MCE_B_ASSETS_CONTRACT.Update(entity, transaction);


                                CauseObject_MCE_B_ASSETS_CONTRACT_D pCONTRACT_D = new CauseObject_MCE_B_ASSETS_CONTRACT_D();
                                pCONTRACT_D.BASE_ID = json.ID;
                                HelperObject_MCE_B_ASSETS_CONTRACT_D.Delete(pCONTRACT_D, transaction);


                                CauseObject_COM_FILE pCOM_FILE = new CauseObject_COM_FILE();
                                pCOM_FILE.REF_TAB_ID   = entity.ID;
                                pCOM_FILE.REF_TAB_NAME = "MCE_B_ASSETS_CONTRACT";
                                HelperObject_COM_FILE.Delete(pCOM_FILE, transaction);


                                DisplayObject_MCE_B_ASSETS_CONTRACT_PAY[] list_Pay = BizLogicObject_MCE_B_ASSETS_CONTRACT_PAY.Proxy.Query(new CauseObject_MCE_B_ASSETS_CONTRACT_PAY()
                                {
                                    BASE_ID = entity.ID
                                });
                                if (list_Pay != null && list_Pay.Length > 0)
                                {
                                    foreach (DisplayObject_MCE_B_ASSETS_CONTRACT_PAY item_Pay in list_Pay)
                                    {
                                        var v_Pay = json.listPay.Find(l => l.ID == item_Pay.ID);
                                        if (v_Pay == null)
                                        {
                                            HelperObject_MCE_B_ASSETS_CONTRACT_PAY.Delete(item_Pay, transaction);
                                        }
                                    }
                                }
                            }


                            if (json.children != null && json.children.Count > 0)
                            {
                                foreach (JsonMCE_Contract_D item in json.children)
                                {
                                    EntityObject_MCE_B_ASSETS_CONTRACT_D entity_D = new EntityObject_MCE_B_ASSETS_CONTRACT_D();

                                    entity_D.BASE_ID  = entity.ID;
                                    entity_D.ASSET_ID = item.ASSET_ID;

                                    HelperObject_MCE_B_ASSETS_CONTRACT_D.Save(entity_D, transaction);
                                }
                            }


                            if (json.listPay != null && json.listPay.Count > 0)
                            {
                                foreach (JsonMCE_Contract_Pay item in json.listPay)
                                {
                                    EntityObject_MCE_B_ASSETS_CONTRACT_PAY entity_D = new EntityObject_MCE_B_ASSETS_CONTRACT_PAY();

                                    if (!string.IsNullOrEmpty(item.ID))
                                    {
                                        entity_D.ID = item.ID;

                                        entity_D = HelperObject_MCE_B_ASSETS_CONTRACT_PAY.Get(entity_D);

                                        if (entity_D == null)
                                        {
                                            throw new Exception("获取数据出错.");
                                        }
                                    }

                                    entity_D.BASE_ID = entity.ID;
                                    entity_D.PERIODS = item.PERIODS;
                                    if (!string.IsNullOrEmpty(item.MONEY))
                                    {
                                        entity_D.MONEY = decimal.Parse(item.MONEY);
                                    }
                                    if (!string.IsNullOrEmpty(item.PLAN_PAY_DATE))
                                    {
                                        entity_D.PLAN_PAY_DATE = DateTime.Parse(item.PLAN_PAY_DATE);
                                    }

                                    if (string.IsNullOrEmpty(item.ID))
                                    {
                                        entity_D.STATE = 2;
                                        HelperObject_MCE_B_ASSETS_CONTRACT_PAY.Save(entity_D, transaction);
                                    }
                                    else
                                    {
                                        HelperObject_MCE_B_ASSETS_CONTRACT_PAY.Update(entity_D, transaction);
                                    }
                                }
                            }


                            if (json.listAttach != null && json.listAttach.Count > 0)
                            {
                                foreach (JsonMCEMT_APPLY_MTN_ATTACH item in json.listAttach)
                                {
                                    Ipedf.Web.Entity.EntityObject_COM_FILE entityPicFile = new Ipedf.Web.Entity.EntityObject_COM_FILE();
                                    entityPicFile.REF_TAB_NAME   = "MCE_B_ASSETS_CONTRACT";
                                    entityPicFile.CLIENT_NAME    = item.CLIENT_NAME;
                                    entityPicFile.STATE          = 1;
                                    entityPicFile.CREATE_TIME    = item.CREATE_TIME;
                                    entityPicFile.CREATE_USER_ID = Ipedf.Web.BizLogic.SystemLogic.Proxy.CurrentUser.ID;
                                    entityPicFile.REF_TAB_ID     = entity.ID;
                                    entityPicFile.SERVER_NAME    = item.SERVER_NAME;
                                    entityPicFile.IS_IMPORT      = 0;
                                    Ipedf.Web.DataAccess.HelperObject_COM_FILE.Save(entityPicFile, transaction);
                                }
                            }

                            msg.Message = entity.ID;

                            transaction.Commit();
                        }
                        catch (Exception expt)
                        {
                            transaction.Rollback();
                            msg = new BizLogicMsg(false, expt.Message);
                            Error(expt);
                        }
                        finally
                        {
                            IDALProvider.IDAL.PushConnection(connection);
                        }
                    }
                }
                return(msg);
            }
            else
            {
                using (ServiceManager <ServiceContract_MCE_B_ASSETS_CONTRACT> smgr = new ServiceManager <ServiceContract_MCE_B_ASSETS_CONTRACT>(ServiceUri))
                {
                    return(smgr.Service.Save_Ext2(json));
                }
            }
        }