protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Maticsoft.BLL.ComPany combll = new Maticsoft.BLL.ComPany(); int maxid = combll.GetMaxId() - 1; Maticsoft.Model.ComPany commodel = combll.GetModel(maxid); lblComPanyContent.Text = commodel.comconten; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.ComPany model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ComPany set "); strSql.Append("CompanyNames=@CompanyNames,"); strSql.Append("CompanyType=@CompanyType,"); strSql.Append("Fanren=@Fanren,"); strSql.Append("ComAddress=@ComAddress,"); strSql.Append("ComFax=@ComFax,"); strSql.Append("ComPhoto=@ComPhoto,"); strSql.Append("ComEmail=@ComEmail,"); strSql.Append("QQ=@QQ,"); strSql.Append("Comwangzhi=@Comwangzhi,"); strSql.Append("comconten=@comconten"); strSql.Append(" where CompanyID=@CompanyID"); SqlParameter[] parameters = { new SqlParameter("@CompanyID", SqlDbType.Int, 4), new SqlParameter("@CompanyNames", SqlDbType.VarChar, 200), new SqlParameter("@CompanyType", SqlDbType.VarChar, 200), new SqlParameter("@Fanren", SqlDbType.VarChar, 200), new SqlParameter("@ComAddress", SqlDbType.Text), new SqlParameter("@ComFax", SqlDbType.VarChar, 200), new SqlParameter("@ComPhoto", SqlDbType.VarChar, 200), new SqlParameter("@ComEmail", SqlDbType.VarChar, 200), new SqlParameter("@QQ", SqlDbType.VarChar, 200), new SqlParameter("@Comwangzhi", SqlDbType.Text), new SqlParameter("@comconten", SqlDbType.Text) }; parameters[0].Value = model.CompanyID; parameters[1].Value = model.CompanyNames; parameters[2].Value = model.CompanyType; parameters[3].Value = model.Fanren; parameters[4].Value = model.ComAddress; parameters[5].Value = model.ComFax; parameters[6].Value = model.ComPhoto; parameters[7].Value = model.ComEmail; parameters[8].Value = model.QQ; parameters[9].Value = model.Comwangzhi; parameters[10].Value = model.comconten; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void bind() { Maticsoft.BLL.ComPany companybll = new Maticsoft.BLL.ComPany(); int maxid = companybll.GetMaxId() - 1; Maticsoft.Model.ComPany companymodel = companybll.GetModel(maxid); lblComEmail.Text = companymodel.ComEmail; lblComFax.Text = companymodel.ComFax; lblCompanyNames.Text = companymodel.CompanyNames; lblComPhoto.Text = companymodel.ComPhoto; lblFanren.Text = companymodel.Fanren; }
private void ShowInfo(int CompanyID) { Maticsoft.BLL.ComPany bll = new Maticsoft.BLL.ComPany(); Maticsoft.Model.ComPany model = bll.GetModel(CompanyID); this.lblCompanyID.Text = model.CompanyID.ToString(); this.txtCompanyNames.Text = model.CompanyNames; this.txtCompanyType.Text = model.CompanyType; this.txtComAddress.Text = model.ComAddress; this.txtComFax.Text = model.ComFax; this.txtComPhoto.Text = model.ComPhoto; this.txtComEmail.Text = model.ComEmail; this.txtQQ.Text = model.QQ; this.txtComwangzhi.Text = model.Comwangzhi; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Maticsoft.BLL.ComPany companybll = new Maticsoft.BLL.ComPany(); Maticsoft.Model.ComPany companymodel = companybll.GetModel(1); lblComAddress.Text = companymodel.ComAddress; lblComEmail.Text = companymodel.ComEmail; lblComFax.Text = companymodel.ComFax; lblCompanyNames.Text = companymodel.CompanyNames; lblComPhoto.Text = companymodel.ComPhoto; lblComwangzhi.Text = companymodel.Comwangzhi; lblqq.Text = companymodel.QQ; } }
private void bind() { Maticsoft.BLL.ComPany combll = new Maticsoft.BLL.ComPany(); Maticsoft.Model.ComPany commodel = combll.GetModel(1); txtcomfaren.Text = commodel.Fanren.ToString(); txtcomfax.Text = commodel.ComFax; txtcompanyname.Text = commodel.CompanyNames; txtcompanytype.Text = commodel.CompanyType; txtcomphoto.Text = commodel.ComPhoto; txtcomwangzhi.Text = commodel.Comwangzhi; txtcontent.Text = commodel.comconten; txtEmail.Text = commodel.ComEmail; txtqq.Text = commodel.QQ; txtcomaddress.Text = commodel.ComAddress; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Maticsoft.Model.ComPany model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ComPany("); strSql.Append("CompanyNames,CompanyType,Fanren,ComAddress,ComFax,ComPhoto,ComEmail,QQ,Comwangzhi,comconten)"); strSql.Append(" values ("); strSql.Append("@CompanyNames,@CompanyType,@Fanren,@ComAddress,@ComFax,@ComPhoto,@ComEmail,@QQ,@Comwangzhi,@comconten)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@CompanyNames", SqlDbType.VarChar, 200), new SqlParameter("@CompanyType", SqlDbType.VarChar, 200), new SqlParameter("@Fanren", SqlDbType.VarChar, 200), new SqlParameter("@ComAddress", SqlDbType.Text), new SqlParameter("@ComFax", SqlDbType.VarChar, 200), new SqlParameter("@ComPhoto", SqlDbType.VarChar, 200), new SqlParameter("@ComEmail", SqlDbType.VarChar, 200), new SqlParameter("@QQ", SqlDbType.VarChar, 200), new SqlParameter("@Comwangzhi", SqlDbType.Text), new SqlParameter("@comconten", SqlDbType.Text) }; parameters[0].Value = model.CompanyNames; parameters[1].Value = model.CompanyType; parameters[2].Value = model.Fanren; parameters[3].Value = model.ComAddress; parameters[4].Value = model.ComFax; parameters[5].Value = model.ComPhoto; parameters[6].Value = model.ComEmail; parameters[7].Value = model.QQ; parameters[8].Value = model.Comwangzhi; parameters[9].Value = model.comconten; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.ComPany GetModel(int CompanyID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 CompanyID,CompanyNames,CompanyType,Fanren,ComAddress,ComFax,ComPhoto,ComEmail,QQ,Comwangzhi,comconten from ComPany "); strSql.Append(" where CompanyID=@CompanyID"); SqlParameter[] parameters = { new SqlParameter("@CompanyID", SqlDbType.Int, 4) }; parameters[0].Value = CompanyID; Maticsoft.Model.ComPany model = new Maticsoft.Model.ComPany(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["CompanyID"].ToString() != "") { model.CompanyID = int.Parse(ds.Tables[0].Rows[0]["CompanyID"].ToString()); } model.CompanyNames = ds.Tables[0].Rows[0]["CompanyNames"].ToString(); model.CompanyType = ds.Tables[0].Rows[0]["CompanyType"].ToString(); model.Fanren = ds.Tables[0].Rows[0]["Fanren"].ToString(); model.ComAddress = ds.Tables[0].Rows[0]["ComAddress"].ToString(); model.ComFax = ds.Tables[0].Rows[0]["ComFax"].ToString(); model.ComPhoto = ds.Tables[0].Rows[0]["ComPhoto"].ToString(); model.ComEmail = ds.Tables[0].Rows[0]["ComEmail"].ToString(); model.QQ = ds.Tables[0].Rows[0]["QQ"].ToString(); model.Comwangzhi = ds.Tables[0].Rows[0]["Comwangzhi"].ToString(); model.comconten = ds.Tables[0].Rows[0]["comconten"].ToString(); return(model); } else { return(null); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["usename"] != null) { if (Session["usename"].ToString() != "") { Maticsoft.BLL.ComPany companybll = new Maticsoft.BLL.ComPany(); Maticsoft.Model.ComPany companymodel = companybll.GetModel(1); if (companymodel.CompanyNames == "") { btnadd.Visible = true; btnupadel.Visible = false; } else { btnadd.Visible = false; btnupadel.Visible = true; bind(); } } else { Response.Redirect("login.aspx"); Response.End(); } } else { Response.Redirect("login.aspx"); Response.End(); } } }
protected void btnadd_Click(object sender, EventArgs e) { Maticsoft.BLL.ComPany companybll = new Maticsoft.BLL.ComPany(); Maticsoft.Model.ComPany commodel = new Maticsoft.Model.ComPany(); if (txtcompanyname.Text.Trim() == "") { lblconname.Text = "请填写公司名称"; return; } lblconname.Text = ""; commodel.CompanyNames = txtcompanyname.Text.Trim(); if (txtcompanytype.Text.Trim() == "") { lbltype.Text = "请填写公司类型"; return; } lbltype.Text = ""; commodel.CompanyType = txtcompanytype.Text.Trim(); if (txtcomaddress.Text.Trim() == "") { lbladdress.Text = "请填写公司地址"; return; } lbladdress.Text = ""; commodel.ComAddress = txtcomaddress.Text.Trim(); if (txtcomfax.Text.Trim() == "") { lblfax.Text = "请填写公司传真"; return; } lblfax.Text = ""; commodel.ComFax = txtcomfax.Text.Trim(); if (txtcomfaren.Text.Trim() == "") { lblfanren.Text = "请填写公司法人代表"; return; } lblfanren.Text = ""; commodel.Fanren = txtcomfaren.Text.Trim(); if (txtcomphoto.Text.Trim() == "") { lblphoto.Text = "请填写公司电话"; return; } lblphoto.Text = ""; commodel.ComPhoto = txtcomphoto.Text.Trim(); if (txtEmail.Text.Trim() == "") { lblemail.Text = "请填写公司邮箱"; return; } lblemail.Text = ""; commodel.ComEmail = txtEmail.Text.Trim(); if (txtqq.Text.Trim() == "") { lblqq.Text = "请填写公司qq或MSN"; return; } lblqq.Text = ""; commodel.QQ = txtqq.Text.Trim(); if (txtcomwangzhi.Text.Trim() == "") { lblwangzhi.Text = "请填写公司网址"; return; } lblwangzhi.Text = ""; commodel.Comwangzhi = txtcomwangzhi.Text.Trim(); if (txtcontent.Text.Trim() == "") { lblcomcontent.Text = "请填写公司简介"; } lblcomcontent.Text = ""; commodel.comconten = txtcontent.Text.Trim(); companybll.Add(commodel); Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('信息添加成功....')</script>"); txtcomaddress.Text = string.Empty; txtcomfaren.Text = string.Empty; txtcomfax.Text = string.Empty; txtcompanyname.Text = string.Empty; txtcompanytype.Text = string.Empty; txtcomphoto.Text = string.Empty; txtcomwangzhi.Text = string.Empty; txtcontent.Text = string.Empty; txtEmail.Text = string.Empty; txtqq.Text = string.Empty; }
public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtCompanyNames.Text.Trim().Length == 0) { strErr += "CompanyNames不能为空!\\n"; } if (this.txtCompanyType.Text.Trim().Length == 0) { strErr += "CompanyType不能为空!\\n"; } if (this.txtComAddress.Text.Trim().Length == 0) { strErr += "ComAddress不能为空!\\n"; } if (this.txtComFax.Text.Trim().Length == 0) { strErr += "ComFax不能为空!\\n"; } if (this.txtComPhoto.Text.Trim().Length == 0) { strErr += "ComPhoto不能为空!\\n"; } if (this.txtComEmail.Text.Trim().Length == 0) { strErr += "ComEmail不能为空!\\n"; } if (this.txtQQ.Text.Trim().Length == 0) { strErr += "QQ不能为空!\\n"; } if (this.txtComwangzhi.Text.Trim().Length == 0) { strErr += "Comwangzhi不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int CompanyID = int.Parse(this.lblCompanyID.Text); string CompanyNames = this.txtCompanyNames.Text; string CompanyType = this.txtCompanyType.Text; string ComAddress = this.txtComAddress.Text; string ComFax = this.txtComFax.Text; string ComPhoto = this.txtComPhoto.Text; string ComEmail = this.txtComEmail.Text; string QQ = this.txtQQ.Text; string Comwangzhi = this.txtComwangzhi.Text; Maticsoft.Model.ComPany model = new Maticsoft.Model.ComPany(); model.CompanyID = CompanyID; model.CompanyNames = CompanyNames; model.CompanyType = CompanyType; model.ComAddress = ComAddress; model.ComFax = ComFax; model.ComPhoto = ComPhoto; model.ComEmail = ComEmail; model.QQ = QQ; model.Comwangzhi = Comwangzhi; Maticsoft.BLL.ComPany bll = new Maticsoft.BLL.ComPany(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx"); }