Beispiel #1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string sql = "SELECT nId,IsLogin,LoginIP FROM TS_Login WHERE vLogin='******' and vPsw='{1}'";

        string pass = common.md5(this.txtPassword.Text.Trim());

        sql = String.Format(sql, txtUser.Text, pass);
        dbConfig DB = new dbConfig();
        //保存APPPath
        DB.UpdateProperty("AppPath", Server.MapPath(Request.ApplicationPath));

        string UserID = DB.ExecuteScalar(sql);
        if (UserID != "")
        {
            string useridstr = DB.CreateDataSet(sql).Tables[0].Rows[0]["nId"].ToString();
            string userislogin = DB.CreateDataSet(sql).Tables[0].Rows[0]["IsLogin"].ToString();
            string useripstr = DB.CreateDataSet(sql).Tables[0].Rows[0]["LoginIP"].ToString();
            string userip = Request.ServerVariables["Remote_Addr"].ToString();
            Session["FromDate"] = System.DateTime.Today.AddDays(-1);
            Session["ToDate"] = System.DateTime.Today.AddDays(-1);
            //将登录信息定入日志文件
            common.setLog(useridstr, DB.getUserName(UserID), userip, "登录");
            Session["adminName"] = txtUser.Text.Trim();

            /*if (userislogin == "1")
            {
                if (userip == useripstr)
                {
                    FormsAuthentication.RedirectFromLoginPage(UserID, false);

                    DB.changeuserstate(useridstr, "1", userip);
                    Response.Redirect("Main.aspx");
                }
                else
                {
                    lblMessage.Text = "该用户已经登录!";
                    lblMessage.Visible = true;
                }
            }
            else
            {*/
            FormsAuthentication.RedirectFromLoginPage(UserID, false);

            //DB.changeuserstate(useridstr, "1", userip);
            Response.Redirect("Main.aspx");
            //}
        }
        else
        {
            txtUser.Focus();
            lblMessage.Text = "用户名或密码错误,请重新输入!";
            lblMessage.Visible = true;
        }
    }
Beispiel #2
0
    /// <summary>
    /// 更新
    /// </summary>
    private static void update()
    {
        database db = new dbConfig();
        DataSet ds = db.CreateDataSet("select * from TB_Update");

        if (ds == null || ds.Tables == null || ds.Tables[0] == null || ds.Tables[0].Rows.Count <= 0)
            return;

        string path = string.Empty;
        string version = string.Empty;

        foreach (DataRow row in ds.Tables[0].Rows)
        {
            if (row["vSystemType"].ToString() == "2") //windows
            {
                path = helper.VersionUpdate.UpdateFile(2, Convert.ToInt32(row["vVersion"]));
                version = helper.VersionUpdate.GetVersion(2);
                if (!string.IsNullOrEmpty(path))
                    db.ExecuteScalar("update TB_Update set vVersion=" + version + ",vAppPath='" + path + "',dUpdateDate='" + DateTime.Now.ToString() + "' where vSystemType=2");
            }

            if (row["vSystemType"].ToString() == "1") //redhat
            {
                path = helper.VersionUpdate.UpdateFile(1, Convert.ToInt32(row["vVersion"]));
                version = helper.VersionUpdate.GetVersion(1);
                if (!string.IsNullOrEmpty(path))
                    db.ExecuteScalar("update TB_Update set vVersion=" + version + ",vAppPath='" + path + "',dUpdateDate='" + DateTime.Now.ToString() + "' where vSystemType=1");
            }

            if (row["vSystemType"].ToString() == "0") //fedore
            {
                path = helper.VersionUpdate.UpdateFile(0, Convert.ToInt32(row["vVersion"]));
                version = helper.VersionUpdate.GetVersion(0);
                if (!string.IsNullOrEmpty(path))
                    db.ExecuteScalar("update TB_Update set vVersion=" + version + ",vAppPath='" + path + "',dUpdateDate='" + DateTime.Now.ToString() + "' where vSystemType=0");
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string dataType = DataType;

        dbConfig db = new dbConfig();
        DataSet ds = db.CreateDataSet("SELECT vState FROM TS_ListUpdate");
        int val = 0;
        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        {
            val = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
        }

        string sql = "Update TS_ListUpdate SET vState = " + issued(val);
        db.ExecuteScalar(sql);
    }