//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_albums", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 BLL.common_albums bll = new BLL.common_albums(); Model.common_albums model = bll.GetModel(this.id); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.rc_title = Convert.ToString(txtrc_title.Text); model.rc_type = Convert.ToInt32(txtrc_type.Text); model.rc_data_id = Convert.ToInt32(txtrc_data_id.Text); model.thumb_path = Convert.ToString(txtthumb_path.Text); model.original_path = Convert.ToString(txtoriginal_path.Text); model.remark = Convert.ToString(txtremark.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.common_albums GetModel(int Top, string whereStr, string filedOrder) { DataTable dt = dal.GetList(Top, whereStr, filedOrder).Tables[0]; Model.common_albums model = dt.Rows.Count > 0 ? DataRowToModel(dt.Rows[0]) : null; return(model); }
/// <summary> /// 获得Model /// </summary> /// <param name="whereStr"></param> /// <returns></returns> public Model.common_albums GetModel(string whereStr) { DataTable dt = dal.GetList(whereStr).Tables[0]; Model.common_albums model = dt.Rows.Count > 0 ? DataRowToModel(dt.Rows[0]) : null; return(model); }
private bool DoAdd() { Model.common_albums model = new Model.common_albums(); BLL.common_albums bll = new BLL.common_albums(); model.group_id = (int)EnumCollection.img_group.系统默认二维码logo; model.rc_type = 0; model.rc_data_id = 0; model.thumb_path = ""; model.original_path = this.txtad_data_img.Text.Trim(); model.remark = ""; model.add_time = System.DateTime.Now; int id = bll.Add(model); if (id > 0) { AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加系统默认二维码logo,主键:" + id); //记录日志 return(true); } else { return(false); } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { BLL.common_albums bll = new BLL.common_albums(); Model.common_albums model = bll.GetModel(" group_id = " + (int)EnumCollection.img_group.系统默认二维码logo); if (model != null) { ChkAdminLevel("_default_logo", EnumCollection.ActionEnum.Modify.ToString()); //检查权限 if (!DoEdit(model.id)) { JscriptMsg("保存过程中发生错误!", ""); return; } JscriptMsg("修改系统默认二维码logo成功!", ""); } else { ChkAdminLevel("_default_logo", EnumCollection.ActionEnum.Add.ToString()); //检查权限 if (!DoAdd()) { JscriptMsg("保存过程中发生错误!", ""); return; } JscriptMsg("添加系统默认二维码logo成功!", ""); } }
private void ShowInfo() { BLL.common_albums bll = new BLL.common_albums(); Model.common_albums model = bll.GetModel(" group_id = " + (int)EnumCollection.img_group.系统默认二维码logo); if (model != null) { this.txtad_data_img.Text = model.original_path; } }
private bool DoAdd() { Model.common_article model = new Model.common_article(); BLL.common_article bll = new BLL.common_article(); model.group_id = (int)EnumCollection.article_group.精品微课问题讨论; model.user_id = 0; model.category_id = this.chapter; model.title = Convert.ToString(txttitle.Text); model.subtitle = ""; model.contents = Convert.ToString(txtcontents.Text); model.img_src = ""; model.click = 0; model.upvote = 0; model.status = (int)EnumCollection.examine_status.审核通过; model.add_time = System.DateTime.Now; int id = bll.Add(model); if (id > 0) { #region 保存图片 string[] albumArr = Request.Form.GetValues("hid_photo_name"); if (albumArr != null && albumArr.Length > 0) { for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); if (imgArr.Length == 3) { var img = new Model.common_albums { group_id = (int)EnumCollection.img_group.精品微课问题讨论图片, rc_type = 0, rc_data_id = id, add_time = DateTime.Now, original_path = imgArr[1], thumb_path = imgArr[2], remark = "" }; new BLL.common_albums().Add(img); } } } #endregion 保存图片 AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加问题讨论信息,主键:" + id); //记录日志 return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.common_albums model) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"Insert Into ybd_common_albums( group_id ,rc_title ,rc_type ,rc_data_id ,thumb_path ,original_path ,remark ,add_time ) Values ( @group_id ,@rc_title ,@rc_type ,@rc_data_id ,@thumb_path ,@original_path ,@remark ,@add_time ); SELECT @@IDENTITY;"); SqlParameter[] parameters = { new SqlParameter("@group_id", SqlDbType.Int, 4) , new SqlParameter("@rc_title", SqlDbType.NVarChar, 50) , new SqlParameter("@rc_type", SqlDbType.Int, 4) , new SqlParameter("@rc_data_id", SqlDbType.Int, 4) , new SqlParameter("@thumb_path", SqlDbType.NVarChar, 255) , new SqlParameter("@original_path", SqlDbType.NVarChar, 255) , new SqlParameter("@remark", SqlDbType.NVarChar, 500) , new SqlParameter("@add_time", SqlDbType.DateTime, 8) }; parameters[0].Value = model.group_id; parameters[1].Value = model.rc_title; parameters[2].Value = model.rc_type; parameters[3].Value = model.rc_data_id; parameters[4].Value = model.thumb_path; parameters[5].Value = model.original_path; parameters[6].Value = model.remark; parameters[7].Value = model.add_time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private bool DoEdit(int id) { BLL.common_article bll = new BLL.common_article(); Model.common_article model = bll.GetModel(this.id); model.group_id = (int)EnumCollection.article_group.精品微课问题讨论; model.user_id = 0; model.category_id = this.chapter; model.title = Convert.ToString(txttitle.Text); model.contents = Convert.ToString(txtcontents.Text); if (bll.Update(model)) { #region 保存图片 string[] albumArr = Request.Form.GetValues("hid_photo_name"); if (albumArr != null && albumArr.Length > 0) { DBUtility.DbHelperSQL.ExecuteSql("delete ybd_common_albums where rc_guid=" + model.id + " and group_id=" + (int)EnumCollection.img_group.精品微课问题讨论图片);//删除图片 for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); if (imgArr.Length == 3) { var img = new Model.common_albums { group_id = (int)EnumCollection.img_group.精品微课问题讨论图片, rc_type = 0, rc_data_id = id, add_time = DateTime.Now, original_path = imgArr[1], thumb_path = imgArr[2], remark = "" }; new BLL.common_albums().Add(img); } } } #endregion 保存图片 AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改问题讨论信息,主键:" + model.id); //记录日志 return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.common_albums DataRowToModel(DataRow row) { Model.common_albums model = new Model.common_albums(); if (row != null) { if (row["id"] != null) //&& row["id"].ToString() != "" { model.id = Convert.ToInt32(row["id"]); } if (row["group_id"] != null) //&& row["group_id"].ToString() != "" { model.group_id = Convert.ToInt32(row["group_id"]); } if (row["rc_title"] != null) //&& row["rc_title"].ToString() != "" { model.rc_title = Convert.ToString(row["rc_title"]); } if (row["rc_type"] != null) //&& row["rc_type"].ToString() != "" { model.rc_type = Convert.ToInt32(row["rc_type"]); } if (row["rc_data_id"] != null) //&& row["rc_data_id"].ToString() != "" { model.rc_data_id = Convert.ToInt32(row["rc_data_id"]); } if (row["thumb_path"] != null) //&& row["thumb_path"].ToString() != "" { model.thumb_path = Convert.ToString(row["thumb_path"]); } if (row["original_path"] != null) //&& row["original_path"].ToString() != "" { model.original_path = Convert.ToString(row["original_path"]); } if (row["remark"] != null) //&& row["remark"].ToString() != "" { model.remark = Convert.ToString(row["remark"]); } if (row["add_time"] != null && row["add_time"].ToString() != "") { model.add_time = Convert.ToDateTime(row["add_time"]); } return(model); } else { return(null); } }
private bool DoEdit() { BLL.goods_goods bll = new BLL.goods_goods(); Model.goods_goods model = bll.GetModel(this.id); model.ct_id = 0; model.group_id = Convert.ToInt32(rbtnGroup.SelectedValue); model.category_id = Convert.ToInt32(ddlCategory.SelectedValue); model.title = Convert.ToString(txttitle.Text); model.subtitle = Convert.ToString(txtsubtitle.Text); model.img_src = Convert.ToString(txtimg_src.Text); model.oprice = Convert.ToDecimal(txtoprice.Text); model.price = Convert.ToDecimal(txtprice.Text); model.parameters = Convert.ToString(txtparameters.Text); model.details = Convert.ToString(txtdetails.Text); model.sales_num = Convert.ToInt32(txtsales_num.Text); model.status = Convert.ToInt32(rbtnStatus.SelectedValue); model.sj_time = model.status == 1 ? System.DateTime.Now : model.sj_time; model.xj_time = model.status == 2 ? System.DateTime.Now : model.sj_time; if (bll.Update(model)) { #region 添加轮播图 new BLL.common_albums().Delete(" group_id = " + (int)EnumCollection.img_group.商品轮播图 + " and rc_data_id = " + model.id); string[] albumArr = Request.Form.GetValues("hid_photo_name"); if (albumArr != null && albumArr.Length > 0) { for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); if (imgArr.Length == 3) { Model.common_albums pic_model = new Model.common_albums(); pic_model = new Model.common_albums() { group_id = (int)EnumCollection.img_group.商品轮播图, rc_data_id = this.id, rc_type = 0, original_path = imgArr[1], thumb_path = imgArr[2], remark = "", add_time = DateTime.Now }; new BLL.common_albums().Add(pic_model); } } } #endregion AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改商品信息,主键:" + this.id); //记录日志 return(true); } return(false); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.common_albums model) { StringBuilder strSql = new StringBuilder(); strSql.Append(@"UPDATE ybd_common_albums SET group_id = @group_id ,rc_title = @rc_title ,rc_type = @rc_type ,rc_data_id = @rc_data_id ,thumb_path = @thumb_path ,original_path = @original_path ,remark = @remark ,add_time = @add_time WHERE id = @id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) , new SqlParameter("@group_id", SqlDbType.Int, 4) , new SqlParameter("@rc_title", SqlDbType.NVarChar, 50) , new SqlParameter("@rc_type", SqlDbType.Int, 4) , new SqlParameter("@rc_data_id", SqlDbType.Int, 4) , new SqlParameter("@thumb_path", SqlDbType.NVarChar, 255) , new SqlParameter("@original_path", SqlDbType.NVarChar, 255) , new SqlParameter("@remark", SqlDbType.NVarChar, 500) , new SqlParameter("@add_time", SqlDbType.DateTime, 8) }; parameters[0].Value = model.id; parameters[1].Value = model.group_id; parameters[2].Value = model.rc_title; parameters[3].Value = model.rc_type; parameters[4].Value = model.rc_data_id; parameters[5].Value = model.thumb_path; parameters[6].Value = model.original_path; parameters[7].Value = model.remark; parameters[8].Value = model.add_time; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private bool DoEdit(int id) { BLL.common_albums bll = new BLL.common_albums(); Model.common_albums model = bll.GetModel(id); model.original_path = this.txtad_data_img.Text.Trim(); if (bll.Update(model)) { AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改系统默认二维码logo,主键:" + id); //记录日志 return(true); } else { return(false); } }
private void BindInfo() { BLL.common_albums bll = new BLL.common_albums(); Model.common_albums model = bll.GetModel(this.id); if (model == null) { JscriptMsg("信息不存在或已被删除!", "back"); return; } txtgroup_id.Text = model.group_id + ""; txtrc_title.Text = model.rc_title + ""; txtrc_type.Text = model.rc_type + ""; txtrc_data_id.Text = model.rc_data_id + ""; txtthumb_path.Text = model.thumb_path + ""; txtoriginal_path.Text = model.original_path + ""; txtremark.Text = model.remark + ""; txtadd_time.Text = model.add_time + ""; }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_common_albums", EnumCollection.ActionEnum.Add.ToString()); //检查权限 #region string strError = string.Empty; if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4) { strError += "分组id为空或超出长度![br]"; } if (txtrc_title.Text.Trim() == "" || txtrc_title.Text.Trim().Length > 50) { strError += "标题为空或超出长度![br]"; } if (txtrc_type.Text.Trim() == "" || txtrc_type.Text.Trim().Length > 4) { strError += "关联内容分类id为空或超出长度![br]"; } if (txtrc_data_id.Text.Trim() == "" || txtrc_data_id.Text.Trim().Length > 4) { strError += "关联内容数据ID为空或超出长度![br]"; } if (txtthumb_path.Text.Trim() == "" || txtthumb_path.Text.Trim().Length > 255) { strError += "缩略图地址为空或超出长度![br]"; } if (txtoriginal_path.Text.Trim() == "" || txtoriginal_path.Text.Trim().Length > 255) { strError += "原图地址为空或超出长度![br]"; } if (txtremark.Text.Trim() == "" || txtremark.Text.Trim().Length > 500) { 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.common_albums model = new Model.common_albums(); BLL.common_albums bll = new BLL.common_albums(); model.group_id = Convert.ToInt32(txtgroup_id.Text); model.rc_title = Convert.ToString(txtrc_title.Text); model.rc_type = Convert.ToInt32(txtrc_type.Text); model.rc_data_id = Convert.ToInt32(txtrc_data_id.Text); model.thumb_path = Convert.ToString(txtthumb_path.Text); model.original_path = Convert.ToString(txtoriginal_path.Text); model.remark = Convert.ToString(txtremark.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.common_albums model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.common_albums model) { return(dal.Update(model)); }
private bool DoAdd() { BLL.goods_goods bll = new BLL.goods_goods(); Model.goods_goods model = new Model.goods_goods(); model.ct_id = 0; model.group_id = Convert.ToInt32(rbtnGroup.SelectedValue); model.category_id = Convert.ToInt32(ddlCategory.SelectedValue); model.title = Convert.ToString(txttitle.Text); model.subtitle = Convert.ToString(txtsubtitle.Text); model.img_src = Convert.ToString(txtimg_src.Text); model.oprice = Convert.ToDecimal(txtoprice.Text); model.price = Convert.ToDecimal(txtprice.Text); model.parameters = Convert.ToString(txtparameters.Text); model.details = Convert.ToString(txtdetails.Text); model.sales_num = Convert.ToInt32(txtsales_num.Text); model.status = Convert.ToInt32(rbtnStatus.SelectedValue); model.sj_time = System.DateTime.Now; model.xj_time = System.DateTime.Now; model.add_time = System.DateTime.Now; int row = bll.Add(model); if (row > 0) { #region 添加轮播图 string[] albumArr = Request.Form.GetValues("hid_photo_name"); if (albumArr != null && albumArr.Length > 0) { for (int i = 0; i < albumArr.Length; i++) { string[] imgArr = albumArr[i].Split('|'); if (imgArr.Length == 3) { Model.common_albums pic_model = new Model.common_albums(); pic_model = new Model.common_albums() { group_id = (int)EnumCollection.img_group.商品轮播图, rc_data_id = row, rc_type = 0, original_path = imgArr[1], thumb_path = imgArr[2], remark = "", add_time = DateTime.Now }; new BLL.common_albums().Add(pic_model); } } } #endregion #region 添加默认规格 BLL.goods_spec_item specBll = new BLL.goods_spec_item(); Model.goods_spec_item item = new Model.goods_spec_item(); item.name = "规格"; item.parent_id = 0; item.goods_id = row; item.sort = 1; int spec = specBll.Add(item); if (spec > 0) { item = new Model.goods_spec_item(); item.name = "平装"; item.parent_id = spec; item.goods_id = row; item.sort = 1; int subspec = specBll.Add(item); if (subspec > 0) { Model.goods_spec_type type = new Model.goods_spec_type(); type.goods_id = row; type.price = model.price; type.stock = 100; type.spec = subspec; if (new BLL.goods_spec_type().Add(type) <= 0) { specBll.DeleteList(spec + "," + subspec); } } else { specBll.Delete(spec); } } #endregion AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "添加商品信息,主键:" + row); //记录日志 return(true); } return(false); }