/// <summary> /// 加载公司资料 /// </summary> private void LoadFirmData() { int id = int.Parse(Request.Params["id"]); EtNet_Models.FirmInfo model = EtNet_BLL.FirmInfoManager.GetModel(id); string str = "<script>alert('加载数据失败!'); window.location ='ShowFirm.aspx'</script>"; if (model != null) { this.iptcaddress.Value = model.caddress; this.iptcname.Value = model.cname; this.ipteaddress.Value = model.eaddress; this.iptename.Value = model.ename; this.iptfax.Value = model.fax; this.iptfirmcode.Value = model.firmcode; this.iptorgcode.Value = model.orgcode; this.iptpostal.Value = model.postalcode; this.traremark.Value = model.remark; this.iptshortname.Value = model.sname; this.ipttaxnum.Value = model.taxnum; this.ipttel.Value = model.telephone; this.iptwedsite.Value = model.website; this.iptmailbox.Value = model.mailbox; this.hidfirm.Value = ""; LoadAccountData(id); LoadLogoImg(model.imgpath); } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "load", str, false); } }
/// <summary> /// 添加公司资料 /// </summary> private void SaveFirm() { if (TestAdd()) { EtNet_Models.FirmInfo model = new EtNet_Models.FirmInfo(); model.caddress = this.iptcaddress.Value; model.cname = this.iptcname.Value; model.eaddress = this.ipteaddress.Value; model.ename = this.iptename.Value; model.fax = this.iptfax.Value; model.firmcode = this.iptfirmcode.Value; model.imgpath = SaveLogoImg(); model.mailbox = this.iptmailbox.Value; model.orgcode = this.iptorgcode.Value; model.postalcode = this.iptpostal.Value; model.remark = this.traremark.Value; model.sname = this.iptshortname.Value; model.taxnum = this.ipttaxnum.Value; model.telephone = this.ipttel.Value; model.website = this.iptwedsite.Value; int id = EtNet_BLL.FirmInfoManager.Add(model); SaveAccount(id); Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "add", "<script> window.location ='ShowFirm.aspx'</script>", false); } else { this.hidfirm.Value = ""; } }
/// <summary> /// 修改公司资料 /// </summary> private void SaveModifyFirm() { int id = int.Parse(Request.Params["id"]); if (TestModify(id)) { string str = ""; EtNet_Models.FirmInfo model = EtNet_BLL.FirmInfoManager.GetModel(id); if (model != null) { bool mod; //检测公司logo是否上传成功 string path = ModifyLogoImg(model.imgpath.Trim(), out mod); if (mod) { model.caddress = this.iptcaddress.Value; model.cname = this.iptcname.Value; model.eaddress = this.ipteaddress.Value; model.ename = this.iptename.Value; model.fax = this.iptfax.Value; model.firmcode = this.iptfirmcode.Value; model.mailbox = this.iptmailbox.Value; model.orgcode = this.iptorgcode.Value; model.postalcode = this.iptpostal.Value; model.remark = this.traremark.Value; model.sname = this.iptshortname.Value; model.taxnum = this.ipttaxnum.Value; model.telephone = this.ipttel.Value; model.website = this.iptwedsite.Value; model.imgpath = path; if (EtNet_BLL.FirmInfoManager.Update(model)) { ModifyAccount(id); str = "<script>alert('修改成功!'); window.location ='ShowFirm.aspx'</script>"; } else { str = "<script>alert('修改失败!'); window.location ='ShowFirm.aspx'</script>"; } } else { str = "<script>alert('修改失败!'); window.location ='ShowFirm.aspx'</script>"; } } else { str = "<script>alert('操作失败,该公司资料可能已删除!'); window.location ='ShowFirm.aspx'</script>"; } Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "mod", str, false); } else { LoadFirmData(); //重置 } }
//删除公司logo protected void btndel_Click(object sender, EventArgs e) { int id = int.Parse(Request.Params["id"]); EtNet_Models.FirmInfo model = EtNet_BLL.FirmInfoManager.GetModel(id); if (model != null) { DeleteLogoImg(model.imgpath); model.imgpath = ""; EtNet_BLL.FirmInfoManager.Update(model); } LoadFirmData(); }
/// <summary> /// 增加一条数据,取得id值 /// </summary> public static int Add(EtNet_Models.FirmInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("ProcFirm"); SqlParameter[] parameters = { new SqlParameter("@firmcode", SqlDbType.VarChar, 20), new SqlParameter("@sname", SqlDbType.VarChar, 40), new SqlParameter("@cname", SqlDbType.VarChar, 100), new SqlParameter("@ename", SqlDbType.VarChar, 100), new SqlParameter("@caddress", SqlDbType.VarChar, 200), new SqlParameter("@eaddress", SqlDbType.VarChar, 200), new SqlParameter("@telephone", SqlDbType.VarChar, 40), new SqlParameter("@fax", SqlDbType.VarChar, 40), new SqlParameter("@mailbox", SqlDbType.VarChar, 40), new SqlParameter("@postalcode", SqlDbType.VarChar, 40), new SqlParameter("@website", SqlDbType.VarChar, 100), new SqlParameter("@taxnum", SqlDbType.VarChar, 40), new SqlParameter("@orgcode", SqlDbType.VarChar, 40), new SqlParameter("@imgpath", SqlDbType.VarChar, 200), new SqlParameter("@remark", SqlDbType.VarChar, 200), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.firmcode; parameters[1].Value = model.sname; parameters[2].Value = model.cname; parameters[3].Value = model.ename; parameters[4].Value = model.caddress; parameters[5].Value = model.eaddress; parameters[6].Value = model.telephone; parameters[7].Value = model.fax; parameters[8].Value = model.mailbox; parameters[9].Value = model.postalcode; parameters[10].Value = model.website; parameters[11].Value = model.taxnum; parameters[12].Value = model.orgcode; parameters[13].Value = model.imgpath; parameters[14].Value = model.remark; parameters[15].Direction = ParameterDirection.Output; EtNet_DAL.DBHelper.ExecuteCommandPoc(strSql.ToString(), parameters); int id = int.Parse(parameters[15].Value.ToString()); return(id); }
/// <summary> /// 得到一个对象实体 /// </summary> public static EtNet_Models.FirmInfo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,firmcode,sname,cname,ename,caddress,eaddress,telephone,fax,mailbox,postalcode,website,taxnum,orgcode,imgpath,remark from FirmInfo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; EtNet_Models.FirmInfo model = new EtNet_Models.FirmInfo(); DataTable ds = EtNet_DAL.DBHelper.GetDataSet(strSql.ToString(), parameters); if (ds.Rows.Count > 0) { model.id = int.Parse(ds.Rows[0]["id"].ToString()); model.firmcode = ds.Rows[0]["firmcode"].ToString(); model.sname = ds.Rows[0]["sname"].ToString(); model.cname = ds.Rows[0]["cname"].ToString(); model.ename = ds.Rows[0]["ename"].ToString(); model.caddress = ds.Rows[0]["caddress"].ToString(); model.eaddress = ds.Rows[0]["eaddress"].ToString(); model.telephone = ds.Rows[0]["telephone"].ToString(); model.fax = ds.Rows[0]["fax"].ToString(); model.mailbox = ds.Rows[0]["mailbox"].ToString(); model.postalcode = ds.Rows[0]["postalcode"].ToString(); model.website = ds.Rows[0]["website"].ToString(); model.taxnum = ds.Rows[0]["taxnum"].ToString(); model.orgcode = ds.Rows[0]["orgcode"].ToString(); model.imgpath = ds.Rows[0]["imgpath"].ToString(); model.remark = ds.Rows[0]["remark"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(EtNet_Models.FirmInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update FirmInfo set "); strSql.Append("firmcode=@firmcode,"); strSql.Append("sname=@sname,"); strSql.Append("cname=@cname,"); strSql.Append("ename=@ename,"); strSql.Append("caddress=@caddress,"); strSql.Append("eaddress=@eaddress,"); strSql.Append("telephone=@telephone,"); strSql.Append("fax=@fax,"); strSql.Append("mailbox=@mailbox,"); strSql.Append("postalcode=@postalcode,"); strSql.Append("website=@website,"); strSql.Append("taxnum=@taxnum,"); strSql.Append("orgcode=@orgcode,"); strSql.Append("imgpath=@imgpath,"); strSql.Append("remark=@remark"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@firmcode", SqlDbType.VarChar, 20), new SqlParameter("@sname", SqlDbType.VarChar, 40), new SqlParameter("@cname", SqlDbType.VarChar, 100), new SqlParameter("@ename", SqlDbType.VarChar, 100), new SqlParameter("@caddress", SqlDbType.VarChar, 200), new SqlParameter("@eaddress", SqlDbType.VarChar, 200), new SqlParameter("@telephone", SqlDbType.VarChar, 40), new SqlParameter("@fax", SqlDbType.VarChar, 40), new SqlParameter("@mailbox", SqlDbType.VarChar, 40), new SqlParameter("@postalcode", SqlDbType.VarChar, 40), new SqlParameter("@website", SqlDbType.VarChar, 100), new SqlParameter("@taxnum", SqlDbType.VarChar, 40), new SqlParameter("@orgcode", SqlDbType.VarChar, 40), new SqlParameter("@imgpath", SqlDbType.VarChar, 200), new SqlParameter("@remark", SqlDbType.VarChar, 200), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.firmcode; parameters[1].Value = model.sname; parameters[2].Value = model.cname; parameters[3].Value = model.ename; parameters[4].Value = model.caddress; parameters[5].Value = model.eaddress; parameters[6].Value = model.telephone; parameters[7].Value = model.fax; parameters[8].Value = model.mailbox; parameters[9].Value = model.postalcode; parameters[10].Value = model.website; parameters[11].Value = model.taxnum; parameters[12].Value = model.orgcode; parameters[13].Value = model.imgpath; parameters[14].Value = model.remark; parameters[15].Value = model.id; int result = EtNet_DAL.DBHelper.ExecuteCommand(strSql.ToString(), parameters); if (result >= 1) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public static bool Update(EtNet_Models.FirmInfo model) { return(EtNet_DAL.FirmInfoService.Update(model)); }
/// <summary> /// 增加一条数据,取id值 /// </summary> public static int Add(EtNet_Models.FirmInfo model) { return(EtNet_DAL.FirmInfoService.Add(model)); }