214 lines
7.7 KiB
C#
214 lines
7.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.OleDb;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
|
|
public partial class admin_index2 : MyWeb.function
|
|
{
|
|
string db = ConfigurationManager.ConnectionStrings["shopConn"].ConnectionString;
|
|
string p_name = ConfigurationManager.ConnectionStrings["shopConn"].ProviderName;
|
|
string scc = ConfigurationManager.AppSettings["shopCarCode"].ToString();
|
|
MyWeb.sql sql = new MyWeb.sql();
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (MyWeb.admin.chkAdmIP && (MyWeb.admin.chkTwIP || MyWeb.admin.chkAdmIP_Enable))
|
|
{
|
|
LoadMenu();
|
|
|
|
System.Data.DataTable dt = sql.selectTable(db, p_name, "Select * from company where num=1");
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
if (dt.Rows[0]["log_menu"].ToString().IndexOf("A", 0) > -1)
|
|
{
|
|
show_counter();
|
|
//顯示流量統計與會員統計區塊(有統計管理及會員管理才開啟)
|
|
}
|
|
if (dt.Rows[0]["log_menu"].ToString().IndexOf("B", 0) > -1)
|
|
{
|
|
show_product();
|
|
//顯示訂單相關區塊(有訂單管理時才開啟)
|
|
}
|
|
if (dt.Rows[0]["log_menu"].ToString().IndexOf("C", 0) > -1)
|
|
{
|
|
|
|
//顯示未處理客服信件區塊(有客服管理才開啟)
|
|
}
|
|
if (dt.Rows[0]["log_menu"].ToString().IndexOf("D", 0) > -1)
|
|
{
|
|
show_test();
|
|
// 顯示登入後Cookies資訊(開發人員使用)
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (MyWeb.ip.Get() == "127.0.0.1")
|
|
{
|
|
string[] paths = { "~/css/contentbuilder", "~/js/bootstrap5" };
|
|
foreach (var path in paths)
|
|
{
|
|
DirectoryInfo dir = new DirectoryInfo(Server.MapPath(path));
|
|
if (!dir.Exists)
|
|
Literal1.Text += "<div class=\"alert alert-danger\" role=\"alert\">閃電編緝器缺少目錄:" + path+"</div>";
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
HttpContext.Current.Response.Clear();
|
|
HttpContext.Current.Response.StatusCode = 404;
|
|
HttpContext.Current.Response.End();
|
|
}
|
|
|
|
}
|
|
|
|
public void LoadMenu()
|
|
{
|
|
MyWeb.admin admin = new MyWeb.admin();
|
|
if (admin.isLoign())
|
|
{
|
|
if (admin.info.login_ip != MyWeb.admin.MyIP)
|
|
{
|
|
Response.Redirect("~/admin/index.aspx?msg=E");
|
|
}
|
|
|
|
DataTable menuDt = new DataTable();
|
|
OleDbConnection sqlConn = sql.conn(db, p_name);
|
|
|
|
try
|
|
{
|
|
sqlConn.Open();
|
|
OleDbCommand sqlCmd = new OleDbCommand("", sqlConn);
|
|
sqlCmd.CommandText = "SELECT * FROM item Where root<>0";
|
|
|
|
if (admin.info.group == "EZ")
|
|
{
|
|
//nothing
|
|
}
|
|
else if (!isStrNull(admin.info.power))
|
|
{
|
|
string v = admin.info.power;
|
|
if (Right(v, 1) == ",") { v = Left(v, v.Length - 1); }
|
|
if (Left(v, 1) == ",") { v = Right(v, v.Length - 1); }
|
|
sqlCmd.CommandText += " and num in (" + (!isStrNull(v) && IsNumeric(v) ? v : "-1") + ")";
|
|
}
|
|
else
|
|
{
|
|
sqlCmd.CommandText += " and num=-1";
|
|
}
|
|
sqlCmd.CommandText += " order by root, range";
|
|
menuDt = sql.dataTable(sqlCmd);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Response.Write(ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
sqlConn.Close();
|
|
sqlConn.Dispose();
|
|
}
|
|
|
|
try
|
|
{
|
|
MyWeb.config.IMenu menu = (MyWeb.config.IMenu)Master.FindControl("menu");
|
|
if (menu != null) { menu.Data(menuDt); }
|
|
}
|
|
catch (Exception) { }
|
|
}
|
|
|
|
}
|
|
|
|
public void show_counter()
|
|
{
|
|
|
|
this.P_counter.Visible = true;
|
|
|
|
//System.Data.DataTable dt = sql.selectTable(db, p_name, "SELECT [date],[today],[total] FROM web_counter order by id desc");
|
|
//if (dt.Rows.Count > 0)
|
|
//{
|
|
// int today_counter = 0;
|
|
// if ((DateTime)dt.Rows[0]["date"] == System.DateTime.Now)
|
|
// {
|
|
// today_counter = (int)dt.Rows[0]["today"];
|
|
// }
|
|
|
|
// this.L_counter1.Text = dt.Rows[0]["total"].ToString();
|
|
// //網站總流量
|
|
// this.L_counter2.Text = today_counter.ToString();
|
|
// //本日總流量
|
|
//}
|
|
|
|
this.L_counter3.Text = "0"; this.L_counter4.Text = "0";
|
|
System.Data.DataTable dt2 = sql.selectTable(db, p_name, "SELECT count(num) as all_member FROM member");
|
|
if (dt2.Rows.Count > 0) { this.L_counter3.Text = dt2.Rows[0]["all_member"].ToString(); }
|
|
DateTime Now = DateTime.Now.Date;
|
|
if (sql.dbIsSql()) //判斷SQL或Access資料庫
|
|
{
|
|
dt2 = sql.selectTable(db, p_name, "SELECT count(num) as all_member FROM member where reg_time>='" + Now.ToString("yyyy-MM-dd") + "' and reg_time<'" + Now.AddDays(1).ToString("yyyy-MM-dd") + "'");
|
|
}
|
|
else
|
|
{
|
|
dt2 = sql.selectTable(db, p_name, "SELECT count(num) as all_member FROM member where reg_time>=#" + Now.ToString("yyyy-MM-dd") + "# and reg_time<#" + Now.AddDays(1).ToString("yyyy-MM-dd") + "#");
|
|
}
|
|
if (dt2.Rows.Count > 0) { this.L_counter4.Text = dt2.Rows[0]["all_member"].ToString(); }
|
|
|
|
}
|
|
|
|
public void show_product()
|
|
{
|
|
|
|
int kind1_count = 0;
|
|
//未處理訂單
|
|
|
|
string kind1_words = null;
|
|
|
|
//未處理訂單
|
|
System.Data.DataTable dt = sql.selectTable(db, p_name, "SELECT order_no,up_time FROM pro_order WHERE keyin1='A01'");
|
|
kind1_count = dt.Rows.Count;
|
|
int j = (dt.Rows.Count > 10 ? 9 : dt.Rows.Count - 1);
|
|
kind1_words += "<li>";
|
|
bool addMore = false;
|
|
for (int i = 0; i <= j; i++)
|
|
{
|
|
kind1_words += (i > 0 ? "、" : "") + dt.Rows[i]["order_no"].ToString();
|
|
if (i == j & dt.Rows.Count > 10) { addMore = true; break; }
|
|
}
|
|
if (addMore) { kind1_words += "…MORE"; }
|
|
kind1_words += "</li>";
|
|
|
|
|
|
|
|
this.L_product.Text += "您目前尚有 <strong>" + kind1_count.ToString() + "</strong> 筆訂單未處理,您可至【 <a href=\"order/index.aspx\">訂單管理 > 訂單資料查詢</a> 】中查詢訂單資訊。";
|
|
this.L_product.Text += "<br>未處理訂單資訊如下:<ul class=\"list-unstyled news_list\">" + kind1_words + "</ul>";
|
|
this.P_product.Visible = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void show_test()
|
|
{
|
|
if ((Request.Cookies[scc + "_ez_cus"] != null))
|
|
{
|
|
TestPanel.Visible = true;
|
|
this.L_test.Text = "<li>登錄帳號:" + HttpUtility.UrlDecode(Request.Cookies[scc + "_ez_cus"]["u_id"]) + "</li>";
|
|
this.L_test.Text += "<li>可用項目:" + Request.Cookies[scc + "_ez_cus"]["power"] + "</li>";
|
|
this.L_test.Text += "<li>使用權限:" + Request.Cookies[scc + "_ez_cus"]["group"] + "</li>";
|
|
this.L_test.Text += "<li>登錄時間:" + HttpUtility.UrlDecode(Request.Cookies[scc + "_ez_cus"]["login_time"]) + "</li>";
|
|
this.L_test.Text += "<li>選單類型:" + Request.Cookies[scc + "_ez_cus"]["menu"] + "</li>";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} |