Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int    OrgID         = 0;
        string MsgAccount    = "";
        string MsgPassWord   = "";
        int    Success       = 0;
        int    DataError     = 0;
        int    CheckAccount  = 0;
        int    CheckPassWord = 0;

        int.TryParse(Request.Form["OrgID"], out OrgID);
        MsgAccount  = Request.Form["MsgAccount"];
        MsgPassWord = Request.Form["MsgPassWord"];

        if (OrgID == 0)
        {
            DataError = 1;
            return;
        }
        EncryptDES enc = new EncryptDES();

        DataSet ds = new DataSet();

        using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
        {
            using (SqlCommand cmd = new SqlCommand("usp_StMsgSet_xGetStMsgSetData", sc))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@OrgID", OrgID);
                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                {
                    sc.Open();
                    da.Fill(ds);
                }
            }
        }

        DataTable dt = ds.Tables[0];

        if (dt.Rows.Count > 0)
        {
            if (MsgAccount == dt.Rows[0]["MsgAccount"].ToString())
            {
                CheckAccount = 1;
            }
            if (MsgPassWord == enc.ToDecryptDES(dt.Rows[0]["MsgPassWord"].ToString(), Convert.ToString(WebConfigurationManager.AppSettings["encryptKey"])))
            {
                CheckPassWord = 1;
            }
        }
        Dictionary <string, int> dict = new Dictionary <string, int>();

        dict.Add("DataError", DataError);
        dict.Add("CheckAccount", CheckAccount);
        dict.Add("CheckPassWord", CheckPassWord);

        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(dict));
        Response.End();
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserVM user = AuthServer.GetLoginUser();

        int    OrgID = 0;
        string MsgAccount;
        string MsgPassWord;
        int    MsgStatus;
        int    Success = 0;

        int.TryParse(Request.Form["OrgID"], out OrgID);
        MsgAccount  = Request.Form["MsgAccount"];
        MsgPassWord = Request.Form["MsgPassWord"];
        int.TryParse(Request.Form["MsgStatus"], out MsgStatus);
        if (OrgID == 0)
        {
            string script = "<script>alert('資料取得失敗');history.go(-1);</script>";
            Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
        }

        EncryptDES enc = new EncryptDES();

        DataSet ds = new DataSet();

        using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
        {
            using (SqlCommand cmd = new SqlCommand("usp_StMsgSet_xUpdateStMsgSetData", sc))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@OrgID", user.OrgID);
                cmd.Parameters.AddWithValue("@MsgAccount", MsgAccount);
                cmd.Parameters.AddWithValue("@MsgPassWord", enc.ToEncryptDES(MsgPassWord, Convert.ToString(WebConfigurationManager.AppSettings["encryptKey"])));
                cmd.Parameters.AddWithValue("@MsgStatus", MsgStatus);
                cmd.Parameters.AddWithValue("@Account", user.ID);
                SqlParameter sp = cmd.Parameters.AddWithValue("@Success", Success);
                sp.Direction = ParameterDirection.Output;

                sc.Open();
                cmd.ExecuteNonQuery();
                Success = (int)sp.Value;
            }
        }

        Dictionary <string, int> dict = new Dictionary <string, int>();

        dict.Add("Success", Success);

        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(dict));
        Response.End();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int OrgID = 0;

        int.TryParse(Request.Form["OrgID"], out OrgID);

        if (OrgID == 0)
        {
            string script = "<script>alert('資料取得失敗');history.go(-1);</script>";
            Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", script, false);
        }
        EncryptDES enc = new EncryptDES();

        DataSet ds = new DataSet();

        using (SqlConnection sc = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnDB"].ToString()))
        {
            using (SqlCommand cmd = new SqlCommand("usp_StMsgSet_xGetStMsgSetData", sc))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@OrgID", OrgID);
                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                {
                    sc.Open();
                    da.Fill(ds);
                }
            }
        }

        AnyDataVM rtn = new AnyDataVM();

        if (ds.Tables[0].Rows.Count > 0)
        {
            ds.Tables[0].Rows[0]["MsgPassWord"] = enc.ToDecryptDES(ds.Tables[0].Rows[0]["MsgPassWord"].ToString(), Convert.ToString(WebConfigurationManager.AppSettings["encryptKey"]));
        }
        rtn.message          = ds.Tables[0];
        Response.ContentType = "application/json; charset=utf-8";
        Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(rtn));
        Response.End();
    }