protected void Page_Load(object sender, EventArgs e) { var id = this.Request.QueryString["id"]; if(!string.IsNullOrEmpty(id)) { var ctx = new DataContext(); var dt = ctx.ExecuteDataTable( "SELECT [LoginName],[Password],[Name],[Mob],[Email],[QQ],[Remark],[State],[CreateDate],[ModifyDate] From [Admin] Where id=" + id + " and [state]<>255"); if(dt!=null&&dt.Rows.Count>0) { this.txtLgName.Text = dt.Rows[0]["LoginName"].ToString(); this.txtName.Text = dt.Rows[0]["Name"].ToString(); this.txtEmail.Text = dt.Rows[0]["Email"].ToString(); this.txtMob.Text = dt.Rows[0]["Mob"].ToString(); this.txtQQ.Text = dt.Rows[0]["QQ"].ToString(); this.txtRemark.Text = dt.Rows[0]["Remark"].ToString(); this.txtState.Text = dt.Rows[0]["State"].ToString(); this.txtCreateDate.Text = dt.Rows[0]["CreateDate"].ToString(); this.txtModifyDate.Text = dt.Rows[0]["ModifyDate"].ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { var ctx = new DataContext(); var ds = ctx.ExecuteDataSet( @"Select top 10 ID,Title,ChannelID,CreateDate from Content Where ChannelCode='Company' And State=0 Order by CreateDate Desc; Select top 10 ID,Title,ChannelID,CreateDate from Content Where ChannelCode='dongtai' And State=0 Order by CreateDate Desc; Select * from Config where state=0;"); if (ds != null) { if (ds.Tables.Count>0) { CompanyContents = ds.Tables[0].ToList<Model.Content>(); } if (ds.Tables.Count > 1) { dtContents = ds.Tables[1].ToList<Model.Content>(); } if (ds.Tables.Count > 2) { Configs = ds.Tables[2].ToList<Model.Config>(); } } }
protected void Page_Load(object sender, EventArgs e) { Common.DataContext ctx = new Common.DataContext(); int pageIndex = PubFunc.getPageIndex(); if (pageIndex == 0) { pageIndex = 1; } int pageSize = Pager.PageSize; ctx.CommandType = CommandType.Text; // (SELECT ROW_NUMBER() OVER (ORDER BY usr_User.ID DESC) AS ROWNO, string sql = @"Select [ID],Case ParentId when 0 then [Name] else '|----'+[Name] end [Name],[Type],[ContentType],[ImageUrl],[Code],[ParentId],[Sort],Case ParentId when 0 then ID else ParentId end sortId,[State],[CreateDate],[ModifyDate],[CreatedBy],[ModifiedBy],[Remark],[Ext] from [Channel] where State <> 255 order by sortId"; var dataset = ctx.ExecuteDataSet(sql); if (dataset.Tables.Count <= 0) { return; } var list = dataset.Tables[0].ToList<Model.Channel>(); Common.PubFunc.BindControl(rptList, list); }
private AjaxResult Del(int id) { BLL.BLLBase bll = new BLLBase(); AjaxResult re = null; var ctx = new Common.DataContext(); ctx.BeginTransaction(); try { bll.Update(ctx, new Model.Channel() {ID = id, State = 255}); ctx.CommitTransaction(); re = new AjaxResult() {Success = 1}; } catch (Exception ex) { ctx.RollBackTransaction(); re = new AjaxResult() {Success = 0, Message = "操作失败,原因:" + ex.Message}; } finally { ctx.CloseConnection(); } return re; }
protected void Page_Load(object sender, EventArgs e) { Common.DataContext ctx = new Common.DataContext(); int pageIndex = PubFunc.getPageIndex(); if (pageIndex == 0) { pageIndex = 1; } int pageSize = Pager.PageSize; ctx.CommandType = CommandType.Text; // (SELECT ROW_NUMBER() OVER (ORDER BY usr_User.ID DESC) AS ROWNO, string sql = @"Select [ID],Case ParentId when 0 then [Name] else '|----'+[Name] end [Name],[Type],[ContentType],[ImageUrl],[Code],[ParentId],[Sort],Case ParentId when 0 then ID else ParentId end sortId,[State],[CreateDate],[ModifyDate],[CreatedBy],[ModifiedBy],[Remark],[Ext] from [Channel] where State <> 255 order by sortId"; var dataset = ctx.ExecuteDataSet(sql); if (dataset.Tables.Count <= 0) { return; } var list = dataset.Tables[0].ToList <Model.Channel>(); Common.PubFunc.BindControl(rptList, list); }
public int Update(Common.DataContext ctx, IModel.BaseTable baseTable) { int rel = 0; rel = dal.Update(ctx, baseTable); return(rel); }
public Model.Content GetSinplePageChannelContent(DataContext ctx,int? channelId) { var tb = ctx.ExecuteDataTable( "Select top 1 * From Content where State!=255 and ChannelID=" + channelId + " Order by ID desc"); if (tb != null && tb.Rows.Count > 0) { return tb.ToList<Model.Content>()[0]; } return null; }
public List<Model.Content> GetChannelContentList(DataContext ctx, int? channelId) { var tb = ctx.ExecuteDataTable( "Select top 20 [ID],[ChannelID],[Type],[ImageUrls],[Title],substring([ContentText],1,200) as ContentText,[Url],[Attributes],[State],[CreateDate],ChannelName From Content where State!=255 and ChannelID=" + channelId + " Order by ID desc"); if (tb != null) { return tb.ToList<Model.Content>(); } return new List<Model.Content>(); }
private AjaxResult Del(int id) { BLL.BLLBase bll = new BLLBase(); AjaxResult re = null; var ctx = new Common.DataContext(); ctx.BeginTransaction(); try { bll.Update(ctx, new Model.Channel() { ID = id, State = 255 }); ctx.CommitTransaction(); re = new AjaxResult() { Success = 1 }; } catch (Exception ex) { ctx.RollBackTransaction(); re = new AjaxResult() { Success = 0, Message = "操作失败,原因:" + ex.Message }; } finally { ctx.CloseConnection(); } return(re); }
protected override void OnActionExecuting(ActionExecutingContext filterContext) { // Set the Categories for the navigation var categories = new DataContext().Categories; ViewBag.Categories = categories; }
protected void Page_Load(object sender, EventArgs e) { if(IsPostBack) { AjaxResult response = null; var txtLgName = Request.Form["txtLgName"]; var txtPwd = Request.Form["txtPwd"]; var txtName = Request.Form["txtName"]; var txtEmail = Request.Form["txtMail"]; var txtQQ = Request.Form["txtQQ"]; var txtMob = Request.Form["txtMob"]; var txtRemark = Request.Form["txtRemark"]; if (string.IsNullOrEmpty(txtLgName)) { response = new AjaxResult() {Success = 0, Message = "登录名不能为空。"}; this.Response.Write(common.Common.GetJSMsgBox(response.Message)); return; } if (string.IsNullOrEmpty(txtPwd)) { response = new AjaxResult() { Success = 0, Message = "密码不能为空。" }; this.Response.Write(common.Common.GetJSMsgBox(response.Message)); return; } if (string.IsNullOrEmpty(txtName)) { response = new AjaxResult() { Success = 0, Message = "用户名不能为空。" }; this.Response.Write(common.Common.GetJSMsgBox(response.Message)); return; } var dt = new Model.Admin() { CreateDate = DateTime.Now, Email = txtEmail, LoginName = txtLgName, ModifyDate = DateTime.Now, Name = txtName, Password = PubFunc.Md5(txtPwd), QQ = txtQQ, Mob = txtMob, Remark = txtRemark }; DataContext dc=new DataContext(); dc.BeginTransaction(); try { var bll = new BLL.BLLBase(); var id = bll.Add(dc, dt); dc.CommitTransaction(); response = new AjaxResult() {Success = 1, Message = "操作成功", Data = id}; } catch(Exception exception) { dc.RollBackTransaction(); response = new AjaxResult() { Success = 0, Message = "操作失败:"+exception.Message, Data = 0 }; } finally { dc.CloseConnection(); } this.Response.Write(common.Common.GetJSMsgBox(response.Message)); } }
/// <summary> /// 根据ID读取指定表单个字段 /// </summary> /// <param name="ctx"></param> /// <param name="Field"></param> /// <param name="Table"></param> /// <param name="ID"></param> /// <returns></returns> public static object GetValueByID(DataContext ctx, string Field, string Table, int ID) { if (ctx == null) ctx = new DataContext(); string sql = string.Format("SELECT {0} FROM {1} WITH(NOLOCK) WHERE ID=@ID_getValueByID", Field, Table, ID); ctx.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ID_getValueByID", ID)); ctx.CommandType = CommandType.Text; object reval = ctx.ExecuteScalar(sql); ctx.ClearParameters(); return reval; }
/// <summary> /// 获取配置信息 /// </summary> /// <param name="ID"></param> /// <returns></returns> public static string GetConfig(int ID) { DataContext ctx = new DataContext(); return GetConfig(ctx, ID); }
/// <summary> /// 获取配置信息 /// </summary> /// <param name="ctx"></param> /// <param name="ID"></param> /// <returns></returns> public static string GetConfig(DataContext ctx, int ID) { string sql = "SELECT Value FROM sys_Config WHERE ID=" + ID; return ctx.ExecuteScalar(sql).ToString(); }
/// <summary> /// 获取专区域名 /// </summary> /// <param name="ctx"></param> /// <param name="ID"></param> /// <returns></returns> public static string GetAreaUrl(DataContext ctx, int ID) { object obj = GetValueByID(ctx, "PinYin", "pro_Area", ID); string s = obj == null ? string.Empty : obj.ToString(); string feed = string.Format(Constant.SiteUrl.Replace("www", "{0}")); return string.Format(feed, s); }
public DataTable Select(Common.DataContext ctx, IModel.BaseTable baseTable) { return(dal.Select(ctx, baseTable)); }