//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_company_info", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.company_info bll = new BLL.company_info(); Model.company_info model = bll.GetModel(this.id); model.logo = Convert.ToString(txtlogo.Text); model.title = Convert.ToString(txttitle.Text); model.img_url = Convert.ToString(txtimg_url.Text); model.video_thumb_img = Convert.ToString(txtvideo_thumb_img.Text); model.video_url = Convert.ToString(txtvideo_url.Text); model.about_us = Convert.ToString(txtabout_us.Text); model.who_are_we_img = Convert.ToString(txtwho_are_we_img.Text); model.who_are_we = Convert.ToString(txtwho_are_we.Text); model.what_can_we_do = Convert.ToString(txtwhat_can_we_do.Text); model.what_can_we_do_img = Convert.ToString(txtwhat_can_we_do_img.Text); model.we_team_img = Convert.ToString(txtwe_team_img.Text); model.we_team = Convert.ToString(txtwe_team.Text); model.contact_us = Convert.ToString(txtcontact_us.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改集团子公司信息信息,主键:" + id); //记录日志 JscriptMsg("修改集团子公司信息信息成功!", "Manage.aspx"); } else { JscriptMsg("保存过程中发生错误!", ""); } }
/// <summary> /// 获得Model /// </summary> /// <param name="Top">大于0取前几行数据,否则取全部</param> /// <param name="whereStr">where条件</param> /// <param name="filedOrder">排序字段Order By + filedOrder (不可为空)</param> /// <returns></returns> public Model.company_info GetModel(int Top, string whereStr, string filedOrder) { DataTable dt = dal.GetList(Top, whereStr, filedOrder).Tables[0]; Model.company_info model = dt.Rows.Count > 0 ? DataRowToModel(dt.Rows[0]) : null; return(model); }
/// <summary> /// 获得Model /// </summary> /// <param name="whereStr"></param> /// <returns></returns> public Model.company_info GetModel(string whereStr) { DataTable dt = dal.GetList(whereStr).Tables[0]; Model.company_info model = dt.Rows.Count > 0 ? DataRowToModel(dt.Rows[0]) : null; return(model); }
private void BindInfo() { BLL.company_info bll = new BLL.company_info(); Model.company_info model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtlogo.Text = model.logo + ""; txttitle.Text = model.title + ""; txtimg_url.Text = model.img_url + ""; txtvideo_thumb_img.Text = model.video_thumb_img + ""; txtvideo_url.Text = model.video_url + ""; txtabout_us.Text = model.about_us + ""; txtwho_are_we_img.Text = model.who_are_we_img + ""; txtwho_are_we.Text = model.who_are_we + ""; txtwhat_can_we_do.Text = model.what_can_we_do + ""; txtwhat_can_we_do_img.Text = model.what_can_we_do_img + ""; txtwe_team_img.Text = model.we_team_img + ""; txtwe_team.Text = model.we_team + ""; txtcontact_us.Text = model.contact_us + ""; txtadd_time.Text = model.add_time + ""; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.company_info DataRowToModel(DataRow row) { Model.company_info model = new Model.company_info(); if (row != null) { if (row["id"] != null) //&& row["id"].ToString() != "" { model.id = Convert.ToInt32(row["id"]); } if (row["logo"] != null) //&& row["logo"].ToString() != "" { model.logo = Convert.ToString(row["logo"]); } if (row["title"] != null) //&& row["title"].ToString() != "" { model.title = Convert.ToString(row["title"]); } if (row["img_url"] != null) //&& row["img_url"].ToString() != "" { model.img_url = Convert.ToString(row["img_url"]); } if (row["video_thumb_img"] != null) //&& row["video_thumb_img"].ToString() != "" { model.video_thumb_img = Convert.ToString(row["video_thumb_img"]); } if (row["video_url"] != null) //&& row["video_url"].ToString() != "" { model.video_url = Convert.ToString(row["video_url"]); } if (row["about_us"] != null) //&& row["about_us"].ToString() != "" { model.about_us = Convert.ToString(row["about_us"]); } if (row["who_are_we_img"] != null) //&& row["who_are_we_img"].ToString() != "" { model.who_are_we_img = Convert.ToString(row["who_are_we_img"]); } if (row["who_are_we"] != null) //&& row["who_are_we"].ToString() != "" { model.who_are_we = Convert.ToString(row["who_are_we"]); } if (row["what_can_we_do"] != null) //&& row["what_can_we_do"].ToString() != "" { model.what_can_we_do = Convert.ToString(row["what_can_we_do"]); } if (row["what_can_we_do_img"] != null) //&& row["what_can_we_do_img"].ToString() != "" { model.what_can_we_do_img = Convert.ToString(row["what_can_we_do_img"]); } if (row["we_team_img"] != null) //&& row["we_team_img"].ToString() != "" { model.we_team_img = Convert.ToString(row["we_team_img"]); } if (row["we_team"] != null) //&& row["we_team"].ToString() != "" { model.we_team = Convert.ToString(row["we_team"]); } if (row["contact_us"] != null) //&& row["contact_us"].ToString() != "" { model.contact_us = Convert.ToString(row["contact_us"]); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = Convert.ToDateTime(row["add_time"]); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.company_info model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.company_info model) { return(dal.Add(model)); }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_company_info", EnumCollection.ActionEnum.Add.ToString()); //检查权限 #region string strError = string.Empty; if (txtlogo.Text.Trim() == "" || txtlogo.Text.Trim().Length > 255) { strError += "logo为空或超出长度![br]"; } if (txttitle.Text.Trim() == "" || txttitle.Text.Trim().Length > 50) { strError += "标题为空或超出长度![br]"; } if (txtimg_url.Text.Trim() == "" || txtimg_url.Text.Trim().Length > 255) { strError += "封面图为空或超出长度![br]"; } if (txtvideo_thumb_img.Text.Trim() == "" || txtvideo_thumb_img.Text.Trim().Length > 255) { strError += "视频缩略图为空或超出长度![br]"; } if (txtvideo_url.Text.Trim() == "" || txtvideo_url.Text.Trim().Length > 255) { strError += "视频为空或超出长度![br]"; } if (txtabout_us.Text.Trim() == "" || txtabout_us.Text.Trim().Length > 16) { strError += "关于我们为空或超出长度![br]"; } if (txtwho_are_we_img.Text.Trim() == "" || txtwho_are_we_img.Text.Trim().Length > 255) { strError += "我们是谁左侧图为空或超出长度![br]"; } if (txtwho_are_we.Text.Trim() == "" || txtwho_are_we.Text.Trim().Length > 255) { strError += "我们是谁文字为空或超出长度![br]"; } if (txtwhat_can_we_do.Text.Trim() == "" || txtwhat_can_we_do.Text.Trim().Length > 4000) { strError += "我们能做什么文字[[中文,英文],[中文,英文],[中文,英文],[中文,英文]]为空或超出长度![br]"; } if (txtwhat_can_we_do_img.Text.Trim() == "" || txtwhat_can_we_do_img.Text.Trim().Length > 255) { strError += "我们能做什么右侧图为空或超出长度![br]"; } if (txtwe_team_img.Text.Trim() == "" || txtwe_team_img.Text.Trim().Length > 255) { strError += "我们的团队左侧图为空或超出长度![br]"; } if (txtwe_team.Text.Trim() == "" || txtwe_team.Text.Trim().Length > 500) { strError += "我们的团队文字为空或超出长度![br]"; } if (txtcontact_us.Text.Trim() == "" || txtcontact_us.Text.Trim().Length > 16) { strError += "联系我们为空或超出长度![br]"; } if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8) { strError += "添加时间为空或超出长度![br]"; } if (strError != string.Empty) { JscriptMsg(strError, "", "Error"); return; } #endregion Model.company_info model = new Model.company_info(); BLL.company_info bll = new BLL.company_info(); model.logo = Convert.ToString(txtlogo.Text); model.title = Convert.ToString(txttitle.Text); model.img_url = Convert.ToString(txtimg_url.Text); model.video_thumb_img = Convert.ToString(txtvideo_thumb_img.Text); model.video_url = Convert.ToString(txtvideo_url.Text); model.about_us = Convert.ToString(txtabout_us.Text); model.who_are_we_img = Convert.ToString(txtwho_are_we_img.Text); model.who_are_we = Convert.ToString(txtwho_are_we.Text); model.what_can_we_do = Convert.ToString(txtwhat_can_we_do.Text); model.what_can_we_do_img = Convert.ToString(txtwhat_can_we_do_img.Text); model.we_team_img = Convert.ToString(txtwe_team_img.Text); model.we_team = Convert.ToString(txtwe_team.Text); model.contact_us = Convert.ToString(txtcontact_us.Text); model.add_time = Convert.ToDateTime(txtadd_time.Text); int id = bll.Add(model); if (id > 0) { AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加集团子公司信息信息,主键:" + id); //记录日志 JscriptMsg("添加集团子公司信息信息成功!", "Manage.aspx", ""); } else { JscriptMsg("保存过程中发生错误!", ""); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.company_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"Insert Into ybd_company_info( logo ,title ,img_url ,video_thumb_img ,video_url ,about_us ,who_are_we_img ,who_are_we ,what_can_we_do ,what_can_we_do_img ,we_team_img ,we_team ,contact_us ,add_time ) Values ( @logo ,@title ,@img_url ,@video_thumb_img ,@video_url ,@about_us ,@who_are_we_img ,@who_are_we ,@what_can_we_do ,@what_can_we_do_img ,@we_team_img ,@we_team ,@contact_us ,@add_time ); SELECT @@IDENTITY;"); SqlParameter[] parameters = { new SqlParameter("@logo", SqlDbType.NVarChar, 255) , new SqlParameter("@title", SqlDbType.NVarChar, 50) , new SqlParameter("@img_url", SqlDbType.NVarChar, 255) , new SqlParameter("@video_thumb_img", SqlDbType.NVarChar, 255) , new SqlParameter("@video_url", SqlDbType.NVarChar, 255) , new SqlParameter("@about_us", SqlDbType.NText) , new SqlParameter("@who_are_we_img", SqlDbType.NVarChar, 255) , new SqlParameter("@who_are_we", SqlDbType.NVarChar, 255) , new SqlParameter("@what_can_we_do", SqlDbType.NVarChar, 4000) , new SqlParameter("@what_can_we_do_img", SqlDbType.NVarChar, 255) , new SqlParameter("@we_team_img", SqlDbType.NVarChar, 255) , new SqlParameter("@we_team", SqlDbType.NVarChar, 500) , new SqlParameter("@contact_us", SqlDbType.NText) , new SqlParameter("@add_time", SqlDbType.DateTime, 8) }; parameters[0].Value = model.logo; parameters[1].Value = model.title; parameters[2].Value = model.img_url; parameters[3].Value = model.video_thumb_img; parameters[4].Value = model.video_url; parameters[5].Value = model.about_us; parameters[6].Value = model.who_are_we_img; parameters[7].Value = model.who_are_we; parameters[8].Value = model.what_can_we_do; parameters[9].Value = model.what_can_we_do_img; parameters[10].Value = model.we_team_img; parameters[11].Value = model.we_team; parameters[12].Value = model.contact_us; parameters[13].Value = model.add_time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.company_info model) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"UPDATE ybd_company_info SET logo = @logo ,title = @title ,img_url = @img_url ,video_thumb_img = @video_thumb_img ,video_url = @video_url ,about_us = @about_us ,who_are_we_img = @who_are_we_img ,who_are_we = @who_are_we ,what_can_we_do = @what_can_we_do ,what_can_we_do_img = @what_can_we_do_img ,we_team_img = @we_team_img ,we_team = @we_team ,contact_us = @contact_us ,add_time = @add_time WHERE id = @id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) , new SqlParameter("@logo", SqlDbType.NVarChar, 255) , new SqlParameter("@title", SqlDbType.NVarChar, 50) , new SqlParameter("@img_url", SqlDbType.NVarChar, 255) , new SqlParameter("@video_thumb_img", SqlDbType.NVarChar, 255) , new SqlParameter("@video_url", SqlDbType.NVarChar, 255) , new SqlParameter("@about_us", SqlDbType.NText) , new SqlParameter("@who_are_we_img", SqlDbType.NVarChar, 255) , new SqlParameter("@who_are_we", SqlDbType.NVarChar, 255) , new SqlParameter("@what_can_we_do", SqlDbType.NVarChar, 4000) , new SqlParameter("@what_can_we_do_img", SqlDbType.NVarChar, 255) , new SqlParameter("@we_team_img", SqlDbType.NVarChar, 255) , new SqlParameter("@we_team", SqlDbType.NVarChar, 500) , new SqlParameter("@contact_us", SqlDbType.NText) , new SqlParameter("@add_time", SqlDbType.DateTime, 8) }; parameters[0].Value = model.id; parameters[1].Value = model.logo; parameters[2].Value = model.title; parameters[3].Value = model.img_url; parameters[4].Value = model.video_thumb_img; parameters[5].Value = model.video_url; parameters[6].Value = model.about_us; parameters[7].Value = model.who_are_we_img; parameters[8].Value = model.who_are_we; parameters[9].Value = model.what_can_we_do; parameters[10].Value = model.what_can_we_do_img; parameters[11].Value = model.we_team_img; parameters[12].Value = model.we_team; parameters[13].Value = model.contact_us; parameters[14].Value = model.add_time; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }