protected void bindModel(int id) { dominM = dominBll.GetModel(id); ViewState["loginName"] = dominM.loginName.ToString(); //txtProductName.Text = dominM.productName.Trim(); ViewState["productTypeId"] = dominM.productTypeId.ToString(); ddlName.SelectedValue = typeBll.GetList("productTypeId=" + dominM.productTypeId).Tables[0].Rows[0]["productTypeId"].ToString(); txtChina.Text = dominM.Chineseintroduced.ToString().Trim(); txtEnglish.Text = dominM.Englishintroduction.ToString().Trim(); DataSet ds = imgBLL.GetList("productId=" + id); if ((ds != null) && (ds.Tables[0].Rows.Count > 0)) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; str += dr["imgName"].ToString() + "%"; } DataList1.DataSource = ds; DataList1.DataBind(); photo.Attributes.Add("style", "display:''"); } else { photo.Attributes.Add("style", "display:none"); } }
public int StaticHtml(int id, string loginName) { try { string TempFileName = ProductTem.ToString(); string Tem = Compage.Reader(TempFileName); //读取模板内容 string TempSoure = Tem; ProductDominM doma = new ProductDominM(); if (id == 0) { doma = doBll.GetProductByName(loginName); } else { doma = doBll.GetModel(id); } if (doma != null) { TempSoure = TempSoure.Replace("$ProductID$", doma.productid.ToString().Trim()); } else { string a = "0"; TempSoure = TempSoure.Replace("$ProductID$", a); } string ids = ""; int scriptId = 0; TempSoure = TempSoure.Replace("$typeName$", type(ref ids, ref scriptId, loginName)); TempSoure = TempSoure.Replace("$loginName$", loginName); TempSoure = TempSoure.Replace("$ChinaName$", content(ids, loginName)); //TempSoure = TempSoure.Replace("$ProductScript$", script(scriptId)); TempSoure = TempSoure.Replace("$ProductScript$", scriptId.ToString()); CompanyShow com = new CompanyShow(); TempSoure = TempSoure.Replace("$CompanyName$", com.GetCompanyNameByLoginName(loginName)); if (string.IsNullOrEmpty(doM.htmlurl)) { doma.htmlurl = "industry.htm"; // doma.htmlurl = doma.loginName + "/" + DateTime.Now.ToString("yyyyMMdd") + "_" + id + ".shtml"; } string htmlFile = "industry.htm"; string wenjian = ProductPath + loginName; if (!Directory.Exists(wenjian)) { Directory.CreateDirectory(wenjian); } string htmlpaths = wenjian + "/" + htmlFile; Compage.Writer(htmlpaths, TempSoure); return(1); } catch (Exception e) { return(0); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ProductDominM model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update produceDomin set "); //strSql.Append("loginName=@loginName,"); strSql.Append("Chineseintroduced=@Chineseintroduced,"); strSql.Append("Englishintroduction=@Englishintroduction,"); //strSql.Append("createdate=@createdate,"); strSql.Append("htmlurl=@htmlurl,"); strSql.Append("productName=@productName,"); //strSql.Append("clicks=@clicks,"); strSql.Append("productTypeId=@productTypeId"); strSql.Append(" where productid=@productid"); SqlParameter[] parameters = { new SqlParameter("@productid", SqlDbType.Int, 4), //new SqlParameter("@loginName", SqlDbType.VarChar,50), new SqlParameter("@Chineseintroduced", SqlDbType.Text), new SqlParameter("@Englishintroduction", SqlDbType.Text), //new SqlParameter("@createdate", SqlDbType.DateTime), new SqlParameter("@htmlurl", SqlDbType.VarChar, 120), new SqlParameter("@productName", SqlDbType.VarChar, 120), //new SqlParameter("@clicks", SqlDbType.Int,4), new SqlParameter("@productTypeId", SqlDbType.Int, 4) }; parameters[0].Value = model.productid; //parameters[1].Value = model.loginName; parameters[1].Value = model.Chineseintroduced; parameters[2].Value = model.Englishintroduction; // parameters[4].Value = model.createdate; parameters[3].Value = model.htmlurl; parameters[4].Value = model.productName; //parameters[6].Value = model.clicks; parameters[5].Value = model.productTypeId; int rows = DBHelper.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private bool NewMethod(bool flag) { dominM = dominBll.GetModel(int.Parse(ViewState["productid"].ToString())); //dominM.productid = ; if (string.IsNullOrEmpty(dominM.htmlurl)) { dominM.htmlurl = dominM.loginName + "/product" + dominM.loginName + ".htm"; //dominM.htmlurl = dominM.loginName + "/" + DateTime.Now.ToString("yyyyMMdd") + "_" + dominM.productid + ".shtml"; } dominM.Chineseintroduced = txtChina.Text.Trim(); dominM.Englishintroduction = txtEnglish.Text.Trim(); dominM.productTypeId = int.Parse(ddlName.SelectedValue.ToString()); dominM.productName = ddlName.SelectedItem.Text.ToString(); //dominM.loginName = loginName; if (dominBll.Update(dominM)) { if (ViewState["update"].Equals("true")) { imgBLL.DeleteByProductId(dominM.productid); if (DataList1.Items.Count > 0) { foreach (DataListItem item in DataList1.Items) { CheckBox ck = (CheckBox)item.FindControl("chckimage"); HiddenField fid = (HiddenField)item.FindControl("HiddenField1"); imgM.productid = dominM.productid; imgM.imgName = fid.Value.Trim(); imgM.imgexplain = "图片描述暂无"; if (imgBLL.Add(imgM) > 0) { flag = true; } } } else { flag = true; } } else { flag = true; } } return(flag); }
/// <summary> /// 得到一个对象实体 /// </summary> public ProductDominM GetModel(int productTypeId, string loginName) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 productid,loginName,Chineseintroduced,Englishintroduction,createdate,htmlurl,clicks,productTypeId from produceDomin "); strSql.Append(" where productTypeId=@productid and loginName=@loginname order by createdate desc"); SqlParameter[] parameters = { new SqlParameter("@productid", SqlDbType.Int, 4), new SqlParameter("@loginname", SqlDbType.VarChar, 50) }; parameters[0].Value = productTypeId; parameters[1].Value = loginName; ProductDominM model = new ProductDominM(); DataSet ds = DBHelper.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["productid"].ToString() != "") { model.productid = int.Parse(ds.Tables[0].Rows[0]["productid"].ToString()); } model.loginName = ds.Tables[0].Rows[0]["loginName"].ToString(); model.Chineseintroduced = ds.Tables[0].Rows[0]["Chineseintroduced"].ToString(); model.Englishintroduction = ds.Tables[0].Rows[0]["Englishintroduction"].ToString(); if (ds.Tables[0].Rows[0]["createdate"].ToString() != "") { model.createdate = DateTime.Parse(ds.Tables[0].Rows[0]["createdate"].ToString()); } model.htmlurl = ds.Tables[0].Rows[0]["htmlurl"].ToString(); if (ds.Tables[0].Rows[0]["clicks"].ToString() != "") { model.clicks = int.Parse(ds.Tables[0].Rows[0]["clicks"].ToString()); } if (ds.Tables[0].Rows[0]["productTypeId"].ToString() != "") { model.productTypeId = int.Parse(ds.Tables[0].Rows[0]["productTypeId"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ProductDominM model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into produceDomin("); strSql.Append("loginName,Chineseintroduced,Englishintroduction,createdate,htmlurl,clicks,productTypeId,productName)"); strSql.Append(" values ("); strSql.Append("@loginName,@Chineseintroduced,@Englishintroduction,getdate(),@htmlurl,0,@productTypeId,@productName)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@loginName", SqlDbType.VarChar, 50), new SqlParameter("@Chineseintroduced", SqlDbType.Text), new SqlParameter("@Englishintroduction", SqlDbType.Text), //new SqlParameter("@createdate", SqlDbType.DateTime), new SqlParameter("@htmlurl", SqlDbType.VarChar, 120), //new SqlParameter("@clicks", SqlDbType.Int,4), new SqlParameter("@productTypeId", SqlDbType.Int, 4), new SqlParameter("@productName", SqlDbType.VarChar, 120) }; parameters[0].Value = model.loginName; parameters[1].Value = model.Chineseintroduced; parameters[2].Value = model.Englishintroduction; // parameters[3].Value = model.createdate; parameters[3].Value = model.htmlurl; //parameters[5].Value = model.clicks; parameters[4].Value = model.productTypeId; parameters[5].Value = model.productName; object obj = DBHelper.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 获得数据列表 /// </summary> public List <ProductDominM> DataTableToList(DataTable dt) { List <ProductDominM> modelList = new List <ProductDominM>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { ProductDominM model; for (int n = 0; n < rowsCount; n++) { model = new ProductDominM(); if (dt.Rows[n]["productid"].ToString() != "") { model.productid = int.Parse(dt.Rows[n]["productid"].ToString()); } model.loginName = dt.Rows[n]["loginName"].ToString(); model.Chineseintroduced = dt.Rows[n]["Chineseintroduced"].ToString(); model.Englishintroduction = dt.Rows[n]["Englishintroduction"].ToString(); if (dt.Rows[n]["createdate"].ToString() != "") { model.createdate = DateTime.Parse(dt.Rows[n]["createdate"].ToString()); } model.htmlurl = dt.Rows[n]["htmlurl"].ToString(); if (dt.Rows[n]["clicks"].ToString() != "") { model.clicks = int.Parse(dt.Rows[n]["clicks"].ToString()); } if (dt.Rows[n]["productTypeId"].ToString() != "") { model.productTypeId = int.Parse(dt.Rows[n]["productTypeId"].ToString()); } modelList.Add(model); } } return(modelList); }
private string content(string id, string loginName) { StringBuilder str = new StringBuilder(); string[] strId = id.Split(','); for (int j = 0; j < strId.Length - 1; j++) { doM = doBll.GetModel(int.Parse(strId[j])); if (doM != null) { str.Append("<div id=\"cy_con_" + strId[j] + "\">"); str.Append("<div class=\"industry-con1\">"); str.Append(doM.Chineseintroduced.ToString() + "</div>"); str.Append("<div class=\"industry-con2\">"); str.Append(doM.Englishintroduction.ToString() + "</div>"); ProductImgBLL imbll = new ProductImgBLL(); ProductImgM imM = new ProductImgM(); if (doM.productid > 0) { DataSet ds = imbll.GetList(" productid=" + doM.productid); if ((ds != null) && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; if (i == 0) { str.Append("<div class=\"industry-img-left\">");//大图width=\"651\" height=\"399\" str.Append("<img src=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\" id=\"placeholder" + doM.productid + "\" />"); str.Append("</div>"); } else { str.Append("<div style='display:none;' class=\"industry-img-left\">");//大图width=\"651\" height=\"399\" str.Append("<img src=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\" style=\"display:none\" id=\"placeholder" + doM.productid + "\" />"); str.Append("</div>"); } } } if ((ds != null) && ds.Tables[0].Rows.Count > 0) { str.Append("<div class=\"industry-img-right\" id=\"ISL_Cont_1\"> <ul>"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; str.Append("<li>"); str.Append("<a href=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\" onmouseover=\"showPic(this," + doM.productid + ");return false;\" alt='点击查看大图' target=\"_blank\">"); str.Append("<img alt='点击查看大图' src=\"http://dp.topfo.com/img/" + loginName + "/" + dr["imgName"].ToString() + "\" />"); str.Append("</a></li>"); } str.Append("</ul></div>"); } } str.Append("</div>"); } else { str.Append("<div id=\"cy_con_" + strId[j] + "\">"); str.Append("暂无数据"); str.Append("</div>"); } } return(str.ToString()); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(ProductDominM model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ProductDominM model) { return(dal.Add(model)); }