void bind() { if (!string.IsNullOrEmpty(id)) { int temp = 0; if (int.TryParse(id, out temp)) { basic_huodong dp = basic_huodongManager.SearchByID(temp); if (dp != null) { try { ddl_type.SelectedValue = dp.hdtype; txt_1.Text = dp.hdone.ToString(); txt_2.Text = dp.hdtwo.ToString(); txt_date1.Text = dp.hddate1.ToString("HH:mm"); txt_date2.Text = dp.hddate2.ToString("HH:mm"); txt_remark.Text = dp.hdremark; txt_name.Text = dp.hdname; } catch { } } } } }
/// <summary> /// 从一个SqlDataReader里读数据 /// </summary> /// <param name="Reader">SqlDataReader</param> /// <returns>basic_huodongExample</returns> public static basic_huodong GetByReader(SqlDataReader Reader) { basic_huodong basic_huodongExample = new basic_huodong(); basic_huodongExample.hdid = Reader["hdid"] == DBNull.Value ? 0 : (int)Reader["hdid"]; basic_huodongExample.hdone = Reader["hdone"] == DBNull.Value ? 0 : (int)Reader["hdone"]; basic_huodongExample.hdtwo = Reader["hdtwo"] == DBNull.Value ? 0 : (int)Reader["hdtwo"]; basic_huodongExample.hddate1 = Reader["hddate1"] == DBNull.Value ? new DateTime() : Convert.ToDateTime(Reader["hddate1"]); basic_huodongExample.hddate2 = Reader["hddate2"] == DBNull.Value ? new DateTime() : Convert.ToDateTime(Reader["hddate2"]); basic_huodongExample.hdtype = Reader["hdtype"] == DBNull.Value ? null : Reader["hdtype"].ToString(); basic_huodongExample.hdremark = Reader["hdremark"] == DBNull.Value ? null : Reader["hdremark"].ToString(); basic_huodongExample.hdname = Reader["hdname"] == DBNull.Value ? null : Reader["hdname"].ToString(); return(basic_huodongExample); }
/// <summary> /// 查询全部数据 /// </summary> /// <returns>IList</returns> /*查看是否为视图*/ public IList <basic_huodong> SearchAll() { DBHelper.sqlstr = "select * from basic_huodong "; List <basic_huodong> list = new List <basic_huodong>(); SqlDataReader reader = DBHelper.ExecuteReader(); while (reader.Read()) { basic_huodong Obj = GetByReader(reader); list.Add(Obj); } reader.Close(); return(list); }
/// <summary> /// 根据编号获取补单方案 /// </summary> /// <param name="opid"></param> /// <returns></returns> public static basic_huodong GetInList(string opid) { basic_huodong op = null; IList <basic_huodong> list = GetList(); foreach (basic_huodong dp in list) { if (dp.hdid.ToString() == opid) { op = dp; break; } } return(op); }
/// <summary> /// 根据hdid,查询一条数据 /// </summary> /// <param name="hdid">编号</param> /// <returns></returns> /*查看是否为视图*/ public basic_huodong SearchByID(int hdid) { DBHelper.sqlstr = "select * from basic_huodong where hdid = @hdid"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("@hdid", hdid) }; SqlDataReader reader = DBHelper.ExecuteReader(param); basic_huodong Obj = null; if (reader.Read()) { Obj = GetByReader(reader); } reader.Close(); return(Obj); }
/// <summary> /// 获取需要补单或者需要报名活动的商品列表 /// </summary> /// <returns></returns> public static IList <basic_goods> GetListByOrder() { DateTime temp_date1 = new DateTime(); DateTime temp_date2 = new DateTime(); DateTime temp_date3 = new DateTime(); DateTime temp_date4 = new DateTime(); int temp_dp = 0; int temp_op = 0; int temp_hp = 0; string state = "1"; string key = ""; string iskey = ""; IList <basic_goods> list = BLL.basic_goodsManager.Search(1, 10000, key, temp_op, temp_hp, temp_dp, state, iskey, temp_date1, temp_date2, temp_date3, temp_date4, ""); List <basic_goods> list_res = new List <basic_goods>(); foreach (basic_goods bg in list) { //补单 int temp_order = basic_order_planManager.GetNumInPlan(bg.bgupdate, bg.opid);; if (temp_order != 0) { int _order_count = BLL.basic_order_recordManager.SearchNum("", bg.bgid, 0, 0, "", "", DateTime.Now, DateTime.Now); if (temp_order - _order_count > 0) { list_res.Add(bg); continue; } } //活动提示 basic_huodong hd = basic_huodongManager.SearchByID(bg.hdid); int temp_huodong = Manager.DateDiff_GetInt(DateTime.Now, bg.bgupdate) + 1; if (temp_huodong == hd.hdone || temp_huodong == hd.hdtwo) { list_res.Add(bg); continue; } } return(list_res); }
/// <summary> /// 搜索条件 /// </summary> /// <param name="s">开始位置</param> /// <param name="e">结束位置</param> /// <param name="key">关键词</param> /// <param name="state">状态</param> /// <param name="orderby">排序方式,直接输入order by后面的语句</param> /// <returns>IList<basic_huodong></returns> public IList <basic_huodong> Search(int s, int e, string key, string state, string orderby) { string sql1 = "select top " + (e - s + 1).ToString() + " * from basic_huodong where "; string sql2 = string.IsNullOrEmpty(key) ? " 1=1 " : " ( hdremark like '%" + key + "%' or hdname like '%" + key + "%' ) "; string sql3 = string.IsNullOrEmpty(state) ? "" : " and hdtype= '" + state + "' "; string sql4 = string.IsNullOrEmpty(orderby) ? " order by hdid desc " : " order by " + orderby; string sql5 = s == 1 ? "" : " and hdid not in ( select top " + (s - 1).ToString() + " hdid from basic_huodong where " + sql2 + sql3 + sql4 + " ) "; DBHelper.sqlstr = sql1 + sql2 + sql3 + sql5 + sql4; List <basic_huodong> list = new List <basic_huodong>(); SqlDataReader reader = DBHelper.ExecuteReader(); while (reader.Read()) { basic_huodong Obj = GetByReader(reader); list.Add(Obj); } reader.Close(); return(list); }
/// <summary> /// 搜索条件 /// </summary> /// <param name="s">开始位置</param> /// <param name="e">结束位置</param> /// <param name="key">关键词</param> /// <param name="state">状态</param> /// <param name="orderby">排序方式,直接输入order by后面的语句</param> /// <returns>IList<basic_huodong></returns> public IList <basic_huodong> Search(int s, int e, string key, string state, string orderby) { string sql1 = "select * from basic_huodong where "; string sql2 = string.IsNullOrEmpty(key) ? " 1=1 " : " ( hdremark like '%" + key + "%' or hdname like '%" + key + "%' ) "; string sql3 = string.IsNullOrEmpty(state) ? "" : " and hdtype= '" + state + "' "; string sql4 = string.IsNullOrEmpty(orderby) ? " order by hdid desc " : " order by " + orderby; string sql10 = e == 0 ? " " : " limit " + s + "," + e; DBHelper.sqlstr = sql1 + sql2 + sql3 + sql4 + sql10; List <basic_huodong> list = new List <basic_huodong>(); MySqlDataReader reader = DBHelper.ExecuteReader(); while (reader.Read()) { basic_huodong Obj = GetByReader(reader); list.Add(Obj); } reader.Close(); return(list); }
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e) { //try //{ if (AJAXManager.GridView_ondblclick(e)) { try { string State = GridView2.DataKeys[e.Row.RowIndex].Values["bgstate"].ToString(); string dpid = GridView2.DataKeys[e.Row.RowIndex].Values["dpid"].ToString(); string bgid = GridView2.DataKeys[e.Row.RowIndex].Values["bgid"].ToString(); string hdid = GridView2.DataKeys[e.Row.RowIndex].Values["hdid"].ToString(); string bgkey = GridView2.DataKeys[e.Row.RowIndex].Values["bgkey"].ToString(); string opid = GridView2.DataKeys[e.Row.RowIndex].Values["opid"].ToString(); string bgupdate = GridView2.DataKeys[e.Row.RowIndex].Values["bgupdate"].ToString(); DateTime up_date = new DateTime(); DateTime.TryParse(bgupdate, out up_date); LinkButton lb_state = e.Row.FindControl("lb_state") as LinkButton; LinkButton lb_key = e.Row.FindControl("lb_key") as LinkButton; Label lbl_dianpu = e.Row.FindControl("lbl_dianpu") as Label; Label lbl_order = e.Row.FindControl("lbl_order") as Label; Label lbl_huodong = e.Row.FindControl("lbl_huodong") as Label; //补单 int temp_order = basic_order_planManager.GetNumInPlan(up_date, Convert.ToInt32(opid)); int _order_count = BLL.basic_order_recordManager.SearchNum("", Convert.ToInt32(bgid), 0, 0, "", "", DateTime.Now, DateTime.Now); int res_count = temp_order - _order_count; if (res_count > 0) { lbl_order.Text = "需补 " + (temp_order - _order_count).ToString() + " 单"; lbl_order.ForeColor = System.Drawing.Color.Red; lbl_order.Font.Bold = true; } else { lbl_order.Text = "无"; lbl_order.ForeColor = System.Drawing.Color.Black; } //活动提示 basic_huodong hd = basic_huodongManager.SearchByID(Convert.ToInt32(hdid)); int temp_huodong = Manager.DateDiff_GetInt(DateTime.Now, up_date) + 1; if (temp_huodong == hd.hdone || temp_huodong == hd.hdtwo) { lbl_huodong.Text = "今日" + hd.hddate1.ToString("HH:mm") + "报名"; lbl_huodong.ForeColor = System.Drawing.Color.Red; lbl_huodong.Font.Bold = true; } else { lbl_huodong.Text = "无"; lbl_huodong.ForeColor = System.Drawing.Color.Black; } //状态 if (State == "1") { lb_state.Text = "启用"; lb_state.ForeColor = System.Drawing.Color.Red; //lb_state.Font.Bold = true; } else if (State == "2") { lb_state.Text = "禁用"; lb_state.ForeColor = System.Drawing.Color.Blue; } //是否重点 if (bgkey == "1") { lb_key.Text = "是"; lb_key.ForeColor = System.Drawing.Color.Red; lb_key.Font.Bold = true; } else if (bgkey == "2") { lb_key.Text = "否"; lb_key.ForeColor = System.Drawing.Color.Blue; } //店铺 dianpu dp = BLL.dianpuManager.GetInList(dpid); if (dp != null) { lbl_dianpu.Text = dp.dpname; lbl_dianpu.ForeColor = System.Drawing.Color.Green; // lb_account.NavigateUrl = "http://www.taobao.com/webww/ww.php?ver=3&touid=" + lb_account.Text + "&siteid=cntaobao&status=1&charset=utf-8"; } //判断是否是编辑状态 if (GridView2.EditIndex != e.Row.RowIndex) { //LinkButton lb_zhifubao = e.Row.FindControl("lb_zhifubao") as LinkButton; //HyperLink lb_account = e.Row.FindControl("lb_account") as HyperLink; //lb_account.NavigateUrl = "http://www.taobao.com/webww/ww.php?ver=3&touid=" + lb_account.Text + "&siteid=cntaobao&status=1&charset=utf-8"; //lb_account.ForeColor = System.Drawing.Color.Blue; } } catch (Exception ex) { Common.ErrorLog.WriteEntry(ex); } } }
/// <summary> /// 更新 /// </summary> /// <param name="basic_huodong">basic_huodong表实例</param> /// <returns>int</returns> public int Update(basic_huodong basic_huodongExample) { DBHelper.sqlstr = "update basic_huodong set hdone=@hdone,hdtwo=@hdtwo,hddate1=@hddate1,hddate2=@hddate2,hdtype=@hdtype,hdremark=@hdremark,hdname=@hdname where hdid=" + basic_huodongExample.hdid; return(DBHelper.ExecuteNonQuery(GetSqlParameters(basic_huodongExample))); }
/// <summary> /// 插入方法 /// </summary> /// <param name="basic_huodong">basic_huodong表实例</param> /// <returns>int</returns> public int Insert(basic_huodong basic_huodongExample) { DBHelper.sqlstr = "insert into basic_huodong (hdone,hdtwo,hddate1,hddate2,hdtype,hdremark,hdname)values(@hdone,@hdtwo,@hddate1,@hddate2,@hdtype,@hdremark,@hdname)"; return(DBHelper.ExecuteNonQuery(GetSqlParameters(basic_huodongExample))); }
/// <summary> /// 根据表,获取一个SqlParameter数组 /// </summary> /// <returns>SqlParameter[]</returns> public static SqlParameter[] GetSqlParameters(basic_huodong basic_huodongExample) { List <SqlParameter> list_param = new List <SqlParameter>(); if (basic_huodongExample.hdone != 0) { list_param.Add(new SqlParameter("@hdone", basic_huodongExample.hdone)); } else { list_param.Add(new SqlParameter("@hdone", DBNull.Value)); } if (basic_huodongExample.hdtwo != 0) { list_param.Add(new SqlParameter("@hdtwo", basic_huodongExample.hdtwo)); } else { list_param.Add(new SqlParameter("@hdtwo", DBNull.Value)); } if (basic_huodongExample.hddate1 != new DateTime() && basic_huodongExample.hddate1 != null) { list_param.Add(new SqlParameter("@hddate1", basic_huodongExample.hddate1.ToString("yyyy-MM-dd"))); } else { list_param.Add(new SqlParameter("@hddate1", DBNull.Value)); } if (basic_huodongExample.hddate2 != new DateTime() && basic_huodongExample.hddate2 != null) { list_param.Add(new SqlParameter("@hddate2", basic_huodongExample.hddate2.ToString("yyyy-MM-dd"))); } else { list_param.Add(new SqlParameter("@hddate2", DBNull.Value)); } if (!string.IsNullOrEmpty(basic_huodongExample.hdtype)) { list_param.Add(new SqlParameter("@hdtype", basic_huodongExample.hdtype)); } else { list_param.Add(new SqlParameter("@hdtype", DBNull.Value)); } if (!string.IsNullOrEmpty(basic_huodongExample.hdremark)) { list_param.Add(new SqlParameter("@hdremark", basic_huodongExample.hdremark)); } else { list_param.Add(new SqlParameter("@hdremark", DBNull.Value)); } if (!string.IsNullOrEmpty(basic_huodongExample.hdname)) { list_param.Add(new SqlParameter("@hdname", basic_huodongExample.hdname)); } else { list_param.Add(new SqlParameter("@hdname", DBNull.Value)); } SqlParameter[] param = new SqlParameter[list_param.Count]; int index = 0; foreach (SqlParameter p in list_param) { param[index] = p; index++; } return(param); }
protected void btn_save_Click(object sender, EventArgs e) { try { string _type = ddl_type.SelectedValue; int one = 0; if (!int.TryParse(txt_1.Text.Trim(), out one)) { Manager.Alert("请输入正确的天数", Page); Manager.TextBox_Select(txt_1); return; } int two = 0; if (!int.TryParse(txt_2.Text.Trim(), out two)) { Manager.Alert("请输入正确的天数", Page); Manager.TextBox_Select(txt_2); return; } DateTime date1 = new DateTime(); if (!DateTime.TryParse(DateTime.Now.ToString("yyyy-MM-dd ") + txt_date1.Text.Trim(), out date1)) { Manager.Alert("请输入正确的时间", Page); Manager.TextBox_Select(txt_date1); return; } DateTime date2 = new DateTime(); if (!DateTime.TryParse(DateTime.Now.ToString("yyyy-MM-dd ") + txt_date2.Text.Trim(), out date2)) { Manager.Alert("请输入正确的时间", Page); Manager.TextBox_Select(txt_date2); return; } string name = txt_name.Text.Trim(); string remark = txt_remark.Text.Trim(); basic_huodong dp = new basic_huodong(); if (!string.IsNullOrEmpty(id)) { dp = BLL.basic_huodongManager.SearchByID(Convert.ToInt32(id)); } dp.hddate1 = date1; dp.hddate2 = date2; dp.hdone = one; dp.hdtwo = two; dp.hdremark = remark; dp.hdname = name; int res; if (string.IsNullOrEmpty(id)) { res = BLL.basic_huodongManager.Insert(dp); } else { res = BLL.basic_huodongManager.Update(dp); } if (res == 1) { Manager.Alert("保存成功", Page); } else { Manager.Alert("保存失败", Page); } } catch (Exception ex) { Manager.Alert(ex.ToString(), Page); } Manager.page_href_reload(Page); }
/// <summary> /// 更新 /// </summary> /// <param name="basic_huodong">basic_huodong表实例</param> /// <returns>int</returns> public static int Update(basic_huodong basic_huodongExample) { return(Service.Update(basic_huodongExample)); }
/// <summary> /// 插入方法 /// </summary> /// <param name="basic_huodong">basic_huodong表实例</param> /// <returns>int</returns> public static int Insert(basic_huodong basic_huodongExample) { return(Service.Insert(basic_huodongExample)); }