Beispiel #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MES.Model.ForeignCurrency DataRowToModel(DataRow row)
 {
     MES.Model.ForeignCurrency model = new MES.Model.ForeignCurrency();
     if (row != null)
     {
         if (row["i_id"] != null && row["i_id"].ToString() != "")
         {
             model.i_id = int.Parse(row["i_id"].ToString());
         }
         if (row["cexch_name"] != null)
         {
             model.cexch_name = row["cexch_name"].ToString();
         }
         if (row["cexch_code"] != null)
         {
             model.cexch_code = row["cexch_code"].ToString();
         }
         if (row["bcal"] != null && row["bcal"].ToString() != "")
         {
             if ((row["bcal"].ToString() == "1") || (row["bcal"].ToString().ToLower() == "true"))
             {
                 model.bcal = true;
             }
             else
             {
                 model.bcal = false;
             }
         }
         if (row["idec"] != null && row["idec"].ToString() != "")
         {
             model.idec = int.Parse(row["idec"].ToString());
         }
         if (row["nerror"] != null && row["nerror"].ToString() != "")
         {
             model.nerror = float.Parse(row["nerror"].ToString());
         }
         if (row["iotherused"] != null && row["iotherused"].ToString() != "")
         {
             model.iotherused = int.Parse(row["iotherused"].ToString());
         }
         //if (row["pubufts"] != null && row["pubufts"].ToString() != "")
         //{
         //    model.pubufts = DateTime.Parse(row["pubufts"].ToString());
         //}
     }
     return(model);
 }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MES.Model.ForeignCurrency GetModel(int i_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 i_id,cexch_name,cexch_code,bcal,idec,nerror,iotherused,pubufts from foreigncurrency ");
            strSql.Append(" where i_id=@i_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@i_id", SqlDbType.Int, 4)
            };
            parameters[0].Value = i_id;

            MES.Model.ForeignCurrency model = new MES.Model.ForeignCurrency();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }