/// <summary>
 /// 展示数据
 /// </summary>
 /// <param name="id">记录Id</param>
 private void ShowInfo(int id)
 {
     LBOMDetailBB bOMDetailBB = new LBOMDetailBB();
     vLBOMDetailData model = new vLBOMDetailData();
     try
     {
         model = bOMDetailBB.GetVModel(id);
         this.id.Text = model.id.ToString();
         this.BOMId.Text = model.BOMId.ToString();
         this.materialNo.Text = model.materialNo;
         this.num.Text = model.num.ToString();
     }
     finally
     {
         bOMDetailBB.Dispose();
     }
 }
Example #2
0
        /// <summary>
        /// 得到一个视图model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public vLBOMDetailData GetVModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,BOMId,materialNo,num,isDel,isrtEmpId,isrtDt,updtEmpId,updtDt,materialDesc from vLBOMDetail");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            vLBOMDetailData model = new vLBOMDetailData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row =ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["BOMId"] != DBNull.Value)
                {
                    model.BOMId = Convert.ToInt32(row["BOMId"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["num"] != DBNull.Value)
                {
                    model.num = Convert.ToDouble(row["num"]);
                }
                if (row["isDel"] != DBNull.Value)
                {
                    model.isDel = Convert.ToBoolean(row["isDel"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                if (row["materialDesc"] != DBNull.Value)
                {
                    model.materialDesc = Convert.ToString(row["materialDesc"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }