c# - 在 asp.net 中获取 BIOS 日期

标签 c#

我检查管理员是否有许可证所以我现在按月检查登录我正在使用系统日期进行检查但管理员更改系统日期所以我想要日期 BIOS 日期

string crt_val = "",crt_mont = "",crt_year = "";
dt_v = objdata.select_upload();
if (dt_v.Rows.Count > 0)
{
    crt_val = dt_v.Rows[0]["val"].ToString();
    crt_mont = dt_v.Rows[0]["mon"].ToString();
    crt_year = dt_v.Rows[0]["yer"].ToString();
    //yy = Convert.ToInt32(crt_year);
}
else
{
    ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('Please Update your Licence Key');", true);
    return;
}
if (Verification.Trim() != "")
{
    ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('Please Update your Licence Key');", true);
    return;
}
string fin="";
string oyear = "";
oyear = DateTime.Now.Year.ToString();
int nyear = DateTime.Now.Year + 1;
int smonth = Convert.ToInt32(DateTime.Now.ToString("MM"));
fin = oyear + "-" + nyear.ToString();
int num;
switch (crt_mont)
{
    case ("January"):
        num = 1;
        break;
    case ("February"):
        num = 2;
        break;
    case ("March"):
        num = 3;
        break;
    case ("April"):
        num = 4;
        break;
    case ("May"):
        num = 5;
        break;
    case ("June"):
        num = 6;
        break;
    case ("July"):
        num = 7;
        break;
    case ("August"):
        num = 8;
        break;
    case ("September"):
        num = 9;
        break;
    case ("October"):
        num = 10;
        break;
    case ("November"):
        num = 11;
        break;
    default:
        num = 12;
        break;
}
if ((num < smonth) || (num == smonth))
{
    ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('Please Update your Licence Key');", true);
}
else
{
    if (crt_val == "0")
    {
        Session["UserId"] = txtusername.Text.Trim();
        objuser.UserCode = txtusername.Text.Trim();
        objuser.Password = s_hex_md5(txtpassword.Text.Trim());
        string pwd = s_hex_md5(txtpassword.Text);
        objuser.Ccode = ddlCode.SelectedValue;
        objuser.Lcode = ddlLocation.SelectedValue;
        DataTable dt = new DataTable();
        dt = objdata.UserLogin(objuser);
        if (dt.Rows.Count > 0)
        {
            if ((dt.Rows[0]["UserCode"].ToString().Trim() == txtusername.Text.Trim()) && (dt.Rows[0]["Password"].ToString().Trim() == pwd) && (dt.Rows[0]["CompCode"].ToString().Trim() == ddlCode.SelectedValue) && (dt.Rows[0]["LocationCode"].ToString().Trim() == ddlLocation.SelectedValue))
            {
                Session["Isadmin"] = dt.Rows[0]["IsAdmin"].ToString().Trim();
                Session["Usernmdisplay"] = txtusername.Text.Trim();
                Session["Ccode"] = dt.Rows[0]["CompCode"].ToString().Trim();
                Session["Lcode"] = dt.Rows[0]["LocationCode"].ToString().Trim();
                if (Session["Isadmin"].ToString() == "1")
                {
                    Session["RoleCode"] = "1";
                }
                else
                {
                    Session["RoleCode"] = "2";
                }
                Response.Redirect("Dashboard.aspx");
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('User Name and Password Wrong');", true);
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Window", "alert('Please Update your Licence Key');", true);
        }
    }
    else
    { }
}

最佳答案

获取 BIOS 日期不会改变任何东西,因为如果有人更改系统日期,硬件实时时钟也会更改。

更好的选择是在客户端计算机之外检查日期,例如检查一些 URL。

关于c# - 在 asp.net 中获取 BIOS 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20741121/

相关文章:

C# 如何在不使用 WMI 的情况下查询 Windows DNS 服务器的 rrecord

c# - 是否可以在运行时更改 "kendo dataviz"图表类型

c# - 从已有返回类型的方法中获取错误

c# - 获取一个 COM 对象以在 C# 中对除 S_OK (0) 以外的任何结果抛出异常

c# - 为什么 lambda 比 IL 注入(inject)动态方法快?

c# - 根据另一个列表或不同大小对列表进行排序

c# - 使用图像参数时 Unity 连接到 Dall-E API?

c# - C#是否可以将基类的实例用于子类的不同实例?

c# - 你能防止 WPF 样式被代码覆盖吗?

c# - 双字结果的高​​效长乘法