private void get_pro_city(HttpContext context) { DataSet cityList = new BLL.product().GetCityList("status=2"); DataTable dt = cityList.Tables[0]; context.Response.Write(JsonHelper.DataTableToJSON(dt)); }
private bool DoEdit(int _id) { try { BLL.product bll = new BLL.product(); Model.product model = bll.GetModel(_id); model.title = txtTitle.Text; model.category = Convert.ToInt32(ddlCategoryId.SelectedValue); model.sort = Convert.ToInt32(txtSort.Text); model.city = txtCity.Text; model.lat = txtLat.Text; model.lon = txtLon.Text; model.addr = txtAddr.Text; model.cont = txtCont.Text; model.add_time = Convert.ToDateTime(txtAddTime.Text); model.pass_time = Convert.ToDateTime(txtPassTime.Text); if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改产品信息:" + model.title); //记录日志 return(true); } } catch { return(false); } return(false); }
private void get_pro_list(HttpContext context) { int page = DTRequest.GetInt("page", 1); int category = DTRequest.GetInt("category", 0); int uid = DTRequest.GetInt("uid", 0); string keywords = DTRequest.GetString("keywords"); string city = DTRequest.GetString("city"); int count = 0; int pageSize = 8; int sum = 0; if (uid == 0) { sum = new BLL.product().GetCount("status=2 and city=" + (city == "未知" ? "city" : "'" + city + "'") + " and category=" + (category == 0 ? "category" : category.ToString())); } else { sum = new BLL.product().GetCount("status=2 and user_id=" + uid); } if ((page - 1) * pageSize >= sum) { //没有更多数据 context.Response.Write("{\"status\":0,\"msg\":\"没有更多数据\"}"); return; } DataSet ds = new DataSet(); if (uid == 0) { ds = new BLL.product().GetList(pageSize, page, "status=2 and city=" + (city == "未知" ? "city" : "'" + city + "'") + " and category=" + (category == 0 ? "category" : category.ToString()) + " and title like '%" + keywords + "%'", "pass_time desc", out count); } else { ds = new BLL.product().GetList(pageSize, page, "status=2 and user_id=" + uid, "pass_time desc", out count); } DataTable dt = ds.Tables[0]; dt.Columns.Add("zan", typeof(int)); dt.Columns.Add("collect", typeof(int)); dt.Columns.Add("view", typeof(int)); foreach (DataRow dr in dt.Rows) { dr["view"] = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=1 and type=1"); dr["collect"] = new BLL.news_commend().GetCount("news_id=" + dr["id"].ToString()); dr["zan"] = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=1 and type=2"); } string strJson = DTcms.Common.JsonHelper.DataTableToJSON(ds.Tables[0]); context.Response.Write(strJson); }
private void get_pm_proList(HttpContext context) { int uid = DTRequest.GetInt("uid", 0); DataTable dt = new BLL.product().GetList(0, "user_id=" + uid, "add_time desc").Tables[0]; foreach (DataRow dr in dt.Rows) { dr["cont"] = dr["cont"].ToString().Length > 50 ? dr["cont"].ToString().Substring(0, 50) + "..." : dr["cont"].ToString(); } context.Response.Write(JsonHelper.DataTableToJSON(dt)); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); this.txtKeywords.Text = this.keywords; BLL.product bll = new BLL.product(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { //ChkAdminLevel("sys_dept", DTEnums.ActionEnum.Delete.ToString()); //检查权限 BLL.product bll = new BLL.product(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked && GetAdminInfo().id != id) { bll.Delete(id); } } JscriptMsg("批量删除成功啦!", Utils.CombUrlTxt("list.aspx", "keywords={0}", this.keywords), "Success"); }
private bool DoEdit(int _id) { bool result = true; BLL.product bll = new BLL.product(); Model.product model = bll.GetModel(_id); model.name = txtName.Text.Trim(); if (!bll.Update(model)) { result = false; } return(result); }
private bool DoAdd() { bool result = true; Model.product model = new Model.product(); BLL.product bll = new BLL.product(); model.name = txtName.Text.Trim(); model.add_time = DateTime.Now; if (bll.Add(model) < 1) { result = false; } return(result); }
//删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("pro_list", DTEnums.ActionEnum.Delete.ToString()); //检查权限 BLL.product bll = new BLL.product(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { bll.Delete(id); } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除产品分类数据"); //记录日志 JscriptMsg("删除数据成功!", Utils.CombUrlTxt("pro_list.aspx", "", "")); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("pro_list", DTEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.product bll = new BLL.product(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort=" + sortId.ToString()); } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "保存产品分类排序"); //记录日志 JscriptMsg("保存排序成功!", Utils.CombUrlTxt("pro_list.aspx", "", "")); }
private void ShowInfo(int id) { Model.product model = new BLL.product().GetModel(id); if (model.status != 1) { btnPass.Visible = false; btnPass2.Visible = false; } ddlCategoryId.SelectedValue = model.category.ToString(); txtSort.Text = model.sort.ToString(); txtTitle.Text = model.title; txtCity.Text = model.city; txtLon.Text = model.lon; txtLat.Text = model.lat; txtAddr.Text = model.addr; txtCont.Text = model.cont; txtAddTime.Text = model.add_time.ToString("yyyy-MM-dd HH:mm:ss"); txtPassTime.Text = model.pass_time.ToString("yyyy-MM-dd HH:mm:ss"); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); this.txtKeywords.Text = this.keywords; DataTable dt = new BLL.product().GetList(pageSize, this.page, _strWhere, _orderby, out this.totalCount).Tables[0]; dt.Columns.Add("username", typeof(string)); foreach (DataRow dr in dt.Rows) { string name = new BLL.user().GetModel(Convert.ToInt32(dr["user_id"])).nickname; dr["username"] = name; } this.rptList.DataSource = dt; this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("pro_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void get_proUser_comment(HttpContext context) { int user_id = DTRequest.GetInt("uid", 0); //select * from fg_news_commend where news_id in(select id from fg_product where user_id=1) and isPN=1 order by time desc DataTable dt = new BLL.product().GetUserComment(user_id).Tables[0]; string[] arr = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { arr[i] = Convert.ToDateTime(dt.Rows[i]["time"].ToString()).ToString("yyyy-MM-dd HH:mm"); } dt.Columns.Remove("time"); dt.Columns.Add("time", typeof(string)); dt.Columns.Add("phone", typeof(string)); foreach (DataRow dr in dt.Rows) { dr["time"] = arr[dt.Rows.IndexOf(dr)]; Model.user user = new BLL.user().GetModel(Convert.ToInt32(dr["user_id"])); dr["phone"] = user.phone; } context.Response.Write(JsonHelper.DataTableToJSON(dt)); }
private void get_pro_model(HttpContext context) { int id = DTRequest.GetInt("id", 0); int uid = DTRequest.GetInt("uid", 0); DataTable dt = new BLL.product().GetList(1, "id=" + id, "").Tables[0]; DataRow dr = new BLL.user_pm().GetList(1, "user_id=" + Convert.ToInt32(dt.Rows[0]["user_id"]), "").Tables[0].Rows[0]; if (dt.Rows.Count > 0) { string pass_time = Convert.ToDateTime(dt.Rows[0]["pass_time"]).ToString("yyyy-MM-dd HH:mm"); string add_time = Convert.ToDateTime(dt.Rows[0]["add_time"]).ToString("yyyy-MM-dd HH:mm"); dt.Columns.Remove("pass_time"); dt.Columns.Add("pass_time", typeof(string)); dt.Columns.Remove("add_time"); dt.Columns.Add("add_time", typeof(string)); dt.Columns.Add("isCollect", typeof(int)); dt.Rows[0]["pass_time"] = pass_time; dt.Rows[0]["add_time"] = add_time; dt.Columns.Add("category2", typeof(int)); dt.Rows[0]["category2"] = new BLL.pro_category().GetModel(Convert.ToInt32(dt.Rows[0]["category"])).parent_id; if (uid != 0) { dt.Rows[0]["isCollect"] = new BLL.news_view().GetCount("user_id=" + uid + " and isPN=2 and type=2 and news_id=" + dt.Rows[0]["id"].ToString()) > 0 ? 1 : 0; } else { dt.Rows[0]["isCollect"] = 0; } dt.Columns.Add("pm_id", typeof(int)); dt.Rows[0]["pm_id"] = dr["user_id"]; dt.Columns.Add("pm_name", typeof(string)); dt.Rows[0]["pm_name"] = dr["name"]; dt.Columns.Add("pm_tel", typeof(string)); dt.Rows[0]["pm_tel"] = dr["phone"]; context.Response.Write(JsonHelper.DataTableToJSON(dt).TrimEnd(']').TrimStart('[')); } }
private void get_category_list(HttpContext context) { string city = DTRequest.GetString("city"); string strJson = ""; strJson += "["; DataSet ds = new BLL.pro_category().GetList(0, "parent_id=0", ""); foreach (DataRow dr in ds.Tables[0].Rows) { strJson += "{"; strJson += "\"id\":\"" + dr["id"].ToString() + "\","; strJson += "\"title\":\"" + dr["title"].ToString() + "\","; strJson += "\"img\":\"" + dr["img"].ToString() + "\","; strJson += "\"img2\":\"" + dr["img2"].ToString() + "\","; strJson += "\"son\":"; strJson += "["; DataSet ds2 = new BLL.pro_category().GetList(0, "parent_id=" + dr["id"], ""); foreach (DataRow dr2 in ds2.Tables[0].Rows) { int num = new BLL.product().GetCount("status=2 and city=" + (city == "未知" ? "city" : "'" + city + "'") + " and category=" + dr2["id"].ToString()); strJson += "{"; strJson += "\"id\":\"" + dr2["id"].ToString() + "\","; strJson += "\"title\":\"" + dr2["title"].ToString() + "\","; strJson += "\"img\":\"" + dr2["img"].ToString() + "\","; strJson += "\"img2\":\"" + dr2["img2"].ToString() + "\","; strJson += "\"num\":" + num; strJson += "},"; } strJson = strJson.TrimEnd(',') + "]"; strJson += "},"; } strJson = strJson.TrimEnd(',') + "]"; context.Response.Write(strJson.TrimEnd(',')); }
private void ShowInfo(int _id) { BLL.product bll = new BLL.product(); Model.product model = bll.GetModel(_id); txtName.Text = model.name; }
//收藏列表,点赞列表 private void get_user_view_list(HttpContext context) { int uid = DTRequest.GetInt("uid", 0); int isPN = DTRequest.GetInt("isPN", 0); int type = DTRequest.GetInt("type", 0); DataTable dt = new BLL.news_view().GetList(0, "type=" + type + " and isPN=" + isPN + " and user_id=" + uid, "time desc").Tables[0]; dt.Columns.Add("title", typeof(string)); dt.Columns.Add("cont", typeof(string)); dt.Columns.Add("day", typeof(string)); foreach (DataRow dr in dt.Rows) { string title, cont; if (isPN == 1) { Model.product model = new BLL.product().GetModel(Convert.ToInt32(dr["news_id"])); title = model.title; if (model.cont.Length > 60) { cont = model.cont.Substring(0, 60) + "..."; } else { cont = model.cont; } } else { Model.news model = new BLL.news().GetModel(Convert.ToInt32(dr["news_id"])); title = model.title; if (model.zhaiyao.Length > 60) { cont = model.zhaiyao.Substring(0, 60) + "..."; } else { cont = model.zhaiyao; } } dr["title"] = title; dr["cont"] = cont; //时间隔计算 DateTime t1 = DateTime.Now; DateTime t2 = Convert.ToDateTime(dr["time"]); TimeSpan ts = t1.Subtract(t2); if (ts.Days > 3) { dr["day"] = Convert.ToDateTime(dr["time"]).ToString("yyyy-MM-dd"); } else if (ts.Days > 0) { dr["day"] = ts.Days + "天前"; } else if (ts.Hours > 0) { dr["day"] = ts.Hours + "小时前"; } else if (ts.Minutes > 0) { dr["day"] = ts.Minutes + "分钟前"; } else if (ts.Seconds > 0) { dr["day"] = ts.Seconds + "秒前"; } else { dr["day"] = "未知"; } } context.Response.Write(JsonHelper.DataTableToJSON(dt)); }
private void product_add(HttpContext context) { int id = DTRequest.GetInt("id", 0); int cateogry = DTRequest.GetInt("category", 0); string title = DTRequest.GetString("title"); string cont = DTRequest.GetString("cont"); string lat = DTRequest.GetString("lat"); string lon = DTRequest.GetString("lon"); string city = DTRequest.GetString("city"); string addr = DTRequest.GetString("addr"); int uid = DTRequest.GetInt("uid", 0); Model.product model = new Model.product(); if (id != 0) { model = new BLL.product().GetModel(id); } model.user_id = uid; model.category = cateogry; model.title = title; model.cont = cont; model.lat = lat; model.lon = lon; model.city = city; model.addr = addr; model.status = 1; if (id == 0) { if (new BLL.product().Add(model) > 0) { if (new BLL.amount().GetCount("type=4 and user_id=" + uid) < 3) { Model.amount amount = new Model.amount() { user_id = uid, type = 4, Amount = 1.88M, remark = "发布产品获得红包", time = DateTime.Now }; new BLL.amount().Add(amount); new BLL.user().UpdateField(uid, "amount=amount+" + amount.Amount); } context.Response.Write("{\"status\":1,\"msg\":\"提交成功!\"}"); } else { context.Response.Write("{\"status\":0,\"msg\":\"提交失败!\"}"); } } else { if (new BLL.product().Update(model)) { context.Response.Write("{\"status\":1,\"msg\":\"修改成功!\"}"); } else { context.Response.Write("{\"status\":0,\"msg\":\"提交失败!\"}"); } } }