Ejemplo n.º 1
0
    protected void AddNewAcc_Click(object sender, EventArgs e)
    {
        string SaveDate    = "Y";
        string NewAccount  = TXTETIDNo.Text + "";
        string gETID1      = TXTETPW.Text + "";
        string gETID2      = TXTETPWChk.Text + "";
        string gETName     = TXTETName.Text + "";
        string gETTel      = TXTETTel.Text + "";
        string gETEmail    = TXTETEmail.Text + "";
        string gETOrgName  = TXTETOrgName.Text + "";
        string gETOrgGUINo = TXTETOrgGUINo.Text = "";
        string gETOrgAddr  = TXTETOrgAddr.Text + "";
        string gETOrgTel   = TXTETOrgTel.Text + "";
        string gETCOPC     = TXTETCOPC.Text + "";
        string gETTCNo01   = TXTETTCNo01.Text + "";
        string gETTCNo02   = TXTETTCNo02.Text + "";
        string gETTCNo03   = TXTETTCNo03.Text + "";
        string gETTCNo04   = TXTETTCNo04.Text + "";
        string gETOrgIssNo = TXTETOrgIssNo.Text + "";
        string gSYSID      = TXTSYSID.Text + "";
        string gTCNo01ED   = TXTTCNo01ED.Text + "";
        string gTCNo02ED   = TXTTCNo02ED.Text + "";
        string gTCNo03ED   = TXTTCNo03ED.Text + "";
        string gTCNo04ED   = TXTTCNo04ED.Text + "";
        string gETCOPCExp  = TXTETCOPCExp.Text + "";


        GBClass001 SBApp = new GBClass001();

        NewAccount = NewAccount.ToUpper();

        if (NewAccount == "")
        {
            error_msg.Text = SBApp.AlertMsg("身分證字號務必填登,謝謝!!");
            TXTETIDNo.Focus();
            return;
        }
        if (gETID1 != gETID2)
        {
            error_msg.Text = SBApp.AlertMsg("密碼與確認密碼不符");
            TXTETPW.Focus();
            return;
        }

        //帳號重覆檢查
        ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["SWCConnStr"];

        using (SqlConnection SWCConn = new SqlConnection(connectionString.ConnectionString))
        {
            SWCConn.Open();

            string strSQLUS = " select ETIDNo from ETUsers ";
            strSQLUS = strSQLUS + " where ETIDNo ='" + NewAccount + "' ";

            SqlDataReader readerUser;
            SqlCommand    objCmdUser = new SqlCommand(strSQLUS, SWCConn);
            readerUser = objCmdUser.ExecuteReader();

            if (readerUser.HasRows)
            {
                Response.Write("<script>alert('您好,此帳號已重複申請,請再次確認密碼,或與大地工程處聯繫,謝謝。'); location.href='SWC000.aspx'; </script>");
                TXTETIDNo.Focus();
                SaveDate = "N";
                return;
            }
        }

        string UserSqlStr = "";

        if (SaveDate == "Y")
        {
            UserSqlStr = UserSqlStr + " INSERT INTO ETUsers (ETID,ETIDNo,ETStatus,status) VALUES ('" + NewAccount + "','" + NewAccount + "','0','申請中') ;";

            UserSqlStr = UserSqlStr + " Update ETUsers Set ";

            UserSqlStr = UserSqlStr + " ETPW =N'" + gETID1 + "', ";
            UserSqlStr = UserSqlStr + " ETName =N'" + gETName + "', ";
            UserSqlStr = UserSqlStr + " ETTel =N'" + gETTel + "', ";
            UserSqlStr = UserSqlStr + " ETEmail =N'" + gETEmail + "', ";
            UserSqlStr = UserSqlStr + " ETOrgName =N'" + gETOrgName + "', ";
            UserSqlStr = UserSqlStr + " ETOrgGUINo =N'" + gETOrgGUINo + "', ";
            UserSqlStr = UserSqlStr + " ETOrgAddr =N'" + gETOrgAddr + "', ";
            UserSqlStr = UserSqlStr + " ETOrgTel =N'" + gETOrgTel + "', ";
            UserSqlStr = UserSqlStr + " ETCOPC =N'" + gETCOPC + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo01 =N'" + gETTCNo01 + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo02 =N'" + gETTCNo02 + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo03 =N'" + gETTCNo03 + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo04 =N'" + gETTCNo04 + "', ";
            UserSqlStr = UserSqlStr + " ETOrgIssNo =N'" + gETOrgIssNo + "', ";
            UserSqlStr = UserSqlStr + " TCNo01ED =N'" + gTCNo01ED + "', ";
            UserSqlStr = UserSqlStr + " TCNo02ED =N'" + gTCNo02ED + "', ";
            UserSqlStr = UserSqlStr + " TCNo03ED =N'" + gTCNo03ED + "', ";
            UserSqlStr = UserSqlStr + " TCNo04ED =N'" + gTCNo04ED + "', ";
            UserSqlStr = UserSqlStr + " ETCOPCExp =N'" + gETCOPCExp + "', ";
            UserSqlStr = UserSqlStr + " SYSID ='" + gSYSID + "', ";
            UserSqlStr = UserSqlStr + " saveuser = '******', ";
            UserSqlStr = UserSqlStr + " savedate = getdate() ";
            UserSqlStr = UserSqlStr + " Where ETIDNo = '" + NewAccount + "'";

            using (SqlConnection SWCConn = new SqlConnection(connectionString.ConnectionString))
            {
                SWCConn.Open();

                SqlCommand objCmdUser = new SqlCommand(UserSqlStr, SWCConn);
                objCmdUser.ExecuteNonQuery();
                objCmdUser.Dispose();

                GBClass001 CL01 = new GBClass001();

                CL01.Mail_Send(GetMailTo(), MailSub(), MailBody());
            }

            //上傳檔案…
            UpLoadTempFileMoveChk(NewAccount);
        }
        GetUserData(NewAccount);

        Response.Write("<script>alert('已送出帳號申請,請等待審核通知,申請結果將以E-mail通知。'); location.href='SWC000.aspx'; </script>");
    }
Ejemplo n.º 2
0
    protected void SaveAccount_Click(object sender, EventArgs e)
    {
        error_msg.Text = "";

        string SSPW = Session["PW"] + "";

        string SaveDate    = "Y";
        string NewAccount  = TXTETIDNo.Text + "";
        string gETID1      = TXTETPW.Text + "";
        string gETID2      = TXTETPWChk.Text + "";
        string gETName     = TXTETName.Text + "";
        string gETTel      = TXTETTel.Text + "";
        string gETEmail    = TXTETEmail.Text + "";
        string gETOrgName  = TXTETOrgName.Text + "";
        string gETOrgGUINo = TXTETOrgGUINo.Text + "";
        string gETOrgAddr  = TXTETOrgAddr.Text + "";
        string gETOrgTel   = TXTETOrgTel.Text + "";
        string gETCOPC     = TXTETCOPC.Text + "";
        string gETTCNo01   = TXTETTCNo01.Text + "";
        string gETTCNo02   = TXTETTCNo02.Text + "";
        string gETTCNo03   = TXTETTCNo03.Text + "";
        string gETTCNo04   = TXTETTCNo04.Text + "";
        string gETOrgIssNo = TXTETOrgIssNo.Text + "";
        string gSYSID      = TXTSYSID.Text + "";
        string gOldPw      = TXTETPWOLD.Text + "";
        string gTCNo01ED   = TXTTCNo01ED.Text + "";
        string gTCNo02ED   = TXTTCNo02ED.Text + "";
        string gTCNo03ED   = TXTTCNo03ED.Text + "";
        string gTCNo04ED   = TXTTCNo04ED.Text + "";
        string gETCOPCExp  = TXTETCOPCExp.Text + "";

        GBClass001 SBApp = new GBClass001();

        if (gOldPw == "" && (gETID1 != "" || gETID2 != ""))
        {
            SaveDate       = "N";
            error_msg.Text = SBApp.AlertMsg("請輸入舊密碼,謝謝!!");
            TXTETIDNo.Focus();
            return;
        }
        if (gOldPw != "" && (SSPW != gOldPw))
        {
            SaveDate       = "N";
            error_msg.Text = SBApp.AlertMsg("密碼不正確請重新輸入,謝謝!!");
            TXTETIDNo.Focus();
            return;
        }

        if (gETID1 != gETID2)
        {
            SaveDate       = "N";
            error_msg.Text = SBApp.AlertMsg("密碼與確認密碼不符");
            TXTETPW.Focus();
            return;
        }

        if (SaveDate == "Y")
        {
            string UserSqlStr = "";

            UserSqlStr = UserSqlStr + " Update ETUsers Set ";
            if (gETID1 != "")
            {
                UserSqlStr    = UserSqlStr + " ETPW ='" + gETID1 + "', ";
                Session["PW"] = gETID1;
            }
            UserSqlStr = UserSqlStr + " ETName =N'" + gETName + "', ";
            UserSqlStr = UserSqlStr + " ETTel =N'" + gETTel + "', ";
            UserSqlStr = UserSqlStr + " ETEmail =N'" + gETEmail + "', ";
            UserSqlStr = UserSqlStr + " ETOrgName =N'" + gETOrgName + "', ";
            UserSqlStr = UserSqlStr + " ETOrgGUINo =N'" + gETOrgGUINo + "', ";
            UserSqlStr = UserSqlStr + " ETOrgAddr =N'" + gETOrgAddr + "', ";
            UserSqlStr = UserSqlStr + " ETOrgTel =N'" + gETOrgTel + "', ";
            UserSqlStr = UserSqlStr + " ETCOPC =N'" + gETCOPC + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo01 =N'" + gETTCNo01 + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo02 =N'" + gETTCNo02 + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo03 =N'" + gETTCNo03 + "', ";
            UserSqlStr = UserSqlStr + " ETTCNo04 =N'" + gETTCNo04 + "', ";
            UserSqlStr = UserSqlStr + " ETOrgIssNo =N'" + gETOrgIssNo + "', ";
            UserSqlStr = UserSqlStr + " TCNo01ED =N'" + gTCNo01ED + "', ";
            UserSqlStr = UserSqlStr + " TCNo02ED =N'" + gTCNo02ED + "', ";
            UserSqlStr = UserSqlStr + " TCNo03ED =N'" + gTCNo03ED + "', ";
            UserSqlStr = UserSqlStr + " TCNo04ED =N'" + gTCNo04ED + "', ";
            UserSqlStr = UserSqlStr + " ETCOPCExp =N'" + gETCOPCExp + "', ";
            UserSqlStr = UserSqlStr + " SYSID =N'" + gSYSID + "', ";
            UserSqlStr = UserSqlStr + " saveuser = N'" + NewAccount + "', ";
            UserSqlStr = UserSqlStr + " savedate = getdate() ";
            UserSqlStr = UserSqlStr + " Where ETIDNo = '" + NewAccount + "'";

            ConnectionStringSettings connectionString = ConfigurationManager.ConnectionStrings["SWCConnStr"];
            using (SqlConnection SWCConn = new SqlConnection(connectionString.ConnectionString))
            {
                SWCConn.Open();

                SqlCommand objCmdUser = new SqlCommand(UserSqlStr, SWCConn);
                objCmdUser.ExecuteNonQuery();
                objCmdUser.Dispose();
            }

            //上傳檔案…
            UpLoadTempFileMoveChk(NewAccount);

            GetUserData(NewAccount);

            Response.Write("<script>alert('資料已存檔'); location.href='SWC001.aspx'; </script>");
        }
    }