首页 新闻 会员 周边

NBear保存实体类问题

0
[待解决问题]

NBear框架中数据库表中添加了几个字段,在保存实体类的时候保存不到数据库中。。。。

代码狂人的主页 代码狂人 | 初学一级 | 园豆:200
提问于:2011-10-20 09:49
< >
分享
所有回答(1)
0

最好能把代码帖出来,大家帮你看看

artwl | 园豆:16736 (专家六级) | 2011-10-20 10:17

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Bsh.WebUi;
using Led.Bean;
using System.Collections.Generic;
using System.Xml;
using NBear.Common;
using Led.BizImpl;
using Bsh.Utile;
using System.IO;

namespace Led.Member.member.ltt
{
/// <summary>
/// 功能:添加招投标信息
/// 创建人:张建
/// 创建时间:2011-10月11日
/// </summary>
///
public partial class addzhaotoubiao : LoginPage
{
protected string starttime, endtime;
private string longFileName, fileType, fileName, fileExtension;//缩略属性

protected List<led_xinxitype> xinxitypes = new List<led_xinxitype>();

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string xmlFile = "http://upload.ledtrade.com.cn/xml/xinxitype.xml";
XmlTextReader reader = new XmlTextReader(xmlFile);

led_xinxitype infos = EntityFactory<led_xinxitype>.CreateObject();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if ("id".Equals(reader.Name))
{
infos.x_id = Convert.ToInt32(reader.ReadString());
}

if ("title".Equals(reader.Name))
{
infos.x_name = reader.ReadString();

}
if ("isdel".Equals(reader.Name))
{
infos.x_del = Convert.ToInt32(reader.ReadString());
xinxitypes.Add(infos);
infos = EntityFactory<led_xinxitype>.CreateObject();
}
}

}
reader.Close();
}
}

/// <summary>
/// 功能:添加招标信息
/// 创建人:
/// 创建时间:2011-10月11日
/// </summary>
///
protected void btnadd_Click(object sender, EventArgs e)
{
led_zhaotoubiao infos = EntityFactory<led_zhaotoubiao>.CreateObject();

string count = Request.Form["count"];
if (count != null && count != "")
{
infos.z_count = Convert.ToInt32(Request.Form["count"]);
}

infos.z_code ="LED"+System.DateTime.Today.ToString();//编码
infos.u_id = 3;//用户编号
infos.z_name = Request.Form["cpname"];//招标名称
//infos.z_type = 3;//行业类型
if (Request.Form["slBrand"] != null && Request.Form["slBrand"].Trim() != "")
{
infos.z_type = Convert.ToInt32(Request.Form["slBrand"]);
}
if (Request.Form["slHyType"] != null && Request.Form["slHyType"].Trim() != "")
{
infos.z_typechild = Convert.ToInt32(Request.Form["slHyType"]);
}
if (Request.Form["xxtype"] != null && Request.Form["xxtype"].Trim() != "")
{
infos.z_type = Convert.ToInt32(Request.Form["xxtype"]);//信息类型
}
infos.z_place = "招标地址";
infos.z_sheng = Convert.ToInt32(Request.Form["province"]);//省
infos.z_shi = Convert.ToInt32(Request.Form["city"]);//市
infos.z_detail = Request.Form["FileContent"];//招标明细
infos.z_zdate = Convert.ToDateTime(Request.Form["zdate"]);
infos.z_pdate = Convert.ToDateTime(Request.Form["pdate"]);
infos.z_jdate = Convert.ToDateTime(Request.Form["jdate"]);
infos.z_passtime = "2012-12-20";//过期时间
infos.z_time = "1年2月3天";//招标剩余时间
infos.z_twarning = this.TextBox2.Text;//投标注意事项
if (Request.Form["myrec"] != null && Request.Form["myrec"].Trim() != "")
{
infos.z_pay = Convert.ToInt32(Request.Form["myrec"]);//运费承担方
}

infos.ischeck = 0;//审核(0:审核中,1:已发布,2:未通过)
infos.z_status = 0;//状态:(0:招标中,1:中标,2:未中标,3:评标中,4:招标已结束)
infos.t_status = 0;//状态:(0:投标中,1:中标,2:未中标,3:投标已结束)
infos.isdel = 0;//删除

//如果没上传就显示无图片标记
string pppic = "http://img.ledtrade.com.cn/imgpool/error.gif";
if (this.FileUpload1.PostedFile.ContentLength > 0)
infos.z_file = uploadpeopleimg();
else
infos.z_file = pppic;


//int isok = 0;
int isok = new LedZhaoTouBiaoImpl().Add(infos);
Response.Write("isok值:"+isok);
if (isok > 0)
AlertClass.AlertToPage("信息添加成功!", "zhaotoubiaolist.aspx?check=0");
else
AlertClass.AlertToBack("信息添加失败!" + "招标名称:" + infos.z_name +"==类型:"+infos.z_type+","+infos.z_typechild+"==上传文件:"+infos.z_file+ "==招标地址:" + "省:"+infos.z_sheng + "市:"+infos.z_shi + "==招标明细:" + infos.z_detail + "==数量:" + count + "==招标截止日期:" + infos.z_zdate + "==评标截止日期:" + infos.z_jdate + "==交货截止日期:" + infos.z_jdate + "==运费承担方:" + infos.z_pay + "==投标注意事项:" + infos.z_twarning);
}

/// <summary>
/// 图片、文件上传帮助类
/// </summary>
/// <param name="path"></param>
private string uploadpeopleimg()
{
string dtPubDate = StringClass.getData();
string strFileName = DateTime.Now.ToString("yymmddHHmmssffff");
string strFileName_pic = strFileName;
string strFileDate = strFileName;
string path1 = String.Empty;
string path4 = String.Empty;

int pcount = Request.Files.Count;
if (pcount > 0)
{
HttpPostedFile hf = Request.Files[0];//获取上传图片对象
if (hf.ContentLength > 0)
{
string tW = "130";
string tH = "120";
string tW1 = RequestClass.GetFormString("txtw");//图片的宽度
string tH1 = RequestClass.GetFormString("txth"); //图片的高度

if (tW == null || "".Equals(tW))
{
tW = tW1;
}
if (tH == null || "".Equals(tH))
{
tH = tH1;
}

int fileSize = 0;
fileSize = hf.ContentLength;
if (fileSize < 2097152)
{
longFileName = hf.FileName;
fileName = Path.GetFileName(longFileName);
fileExtension = Path.GetExtension(longFileName);
strFileName_pic = strFileName_pic + fileExtension;
fileType = hf.ContentType;
path1 = "imgpool/chanpin/yuanshi/" + strFileName_pic;

uploadservice.WebService1 picsv = new Led.Member.uploadservice.WebService1();
byte[] byts = FileClass.getByte(hf);
string flag = picsv.SavePicOfSuoLue(byts, path4, path1, Int32.Parse(tH), Int32.Parse(tW));
}
else
{
AlertClass.AlertToBack("图片大小不能超过2M");
//MessageBox.Show(this.Page, "图片大小不能超过2M");
//return "";
}
return path4;
}
else
{
return "";
}
}
else
{
return "";
}
}
}
}

支持(0) 反对(0) 代码狂人 | 园豆:200 (初学一级) | 2011-10-20 10:20
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册