/// <summary> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { LPalletSortBB palletSortBB = new LPalletSortBB(); vLPalletSortData model = new vLPalletSortData(); try { model = palletSortBB.GetVModel(id); this.tbPalletSortNo.Text = model.palletSortNo; this.tbPalletSortNm.Text = model.palletSortNm; } finally { palletSortBB.Dispose(); } }
/// <summary> /// 得到一个视图model /// </summary> /// <param name="id">主键值</param> /// <returns>model</returns> public vLPalletSortData GetVModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"select id,palletSortNo,palletSortNm,isDel,isrtEmpId,isrtDt,updtEmpId,updtDt,isrtEmpNm,updtEmpNm from vLPalletSort"); strSql.Append(" where id = @id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int) }; parameters[0].Value = id; vLPalletSortData model = new vLPalletSortData(); 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["palletSortNo"] != DBNull.Value) { model.palletSortNo = Convert.ToString(row["palletSortNo"]); } if (row["palletSortNm"] != DBNull.Value) { model.palletSortNm = Convert.ToString(row["palletSortNm"]); } 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["isrtEmpNm"] != DBNull.Value) { model.isrtEmpNm = Convert.ToString(row["isrtEmpNm"]); } if (row["updtEmpNm"] != DBNull.Value) { model.updtEmpNm = Convert.ToString(row["updtEmpNm"]); } return model; } else { return null; } }