1
0
mirror of https://e.coding.net/circlecloud/CitySunlight.git synced 2024-12-04 12:58:46 +00:00

添加注释,删除部分无效数据...

This commit is contained in:
j502647092 2015-06-19 15:12:19 +08:00
parent dacca6c619
commit 6c0935ba9e
6 changed files with 121 additions and 124 deletions

Binary file not shown.

View File

@ -11,17 +11,30 @@ namespace CitySunlight
private const String tbname = "tb_user"; private const String tbname = "tb_user";
private static Dictionary<String, int> trytimes = new Dictionary<string, int>(); private static Dictionary<String, int> trytimes = new Dictionary<string, int>();
private static SqlHelper sql = new SqlHelper("Data Source=.;Initial Catalog=myApplication;User ID=sa;Password=325325"); private static SqlHelper sql = new SqlHelper("Data Source=.;Initial Catalog=myApplication;User ID=sa;Password=325325");
/// <summary>
/// 登录错误增加错误次数
/// </summary>
/// <param name="username">用户名</param>
/// <returns>错误次数</returns>
public static int ErrLogin(String username) public static int ErrLogin(String username)
{ {
return UpdateTimes(username, true); return UpdateTimes(username, true);
} }
/// <summary>
/// 获取错误次数
/// </summary>
/// <param name="username">用户名</param>
/// <returns></returns>
public static int GetTimes(String username) public static int GetTimes(String username)
{ {
return UpdateTimes(username, false); return UpdateTimes(username, false);
} }
/// <summary>
/// 更新错误次数
/// </summary>
/// <param name="username">用户名</param>
/// <param name="add">是否添加</param>
/// <returns></returns>
private static int UpdateTimes(String username, bool add) private static int UpdateTimes(String username, bool add)
{ {
if (!trytimes.ContainsKey(username)) if (!trytimes.ContainsKey(username))
@ -34,7 +47,12 @@ namespace CitySunlight
} }
return trytimes[username]; return trytimes[username];
} }
/// <summary>
/// 用户登录
/// </summary>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns>是否登录成功</returns>
public static bool LoginUser(String username, String password) public static bool LoginUser(String username, String password)
{ {
DataTable dt = sql.ExecuteDataTable("select * from " + tbname + " where UserName='" + username + "' and PassWord='" + password + "'", CommandType.Text); DataTable dt = sql.ExecuteDataTable("select * from " + tbname + " where UserName='" + username + "' and PassWord='" + password + "'", CommandType.Text);
@ -46,7 +64,11 @@ namespace CitySunlight
UpdateTimes(username, true); UpdateTimes(username, true);
return false; return false;
} }
/// <summary>
/// 检查用户是否存在
/// </summary>
/// <param name="username">用户名</param>
/// <returns>是否存在</returns>
public static bool isExist(String username) public static bool isExist(String username)
{ {
DataTable dt = sql.ExecuteDataTable("select * from " + tbname + " where UserName='" + username + "'", CommandType.Text); DataTable dt = sql.ExecuteDataTable("select * from " + tbname + " where UserName='" + username + "'", CommandType.Text);
@ -56,7 +78,12 @@ namespace CitySunlight
} }
return false; return false;
} }
/// <summary>
/// 注册用户
/// </summary>
/// <param name="username">用户名</param>
/// <param name="password">密码</param>
/// <returns>是否注册成功</returns>
public static bool RegisterUser(String username, String password) public static bool RegisterUser(String username, String password)
{ {
int insert = sql.ExecuteNonQuery("insert into " + tbname + "(UserName,PassWord) values('" + username + "','" + password + "')"); int insert = sql.ExecuteNonQuery("insert into " + tbname + "(UserName,PassWord) values('" + username + "','" + password + "')");

View File

@ -69,7 +69,6 @@
<Content Include="Admin.aspx" /> <Content Include="Admin.aspx" />
<Content Include="Main.aspx" /> <Content Include="Main.aspx" />
<Content Include="Account\Register.aspx" /> <Content Include="Account\Register.aspx" />
<Content Include="Picture\1_jtb.jpg" />
<Content Include="Picture\empty.jpg" /> <Content Include="Picture\empty.jpg" />
<Content Include="Picture\main.jpg" /> <Content Include="Picture\main.jpg" />
<Content Include="Product\ProductClassEdit.aspx" /> <Content Include="Product\ProductClassEdit.aspx" />
@ -147,7 +146,6 @@
<DependentUpon>Login.aspx</DependentUpon> <DependentUpon>Login.aspx</DependentUpon>
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="packages.config" /> <Content Include="packages.config" />

View File

@ -7,6 +7,11 @@ namespace CitySunlight
{ {
public static class HttpUtils public static class HttpUtils
{ {
/// <summary>
/// 通过标签名获取数据
/// </summary>
/// <param name="tagName">标签名称</param>
/// <returns>标签数据</returns>
public static String getElementsbyName(String tagName) public static String getElementsbyName(String tagName)
{ {
if (HttpContext.Current.Request.Form[tagName] != null) if (HttpContext.Current.Request.Form[tagName] != null)
@ -14,6 +19,11 @@ namespace CitySunlight
else else
return null; return null;
} }
/// <summary>
/// 查询Get标签数据
/// </summary>
/// <param name="tagName">Get标签</param>
/// <returns>标签数据</returns>
public static String getQueryString(String tagName) public static String getQueryString(String tagName)
{ {
if (HttpContext.Current.Request.QueryString[tagName] != null) if (HttpContext.Current.Request.QueryString[tagName] != null)
@ -21,6 +31,11 @@ namespace CitySunlight
else else
return null; return null;
} }
/// <summary>
/// 通过标签获取文件数据
/// </summary>
/// <param name="tagName">文件标签</param>
/// <returns>文件数据</returns>
public static HttpPostedFile getFilebyName(String tagName) public static HttpPostedFile getFilebyName(String tagName)
{ {
HttpPostedFile file = HttpContext.Current.Request.Files[tagName]; HttpPostedFile file = HttpContext.Current.Request.Files[tagName];
@ -29,18 +44,38 @@ namespace CitySunlight
else else
return null; return null;
} }
/// <summary>
/// 获得1970年1月1日到现在的秒数
/// </summary>
/// <returns>1970年1月1日到现在的秒数</returns>
public static long currentTimeMillis() public static long currentTimeMillis()
{ {
return (long)((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds); return (long)((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds);
} }
/// <summary>
/// 添加Td
/// </summary>
/// <returns>Td的html代码</returns>
public static String addTd() public static String addTd()
{ {
return "<td></td>"; return "<td></td>";
} }
/// <summary>
/// 添加Td(带内容)
/// </summary>
/// <param name="s">内容</param>
/// <returns>Td带内容的Html代码</returns>
public static String addTd(String s) public static String addTd(String s)
{ {
return String.Format("<td align=\"center\">{0}</td>", s); return String.Format("<td align=\"center\">{0}</td>", s);
} }
/// <summary>
/// 可配置大小的Td标签
/// </summary>
/// <param name="s">内容</param>
/// <param name="col">宽</param>
/// <param name="row">高</param>
/// <returns></returns>
public static String addTd(String s, int col, int row) public static String addTd(String s, int col, int row)
{ {
String td = "<td align=\"center\""; String td = "<td align=\"center\"";
@ -48,6 +83,11 @@ namespace CitySunlight
td += row != 0 ? String.Format(" rowspan=\"{0}\"", row) : ""; td += row != 0 ? String.Format(" rowspan=\"{0}\"", row) : "";
return String.Format(td + " >{0}</td>", s); return String.Format(td + " >{0}</td>", s);
} }
/// <summary>
/// String尝试转换为Int(扩展方法)
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static int ToInt(this string s) public static int ToInt(this string s)
{ {
int i; int i;
@ -57,6 +97,11 @@ namespace CitySunlight
} }
return i; return i;
} }
/// <summary>
/// String尝试转换为decimal(扩展方法)
/// </summary>
/// <param name="s"></param>
/// <returns></returns>
public static decimal Todecimal(this string s) public static decimal Todecimal(this string s)
{ {
decimal i; decimal i;

View File

@ -12,12 +12,21 @@ namespace CitySunlight
//分类表名 //分类表名
public const String tbname = "tb_proclass"; public const String tbname = "tb_proclass";
//获得分类列表默认选择第一个 /// <summary>
/// 获得分类列表的Html代码,默认选择第一个
/// </summary>
/// <param name="name">列表名</param>
/// <returns>分类列表的Html代码</returns>
public static String getOptionString(String name) public static String getOptionString(String name)
{ {
return getOptionString(name, "0"); return getOptionString(name, "0");
} }
//获得分类列表 可以配置选项 /// <summary>
/// 获得分类列表的Html代码,可配置选项(数据库部分)
/// </summary>
/// <param name="name">列表名</param>
/// <param name="df">列表选项</param>
/// <returns>分类列表的Html代码</returns>
public static String getOptionString(String name, String df) public static String getOptionString(String name, String df)
{ {
String html = "<select style=\"width: 120px\" Name=\"" + name + "\">"; String html = "<select style=\"width: 120px\" Name=\"" + name + "\">";
@ -32,7 +41,11 @@ namespace CitySunlight
html += "</select>"; html += "</select>";
return html; return html;
} }
//获得分类名称通过ID /// <summary>
/// 通过ID获得分类名称(数据库部分)
/// </summary>
/// <param name="Nid">分类ID</param>
/// <returns>分类名称</returns>
public static String getClassName(int Nid) public static String getClassName(int Nid)
{ {
DataTable dt = sql.ExecuteDataTable("select * from " + tbname + " where nid='" + Nid + "'", CommandType.Text); DataTable dt = sql.ExecuteDataTable("select * from " + tbname + " where nid='" + Nid + "'", CommandType.Text);
@ -41,16 +54,30 @@ namespace CitySunlight
else else
return "分类已被删除"; return "分类已被删除";
} }
//判断分类是否存在 /// <summary>
/// 判断分类是否存在(数据库部分)
/// </summary>
/// <param name="name">分类名称</param>
/// <returns>是否存在</returns>
public static bool isExist(String name) public static bool isExist(String name)
{ {
return sql.ExecuteDataTable("select * from " + tbname + " where ProClassName='" + name + "'", CommandType.Text).Rows.Count > 0; return sql.ExecuteDataTable("select * from " + tbname + " where ProClassName='" + name + "'", CommandType.Text).Rows.Count > 0;
} }
/// <summary>
/// 通过Id判断分类是否存在(数据库部分)
/// </summary>
/// <param name="nid">分类ID</param>
/// <returns>是否存在</returns>
public static bool isExist(int nid) public static bool isExist(int nid)
{ {
return sql.ExecuteDataTable("select * from " + tbname + " where Nid='" + nid + "'", CommandType.Text).Rows.Count > 0; return sql.ExecuteDataTable("select * from " + tbname + " where Nid='" + nid + "'", CommandType.Text).Rows.Count > 0;
} }
//添加分类 /// <summary>
/// 添加分类(数据库部分)
/// </summary>
/// <param name="Pid"></param>
/// <param name="classname"></param>
/// <returns>是否成功</returns>
public static bool addclass(int Pid, String classname) public static bool addclass(int Pid, String classname)
{ {
int j = sql.ExecuteNonQuery("insert into " + tbname + "(Pid,ProClassName) values('" + Pid + "','" + classname + "')", CommandType.Text); int j = sql.ExecuteNonQuery("insert into " + tbname + "(Pid,ProClassName) values('" + Pid + "','" + classname + "')", CommandType.Text);
@ -58,7 +85,11 @@ namespace CitySunlight
return true; return true;
return false; return false;
} }
//删除分类 /// <summary>
/// 删除分类(数据库部分)
/// </summary>
/// <param name="Nid"></param>
/// <returns>是否成功</returns>
public static bool removeclass(int Nid) public static bool removeclass(int Nid)
{ {
if (Nid != 0) if (Nid != 0)
@ -69,7 +100,12 @@ namespace CitySunlight
} }
return false; return false;
} }
//修改分类 /// <summary>
/// 修改分类(数据库部分)
/// </summary>
/// <param name="Nid">分类ID</param>
/// <param name="cname">修改后的名称</param>
/// <returns>是否成功</returns>
public static bool editclass(int Nid, String cname) public static bool editclass(int Nid, String cname)
{ {
if (Nid != 0) if (Nid != 0)

View File

@ -1,109 +0,0 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
namespace CitySunlight
{
public static class Utils
{
public static IList<ItemInfo> ToItemInfoList(this DataTable t, string pFieldValue, string pFieldText)
{
IList<ItemInfo> list = new List<ItemInfo>();
if (t == null)
{
return list;
}
foreach (DataRow row in t.Rows)
{
list.Add(ItemInfo.Create(row[pFieldValue].ToString(), row[pFieldText].ToString()));
}
return list;
}
public static string GetSelect(IList<ItemInfo> pInfolist, string pControlName, string pEditValue, string pFirstValue, string pFirstText)
{
StringBuilder sbStr = new StringBuilder();
sbStr.Append("<select id=\"" + pControlName + "\" name=\"" + pControlName + "\">");
if (pFirstText.Length > 0)
{
sbStr.Append("<option value=\"");
sbStr.Append(pFirstValue);
sbStr.Append("\"");
if (pFirstValue == pEditValue)
{
sbStr.Append(" selected=\"selected\"");
}
sbStr.Append(">");
sbStr.Append(pFirstText);
sbStr.Append("</option>");
}
foreach (ItemInfo info in pInfolist)
{
sbStr.Append("<option value=\"");
sbStr.Append(info.id);
sbStr.Append("\"");
if (pEditValue == info.id)
{
sbStr.Append(" selected=\"selected\"");
}
sbStr.Append(">");
sbStr.Append(info.name);
sbStr.Append("</option>");
}
sbStr.Append("<lect>");
return sbStr.ToString();
}
}
public class ItemInfo
{
public string id;
public string name = string.Empty;
public string detail;
public ItemInfo() { }
public ItemInfo(string pId, string pName)
{
this.id = pId;
this.name = pName;
}
public ItemInfo(string pId, string pName, string pDetail)
{
this.id = pId;
this.name = pName;
this.detail = pDetail;
}
public override string ToString()
{
return this.name;
}
public static ItemInfo Create(string pName)
{
return new ItemInfo(pName, pName, "");
}
public static ItemInfo Create(string pId, string pName)
{
return new ItemInfo(pId, pName, "");
}
public static ItemInfo Create(string pId, string pName, string pDetail)
{
return new ItemInfo(pId, pName, pDetail);
}
}
}