/// <summary> /// 构建安全联网煤矿信息Model /// </summary> /// <returns>Model</returns> protected Model.TN_Coal BuildCoal() { Model.TN_Coal coal = new Model.TN_Coal(); coal.CoalCode = Request.QueryString["coalCode"].Trim(); coal.CoalIP = txtCoalIP.Text.Trim(); coal.CoalName = lblCoalName.Text.Trim(); coal.CountryName = txtCountry.Text.Trim(); coal.ServerCode = ddlServer.SelectedValue; coal.SiteName = txtSite.Text.Trim(); coal.CoalOwner = string.Empty; coal.ContactPhone = string.Empty; return coal; }
/// <summary> /// 由Id获取特定的Model /// </summary> /// <param name="coalCode">煤矿编号</param> /// <returns>TN_Coal model</returns> public Model.TN_Coal GetModel(string coalCode) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("select * from TN_Coals where CoalCode = '{0}'", coalCode); DataSet dst = dal.GetDataSet(sb.ToString()); if (dst != null) { Model.TN_Coal coal = new Model.TN_Coal(); coal.Id = Convert.ToInt32(dst.Tables[0].Rows[0]["Id"]); coal.CoalCode = dst.Tables[0].Rows[0]["CoalCode"].ToString(); coal.CoalIP = dst.Tables[0].Rows[0]["CoalIP"].ToString(); coal.CoalName = dst.Tables[0].Rows[0]["CoalName"].ToString(); coal.CoalOwner = dst.Tables[0].Rows[0]["CoalOwner"].ToString(); coal.ContactPhone = dst.Tables[0].Rows[0]["ContactPhone"].ToString(); coal.CountryName = dst.Tables[0].Rows[0]["CountryName"].ToString(); coal.ServerCode = dst.Tables[0].Rows[0]["ServerCode"].ToString(); coal.SiteName = dst.Tables[0].Rows[0]["SiteName"].ToString(); return coal; } else { return null; } }