//=========================================================================
        //  FunctionName : AutoGenerateKCBH
        /// <summary>
        /// 自动生成KCBH编号方法
        /// </summary>
        /// <returns>返回KCBH新编号</returns>
        //=========================================================================
        public string AutoGenerateKCBH(T_BM_KCXXApplicationData appData)
        {
            int    intNumberLength = 8;
            string strPrefix       = ("KC").ToString();

            strPrefix = strPrefix.ToLower() == "null" ? "" : strPrefix;
            T_BM_KCXXBusinessEntity instanceT_BM_KCXXBusinessEntity = (T_BM_KCXXBusinessEntity)CreateBusinessEntityInstance(typeof(T_BM_KCXXBusinessEntity));
            string        strMaxValue;
            StringBuilder sbNewID = new StringBuilder(string.Empty);

            sbNewID.Append(strPrefix);

            strMaxValue = instanceT_BM_KCXXBusinessEntity.GetMaxValue(strPrefix, intNumberLength).ToString();
            if (strMaxValue != String.Empty)
            {
                if (strMaxValue.Length == strPrefix.Length + intNumberLength)
                {
                    int intMaxValue = Convert.ToInt32(strMaxValue.Substring(strPrefix.Length, intNumberLength)) + 1;
                    sbNewID.Append(FillZeroToString(intMaxValue.ToString(), intNumberLength));
                }
                else
                {
                    sbNewID.Append(FillZeroToString("1", intNumberLength));
                }
            }
            else
            {
                sbNewID.Append(FillZeroToString("1", intNumberLength));
            }

            return(sbNewID.ToString());
        }
        //=========================================================================
        //  FunctionName : Query
        /// <summary>
        /// 检索方法
        /// </summary>
        /// <param name="appData">应用数据实体</param>
        /// <returns>返回数据实体对象</returns>
        //=========================================================================
        public T_BM_KCXXApplicationData Query(T_BM_KCXXApplicationData appData)
        {
            T_BM_KCXXBusinessEntity instanceT_BM_KCXXBusinessEntity = (T_BM_KCXXBusinessEntity)CreateBusinessEntityInstance(typeof(T_BM_KCXXBusinessEntity));

            instanceT_BM_KCXXBusinessEntity.AppData = appData;
            if (instanceT_BM_KCXXBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.PK)
            {
                instanceT_BM_KCXXBusinessEntity.SelectByKey();
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            }
            else if (instanceT_BM_KCXXBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ID)
            {
                instanceT_BM_KCXXBusinessEntity.SelectByObjectID();
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            }
            else if (instanceT_BM_KCXXBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ALL)
            {
                instanceT_BM_KCXXBusinessEntity.SelectByAnyCondition();
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            }
            else
            {
                instanceT_BM_KCXXBusinessEntity.SelectByAnyCondition();
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            }
            return(instanceT_BM_KCXXBusinessEntity.AppData);
        }
        //=========================================================================
        //  FunctionName : Count
        /// <summary>
        /// 统计记录数方法
        /// </summary>
        /// <param name="appData">应用数据实体</param>
        /// <returns>返回数据实体对象</returns>
        //=========================================================================
        public T_BM_KCXXApplicationData Count(T_BM_KCXXApplicationData appData)
        {
            T_BM_KCXXBusinessEntity instanceT_BM_KCXXBusinessEntity = (T_BM_KCXXBusinessEntity)CreateBusinessEntityInstance(typeof(T_BM_KCXXBusinessEntity));

            instanceT_BM_KCXXBusinessEntity.AppData = appData;
            instanceT_BM_KCXXBusinessEntity.CountByAnyCondition();
            instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            return(instanceT_BM_KCXXBusinessEntity.AppData);
        }
        //=========================================================================
        //  FunctionName : Modify
        /// <summary>
        /// 更新方法
        /// </summary>
        /// <param name="appData">应用数据实体</param>
        /// <returns>返回数据实体对象</returns>
        //=========================================================================
        public T_BM_KCXXApplicationData Modify(T_BM_KCXXApplicationData appData)
        {
            T_BM_KCXXBusinessEntity instanceT_BM_KCXXBusinessEntity = (T_BM_KCXXBusinessEntity)CreateBusinessEntityInstance(typeof(T_BM_KCXXBusinessEntity));

            instanceT_BM_KCXXBusinessEntity.AppData = appData;
            if (instanceT_BM_KCXXBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.PK)
            {
                if (instanceT_BM_KCXXBusinessEntity.IsExistByKey() == true)
                {
                    instanceT_BM_KCXXBusinessEntity.UpdateByKey();
                    instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
                }
                else
                {
                    instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure;
                }
            }
            else if (instanceT_BM_KCXXBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ID)
            {
                if (instanceT_BM_KCXXBusinessEntity.IsExistByObjectID() == true)
                {
                    instanceT_BM_KCXXBusinessEntity.UpdateByObjectID();
                    instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
                }
                else
                {
                    instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure;
                }
            }
            else if (instanceT_BM_KCXXBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.BATCH)
            {
                instanceT_BM_KCXXBusinessEntity.UpdateByObjectIDBatch();
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            }
            else if (instanceT_BM_KCXXBusinessEntity.AppData.OPCode == ApplicationDataBase.OPType.ALL)
            {
                instanceT_BM_KCXXBusinessEntity.UpdateByAnyCondition();
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            }
            else
            {
                if (instanceT_BM_KCXXBusinessEntity.IsExistByObjectID() == true)
                {
                    instanceT_BM_KCXXBusinessEntity.UpdateByObjectID();
                    instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
                }
                else
                {
                    instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure;
                }
            }
            return(instanceT_BM_KCXXBusinessEntity.AppData);
        }
        //=====================================================================
        //  FunctionName : GetDataByObjectID
        /// <summary>
        /// 以ObjectID为条件查询记录并返回AppData
        /// </summary>
        //=====================================================================
        public static T_BM_KCXXApplicationData GetDataByObjectID(string strObjectID)
        {
            // 创建数据库连接
            Database  db          = DatabaseFactory.CreateDatabase("strConnManager");
            string    strProcName = "SP_SelectT_BM_KCXXByObjectID";
            DbCommand cmdProc     = db.GetStoredProcCommand(strProcName);

            // 设定存储过程输入参数
            db.AddInParameter(cmdProc, "@ObjectID", DbType.String);
            // 对存储过程参数赋值
            db.SetParameterValue(cmdProc, "@ObjectID", strObjectID);
            // 执行存储过程
            return(T_BM_KCXXApplicationData.FillDataFromDataReader(db.ExecuteReader(cmdProc)));
        }
        //=========================================================================
        //  FunctionName : Add
        /// <summary>
        /// 添加方法
        /// </summary>
        /// <param name="appData">应用数据实体</param>
        /// <returns>返回数据实体对象</returns>
        //=========================================================================
        public T_BM_KCXXApplicationData Add(T_BM_KCXXApplicationData appData)
        {
            T_BM_KCXXBusinessEntity instanceT_BM_KCXXBusinessEntity = (T_BM_KCXXBusinessEntity)CreateBusinessEntityInstance(typeof(T_BM_KCXXBusinessEntity));

            instanceT_BM_KCXXBusinessEntity.AppData = appData;
            if (instanceT_BM_KCXXBusinessEntity.IsExistByKey() == false)
            {
                instanceT_BM_KCXXBusinessEntity.Insert();
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Succeed;
            }
            else
            {
                instanceT_BM_KCXXBusinessEntity.AppData.ResultCode = ApplicationDataBase.ResultState.Failure;
            }
            return(instanceT_BM_KCXXBusinessEntity.AppData);
        }
Пример #7
0
        public static IEnumerable <T_BM_KCXXApplicationData> GetCollectionFromImportDataTable(DataTable dt)
        {
            List <T_BM_KCXXApplicationData> collection = new List <T_BM_KCXXApplicationData>();

            foreach (DataRow dr in dt.Rows)
            {
                T_BM_KCXXApplicationData applicationData = new T_BM_KCXXApplicationData()
                {
                    ObjectID = (dr.ReadGuidNullable("ObjectID") == null ? null : dr.ReadGuidNullable("ObjectID").ToString()),
                    KCBH     = dr.ReadString("KCBH"),
                    KCMC     = dr.ReadString("KCMC"),
                    KCXLBH   = dr.ReadString("KCXLBH"),
                    KCTP     = dr.ReadString("KCTP"),
                    KCNR     = dr.ReadString("KCNR"),
                    KCKKSJ   = dr.ReadDateTimeNullable("KCKKSJ"),
                    KSS      = dr.ReadInt32Nullable("KSS"),
                };
                collection.Add(applicationData);
            }
            return(collection);
        }