コード例 #1
0
ファイル: ScenceDAL.cs プロジェクト: zhouchm/School
 public static Scence ToScence(DataRow row)
 {
     Scence scence = new Scence();
     scence.SceId = (string)row["SceId"];
     scence.ScenceName = (string)row["ScenceName"];
     return scence;
 }
コード例 #2
0
ファイル: ScenceDAL.cs プロジェクト: zhouchm/School
 public static void Insert(Scence scence)
 {
     //bit类型,在sql语句中要写0、1
     //在.net中要用bool表示
     string time = DateTime.Now.ToLocalTime().ToString();
     SqlHelper.ExecuteNonQuery(@"insert into T_Scence(
         SceId,ScenceName,utime) values(@SceId,@ScenceName,@utime)",
             new SqlParameter("@SceId", scence.SceId),
             new SqlParameter("@ScenceName", scence.ScenceName),
             new SqlParameter("@utime",time));
 }
コード例 #3
0
ファイル: ScenceAdd.ashx.cs プロジェクト: zhouchm/School
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/html";
     string AdminName = (string)context.Session["LoginAdminName"];
     if (AdminName == null)
     {
         var data = new { Title = "现代科技体验中心", Msg = "" };
         string html = CommonHelper.RenderHtml("../html/AdminLogin.htm", data);
         context.Response.Write(html);
     }
     else
     {
         string action = context.Request["Action"];
         if (action == "add")
         {
             Scence Scence = new Scence();
             string s = context.Request["SceId"];
             s = Convert.ToInt32(s) + "";
             int num = (int)SqlHelper.ExecuteScalar("select COUNT(*) from T_Scence where SceId=@SceId", new SqlParameter("@SceId", s));
             if (num <= 0)
             {
                 Scence.SceId = s;
                 Scence.ScenceName = context.Request["ScenceName"];  //初始密码为用户名
                 ScenceDAL.Insert(Scence);
                 context.Response.Redirect("ScenceList.ashx");
             }
             else
             {
                 var data = new { Title = "现代科技体验中心", Name = AdminName, Msg = "当前编号已存在!"};
                 string html = CommonHelper.RenderHtml("../html/ScenceAdd.htm", data);
                 context.Response.Write(html);
             }
         }
         else
         {
             var data = new { Title = "现代科技体验中心", Name = AdminName, Msg = "" };
             string html = CommonHelper.RenderHtml("../html/ScenceAdd.htm", data);
             context.Response.Write(html);
         }
     }
 }
コード例 #4
0
ファイル: ScenceEdit.ashx.cs プロジェクト: zhouchm/School
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            string SceId = null;
            string AdminName = (string)context.Session["LoginAdminName"];
            if (AdminName == null)
            {
                var data = new { Title = "现代科技体验中心", Msg = "" };
                string html = CommonHelper.RenderHtml("../html/AdminLogin.htm", data);
                context.Response.Write(html);
            }
            else
            {
                string action = context.Request["Action"];
                if (action == "Sce_edit")
                {
                    SceId = context.Request["SceId"];
                    DataTable dt = SqlHelper.ExecuteDataTable("select * from T_Scence where SceId=@SceId", new SqlParameter("@SceId", SceId));
                    Scence Scence = new Scence();
                    Scence = ScenceDAL.ToScence(dt.Rows[0]);
                    var data = new { Title = "现代科技体验中心", Action = "Sce_update", Scence, Name = AdminName };
                    string html = CommonHelper.RenderHtml("../html/ScenceEdit.htm", data);
                    context.Response.Write(html);
                }
                else if (action == "Sce_update")
                {
                    SceId = context.Request["SceId"];
                    DataTable dt = SqlHelper.ExecuteDataTable("select * from T_Scence where SceId=@SceId", new SqlParameter("@SceId", SceId));
                    if (dt.Rows.Count <= 0)
                    {
                        context.Response.Write("找不到编号为" + SceId + "场景");
                    }
                    else if (dt.Rows.Count > 1)
                    {
                        context.Response.Write("错误!");
                    }
                    else
                    {
                        string ScenceName = context.Request["ScenceName"];
                        ScenceDAL.Update(ScenceName, SceId);
                        context.Response.Redirect("ScenceList.ashx");
                    }
                }
                else if (action == "DevDelete")
                {
                    SceId = context.Request["SceId"];
                    string DevId=context.Request["DevId"];
                    SqlHelper.ExecuteNonQuery("Delete from T_SceDevList where SceId=@SceId and DevId=@DevId", new SqlParameter("@SceId", SceId),
                        new SqlParameter("@DevId", DevId));

                    DataTable DeviceList = SqlHelper.ExecuteDataTable("select * from T_SceDevList where SceId=@SceId", new SqlParameter("@SceId", SceId));
                    var data = new { Title = "现代科技体验中心", SceId, DevList = DeviceList.Rows, Name = AdminName };
                    string html = CommonHelper.RenderHtml("../html/ScenceDeviceList.htm", data);
                    context.Response.Write(html);
                }
                else if (action == "Delete")
                {
                    SceId = context.Request["SceId"];
                    SqlHelper.ExecuteNonQuery("Delete from T_SceDevList where SceId=@SceId ", new SqlParameter("@SceId", SceId));
                    SqlHelper.ExecuteNonQuery("Delete from T_Scence where SceId=@SceId", new SqlParameter("@SceId", SceId));
                    context.Response.Redirect("ScenceList.ashx");
                }
            }
        }
コード例 #5
0
ファイル: ScenceDAL.cs プロジェクト: zhouchm/School
 //public void DeleteById(Guid Id)
 //{
 //    //软删除
 //    SqlHelper.ExecuteNonQuery("Update T_Users Set IsDeleted=1 where Id=@Id",
 //        new SqlParameter("@Id", Id));
 //}
 public Scence[] ListAll()
 {
     DataTable dt = SqlHelper.ExecuteDataTable("select * from T_Scence");
     Scence[] scence = new Scence[dt.Rows.Count];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         scence[i] = ToScence(dt.Rows[i]);
     }
     return scence;
 }