Ejemplo n.º 1
0
        public static EntityData GetDefaultRiskIndex()
        {
            EntityData data2;

            try
            {
                RiskIndexStrategyBuilder builder = new RiskIndexStrategyBuilder();
                builder.AddStrategy(new Strategy(RiskIndexStrategyName.IsDefault, "1"));
                string     queryString = builder.BuildMainQueryString();
                QueryAgent agent       = new QueryAgent();
                EntityData data        = agent.FillEntityData("RiskIndex", queryString);
                agent.Dispose();
                data2 = data;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(data2);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="code"></param>
        /// <param name="parentCode"></param>
        private void SavaData()
        {
            try
            {
                string IndexCode = this.txtIndexCode.Value;

                EntityData entity = DAL.EntityDAO.ConstructDAO.GetRiskIndexByCode(IndexCode);
                DataRow    dr;
                bool       isNew = !entity.HasRecord();


                if (isNew)
                {
                    dr = entity.GetNewRecord();

                    IndexCode = SystemManageDAO.GetNewSysCode("RiskIndexCode");
                    this.txtIndexCode.Value = IndexCode;
                    dr["IndexCode"]         = IndexCode;
                    entity.CurrentTable.Rows.Add(dr);
                }
                else
                {
                    dr = entity.CurrentRow;
                }

                dr["IndexName"]  = this.txtIndexName.Value;
                dr["IndexLevel"] = BLL.ConvertRule.ToInt(this.txtIndexLevel.Value);

                if (this.chkIsDefault.Checked)
                {
                    dr["IsDefault"] = 1;
                }
                else
                {
                    dr["IsDefault"] = 0;
                }

                DAL.EntityDAO.ConstructDAO.SubmitAllRiskIndex(entity);
                entity.Dispose();

                //更新其它记录的默认值
                if (this.chkIsDefault.Checked)
                {
                    RiskIndexStrategyBuilder sb = new RiskIndexStrategyBuilder();

                    sb.AddStrategy(new Strategy(RiskIndexStrategyName.IsDefault, "1"));
                    sb.AddStrategy(new Strategy(RiskIndexStrategyName.ExceptIndexCode, IndexCode));

                    string sql = sb.BuildMainQueryString();

                    QueryAgent qa = new QueryAgent();
                    entity = qa.FillEntityData("RiskIndex", sql);
                    qa.Dispose();

                    if (entity.HasRecord())
                    {
                        foreach (DataRow drTemp in entity.CurrentTable.Rows)
                        {
                            drTemp["IsDefault"] = 0;
                        }

                        DAL.EntityDAO.ConstructDAO.SubmitAllRiskIndex(entity);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }