private string GetItembyGroupIdList(string GroupIdList) { GroupIdList = GroupIdList.Trim(','); AdmUserGroup cont = new AdmUserGroup(); ArrayList al = new ArrayList(); GroupIdList = CFun.RegularIdlist(GroupIdList, true); string[] ss = GroupIdList.Trim().Split(new char[] { ',' }); //第一种方法 for (int j = 0; j < ss.Length; j++) { if (ss[j] == "0") { cont.Name = "系统超级管理员"; al.Add(cont.Name); } else { List <AdmUserGroup> contList = GetItem(" GroupId=" + ss[j]); if (contList != null && contList.Count > 0) { cont = contList[0]; al.Add(cont.Name); } } } //直接装换为String 类型。 cont.Name = string.Join(",", (string[])al.ToArray(typeof(string))); return(cont.Name); }
/// <summary> /// 利用给定的SQL语句绑定给定的DataGrid /// 并将其中一列进行UrlEncode以作为超链的参数 /// 使用该函数时,将DataGrid超链列的URL字段处填“KeyField”即可 /// </summary> /// <param name="strSql">给定的SQL语句</param> /// <param name="DG">给定的DataGrid</param> /// <param name="ColumnName">需要UrlEncode的列名</param> public static void BindDataGrid(string strSql, DataGrid DG, string ColumnName) { try { DataSet DS = new DataSet(); DS = CreateDataSet(strSql); DS.Tables[0].Columns.Add("KeyField"); for (int i = 0; i < DS.Tables[0].Rows.Count; i++) { DS.Tables[0].Rows[i]["KeyField"] = HttpUtility.UrlEncode(DS.Tables[0].Rows[i][ColumnName].ToString().Trim()); } DG.DataSource = DS.Tables[0].DefaultView; if (DG.CurrentPageIndex > DG.PageCount - 1) { if (DG.PageCount > 0) { DG.CurrentPageIndex = DG.PageCount - 1; } else { DG.CurrentPageIndex = 0; } } DG.DataBind(); } catch (Exception e) { CFun.JsAlerT(e.Message.ToString()); } finally { //Close(); //Dispose(); } }
private void SaveMulaqat(clsDostMulaqat oMulaqat, String SarifID, String DostId) { //if (oMulaqat.Halath == "0" || oMulaqat.Halath == "3") // return; if (oMulaqat.Halath == "4") { DeleteMulaqat(oMulaqat); } else { if (oMulaqat.Halath == ((int)Halath.Edited).ToString()) { CFun.fnSaveData(oMulaqat.Id, "Mulaqatain", new string[] { "Tarekh", "Tafseel" }, new string[] { oMulaqat.Tarekh, oMulaqat.Tafseel }, "Id = " + oMulaqat.Id ); } else { CFun.fnSaveData(oMulaqat.Id, "Mulaqatain", new string[] { "SarifId", "DostId", "Tarekh", "Tafseel" }, new string[] { SarifID, DostId, oMulaqat.Tarekh, oMulaqat.Tafseel } ); } } }
protected void Page_Load(object sender, EventArgs e) { LtlCurrentUser.Text = CurrentTureName; webName = CFun.GetAppStr("webName"); LoadMenu(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CFun.BindListControl <AvailablesStatus>(RblStatus, false); CFun.BindListControl <EnumUPostClass>(RblUPost, false); CFun.BindListControl <EnumSexClass>(RblUPostSex, false); RblUPostSex.SelectedIndex = 0; RblUPost.SelectedIndex = 1; RblStatus.SelectedIndex = 1; int id = CFun.RequestPamInt("id"); if (id > 0) { AdmUser cont = new BllAdmUser().GetItem(id); if (cont != null) { CFun.BindPageData <AdmUser>(this, cont); BtnSave.Text = "修改"; initRoleList(cont.GroupIdList); } else { initRoleList(""); } } else { initRoleList(""); } } }
/// <summary> /// 设置数据库连接字符串 /// </summary> /// <param name="con"></param> public void SetSqlConn(string con) { if (con != "") { sqlConn = CFun.GetAppStr(con); } }
protected void Page_Load(object sender, EventArgs e) { string rStr = ""; string act = CFun.RequestPamStr("act"); switch (act) { case "get": rStr = GetValue(); break; case "del": rStr = DelItem(); break; case "getclass": rStr = GetClass(); break; case "delclass": rStr = DelClass(); break; } Response.Write(rStr); Response.End(); }
/// <summary> /// 执行多条SQL语句,实现数据库事务。 /// </summary> /// <param name="SQLStringList">多条SQL语句</param> /// <returns>成功与否</returns> public static bool ExecuteSqlTran(ArrayList SQLStringList) { using (SqlConnection conn = new SqlConnection(ConnString)) { conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; SqlTransaction tx = conn.BeginTransaction(); cmd.Transaction = tx; try { for (int n = 0; n < SQLStringList.Count; n++) { string strsql = SQLStringList[n].ToString(); if (strsql.Trim().Length > 1) { cmd.CommandText = strsql; cmd.ExecuteNonQuery(); } } tx.Commit(); } catch (System.Data.SqlClient.SqlException e) { tx.Rollback(); CFun.JsAlerT(e.Message.ToString()); return(false); } } return(true); }
/// <summary> /// 根据单值型strSQL获取object型单值 /// </summary> /// <param name="SQLString">单值型strSQL语句</param> /// <returns>查询结果(object)</returns> public static object GetObjectSingle(string SQLString) { using (SqlConnection connection = new SqlConnection(ConnString)) { using (SqlCommand cmd = new SqlCommand(SQLString, connection)) { try { connection.Open(); object obj = cmd.ExecuteScalar(); if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) { return(null); } else { return(obj); } } catch (System.Data.SqlClient.SqlException e) { connection.Close(); CFun.JsAlerT(e.Message.ToString()); } } } return(null); }
public baseCC() { CurrentUId = 0; CurrentUName = "admin"; CurrentTureName = "管理员"; //检查用户登录状态 try { HttpCookie co1 = System.Web.HttpContext.Current.Request.Cookies[CFun.GetAppStr("LoginCookieName")]; CurrentUId = Convert.ToInt32(co1["i"]); CurrentUName = co1["n"]; CurrentTureName = System.Web.HttpUtility.UrlDecode(co1["t"]); CurrentCheckCode = CFun.ParseInt(co1["c"]); CurrentRoleId = CFun.DESDecrypt(co1["r"], CFun.GetAppStr("DESKey")); CurrentRoleId = CurrentRoleId == "" ? "-1" : CurrentRoleId; CurrentRoleId = ("," + CurrentRoleId + ",").IndexOf(",0,") >= 0 ? "" : CurrentRoleId; CurrentUPost = Convert.ToInt32(CFun.DESDecrypt(co1["g"], CFun.GetAppStr("DESKey"))); //处理踢人下线 checkUserAvailable(); } catch { System.Web.HttpContext.Current.Response.Redirect(url); return; } if (CurrentUId <= 0) { System.Web.HttpContext.Current.Response.Redirect(url); return; } }
private void checkUserAvailable() { int times = 0; HttpCookie co = System.Web.HttpContext.Current.Request.Cookies["ccUserTimes"]; if (co != null) { times = CFun.ParseInt(co.Value); times++; if (times > 10) { times = 0; } } else { co = new HttpCookie("ccUserTimes"); } co.Value = times.ToString(); System.Web.HttpContext.Current.Response.Cookies.Add(co); if (times == 0) { if (ExecSql.GetDataSet("select ld from AdmUser where Ld=" + CurrentUId + " and CheckCode<>" + CurrentCheckCode).Tables[0].Rows.Count > 0) { new BllAdmUser().LogOut(); return; } } }
protected void BtnSave_Click(object sender, EventArgs e) { AdmUser cont = new AdmUser(); CFun.GetPageData <AdmUser>(cont, this); //cont.GroupIdList = CFun.RequestPamStr("gname"); string GroupIdList = CFun.RequestPamStr("gname"); string platformList = CFun.RequestPamStr("platformname"); cont.GroupIdList = "," + GroupIdList + ','; if (cont.Ld == 0) { cont.CreateDate = DateTime.Now; } cont.LastDate = DateTime.Now; if (TxtUPass.Text != "") { cont.UPassword = CFun.MD5(TxtUPass.Text); } if (new BllAdmUser().InsertorUpdateitem(cont)) { BllAdmActHistory.SaveLog(CurrentUId, (int)EnumCCActiveClass.客服人员管理, cont.Ld.Value, ""); CFun.AlertMegT("保存成功!", "closeFlowPanel", ""); } else { CFun.AlertMegT("发生错误,请稍后再试!", "back", ""); } }
private string GetValueLogin() { int id = CFun.RequestPamInt("id"); string sTime, eTime; sTime = CFun.RequestPamStr("stime"); eTime = CFun.RequestPamStr("etime"); string sqlWhere = " uid=" + id.ToString(); if (CFun.StrIsDate(sTime)) { sqlWhere += " and CreateDate>'" + sTime + "'"; } if (CFun.StrIsDate(eTime)) { sqlWhere += " and CreateDate<'" + eTime + " 23:59:59'"; } int pageSize = CFun.RequestPamInt("rows"); if (pageSize <= 0) { pageSize = CFun.pagesize(); } int pageCurrent = CFun.RequestPamInt("page"); if (pageCurrent <= 0) { pageCurrent = 1; } return(new BllAdmLoginHistory().GetAllByPage("*", pageSize, pageCurrent, sqlWhere, "Ld desc")); }
public void SetCookieDomain(string cookiename, object cookievalue, int hour) { try { System.Runtime.Serialization.IFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); string result = string.Empty; //将字符串进行base64编码,解决中文问题。然后进行序列化化,将shopcart保存至cookie using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { bf.Serialize(ms, cookievalue); byte[] byt = new byte[ms.Length]; byt = ms.ToArray(); result = System.Convert.ToBase64String(byt); ms.Flush(); } HttpCookie hc = new HttpCookie(cookiename); hc.Value = result; hc.HttpOnly = false; if (hour != 0) { hc.Expires = DateTime.Now.AddHours(hour); //设置过期时间 } else { hc.Expires = DateTime.MaxValue; } hc.Domain = CFun.GetAppStr("webDomain"); HttpContext.Current.Response.Cookies.Add(hc); } catch { } }
private string GetValue() { int roleId = CFun.RequestPamInt("roleid"); //string name = CFun.RequestPamStr("Name"); string Sqlwhere = ""; if (roleId > -1) { //Sqlwhere = " charindex('"+roleId+"',GroupIdList)>0"; Sqlwhere = " GroupIdlist like '%," + roleId + ",%'"; } int pageSize = CFun.RequestPamInt("rows"); if (pageSize <= 0) { pageSize = CFun.pagesize(); } int pageCurrent = CFun.RequestPamInt("page"); if (pageCurrent <= 0) { pageCurrent = 1; } return(new BllAdmUser().GetAllByPage("*", pageSize, pageCurrent, Sqlwhere, "Ld desc")); }
/// <summary> /// 处理用户登录 /// </summary> /// <param name="uName"></param> /// <param name="uPass"></param> /// <returns></returns> public int UserLoginIn(string uName, string uPass) { DataTable dtUser = null; int resultInt = new Sql_AdmUser().CheckUser(uName, CFun.MD5(uPass), CFun.GetRemoteIP(), out dtUser); if (resultInt == 1) { DataRow dr = dtUser.Rows[0]; if (dr["Status"].ToString() == "1") { HttpCookie co1 = new HttpCookie(CFun.GetAppStr("LoginCookieName")); co1.Values["i"] = dr["Ld"].ToString(); co1.Values["n"] = dr["UName"].ToString(); co1.Values["c"] = dr["checkcode"].ToString(); co1.Values["r"] = CFun.DESEncrypt(dr["GroupIdList"].ToString().TrimStart(',').TrimEnd(','), CFun.GetAppStr("DESKey")); co1.Values["t"] = System.Web.HttpContext.Current.Server.UrlEncode(dr["TrueName"].ToString()); co1.Values["g"] = CFun.DESEncrypt(dr["UPost"].ToString(), CFun.GetAppStr("DESKey")); co1.Domain = CFun.GetAppStr("webDomain"); System.Web.HttpContext.Current.Response.Cookies.Add(co1); } else { return(5); } } return(resultInt); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Id = CFun.RequestPamInt("id").ToString(); CFun.BindListControl <EnumCCActiveClass>(DdlAct, true); } }
protected void Page_Load(object sender, EventArgs e) { parentId = CFun.RequestPamStr("id"); if (parentId == "") { parentId = "0"; } }
/// <summary> /// 分页查询 /// </summary> /// <param name="strColumn">查询的字段名,空则返回全部</param> /// <param name="pageSize">每页记录数</param> /// <param name="currentPage">当前页数</param> /// <param name="strWhere">查询条件</param> /// <param name="orderBy">排序字段</param> /// <param name="pageCount">返回页数总数</param> /// <param name="recordCount">返回记录总数</param> /// <returns></returns> public List <T> GetAllByPage(string strColumn, int pageSize, int currentPage, string strWhere, string orderBy, out int pageCount, out int recordCount) { pageCount = 1; List <T> allLog = ExecSqlConn.GetTableList <T>(tableName, strColumn, orderBy, "Ld", pageSize, currentPage, strWhere, sqlConn, out recordCount); pageCount = CFun.pagecount(recordCount); return(allLog); }
/// <summary> /// 处理用户登出 /// </summary> public void LogOut() { HttpCookie co1 = new HttpCookie(CFun.GetAppStr("LoginCookieName")); co1.Value = ""; co1.Domain = CFun.GetAppStr("webDomain"); System.Web.HttpContext.Current.Response.Cookies.Add(co1); }
/// <summary> /// 弹出页面 /// </summary> /// <param name="page">所在页面对象</param> /// <param name="NewPageUrl">页面URL</param> /// <param name="Title">标题</param> /// <param name="Reflash">是否刷新</param> /// <param name="FullScrean">是否全屏</param> /// <param name="ReLoadPage">关闭后重定向页面URL</param> public static void OpenPage(System.Web.UI.Page page, string NewPageUrl, string Title, bool Reflash, bool FullScrean, string ReLoadPage) { StringBuilder sb = new StringBuilder(); sb.Append(" art.dialog.open('" + NewPageUrl + "', { "); sb.Append(" title: '" + Title + "',"); sb.Append(" skin: 'facebook',"); sb.Append(" lock: true,"); if (FullScrean == true) { sb.Append(" width: '100%',"); sb.Append(" height: '100%',"); sb.Append(" left: '0%',"); sb.Append(" top: '0%',"); sb.Append(" fixed: true,"); sb.Append(" resize: false,"); sb.Append(" drag: false,"); } if (ReLoadPage != "") { sb.Append(" okVal: '关闭',"); sb.Append(" ok: function (){"); sb.Append(" var win = art.dialog.open.origin;"); sb.Append(" win.location='" + ReLoadPage + "'; "); sb.Append(" return false;"); sb.Append(" }"); } else { if (Reflash == true) { sb.Append(" okVal: '返回',"); sb.Append(" ok: function (){"); sb.Append(" var win = art.dialog.open.origin;"); sb.Append(" win.location.reload(); "); sb.Append(" return false;"); sb.Append(" }"); } else { sb.Append(" okVal: '返回',"); sb.Append(" ok: function (){"); sb.Append(" return false;"); sb.Append(" }"); } } sb.Append(" });"); string js = CFun.FortmatJavaScript(sb.ToString()); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "OpenPage")) { page.ClientScript.RegisterStartupScript(page.GetType(), "OpenPage", js); } }
/// <summary> /// 成功提示框 /// </summary> /// <param name="page">当前Page对象</param> /// <param name="msg">消息</param> public static void WriteJS(System.Web.UI.Page page, string strJS) { string js = CFun.FortmatJavaScript(strJS); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "strJS")) { page.ClientScript.RegisterStartupScript(page.GetType(), "strJS", js); } }
public Service() { CFun.I_LOVE_BBS("yiwowang.com"); //如果使用设计的组件,请取消注释以下行 //InitializeComponent(); }
/// <summary> /// 设置永久cookie /// </summary> /// <param name="cookieName"></param> /// <param name="cookieValue"></param> public static void setCookie(string cookieName, string cookieValue) { HttpCookie co1 = new HttpCookie(cookieName); co1.Value = cookieValue; co1.Domain = CFun.GetAppStr("webDomain"); co1.Expires = DateTime.Now.AddYears(1); System.Web.HttpContext.Current.Response.Cookies.Add(co1); }
/// <summary> /// 弹出框(不带按钮) /// </summary> /// <param name="page">当前Page对象</param> /// <param name="msg">消息</param> public static void AlertBox(System.Web.UI.Page page, string msg) { string str = " document.onLoad=artDialog({ id: 'warning',icon: 'warning',lock: true,content: " + msg + ",ok: true});"; string js = CFun.FortmatJavaScript(str); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "AlertBox")) { page.ClientScript.RegisterStartupScript(page.GetType(), "AlertBox", js); } }
protected void Page_Load(object sender, EventArgs e) { CFun.BindListControl <EnumAdmActClass>(DdlActClass, true); int act = CFun.RequestPamInt("act"); if (act > 0) { DdlActClass.SelectedValue = act.ToString(); } }
/// <summary> ///关闭弹出框 /// </summary> /// <param name="page">当前Page对象</param> public static void Close(System.Web.UI.Page page) { string str = " art.dialog.close();"; string js = CFun.FortmatJavaScript(str); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "close")) { page.ClientScript.RegisterStartupScript(page.GetType(), "close", js); } }
/// <summary> /// 弹出框(不带按钮) /// </summary> /// <param name="page">当前Page对象</param> /// <param name="msg">消息</param> public static void AlertBox(System.Web.UI.Page page, string msg) { string str = "art.dialog.alert('" + msg + "');"; string js = CFun.FortmatJavaScript(str); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "AlertBox")) { page.ClientScript.RegisterStartupScript(page.GetType(), "AlertBox", js); } }
/// <summary> /// 弹出页面 /// </summary> /// <param name="page">所在页面对象</param> /// <param name="DoPage">页面名称(不含后缀)</param> /// <param name="Title">标题</param> public static void OpenPage(System.Web.UI.Page page, string DoUrl, string Title, string Reflash) { string str = "OpenPageNew('" + Title + "', '" + DoUrl + "','" + Reflash + "')"; string js = CFun.FortmatJavaScript(str); if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "OpenProcessPage")) { page.ClientScript.RegisterStartupScript(page.GetType(), "OpenProcessPage", js); } }
//删除Cookie public void DeleteCoolie(string cookieName) { HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieName]; if (cookie != null) { cookie.Expires = DateTime.Now.AddYears(-3); cookie.Domain = CFun.GetAppStr("webDomain"); HttpContext.Current.Response.Cookies.Add(cookie); } }