protected void DetailsView_Route_has_Bus_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        DropDownList BS = (DropDownList)DetailsView_Route_has_Bus.FindControl("DropDownList5");

        SqlDataSource seat = new SqlDataSource();
        seat.ConnectionString =
            ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();

        String count_seat = get_seat_count(BS.SelectedValue).ToString();
        String command = "";
        String Route_has_Bus_ID = get_Route_has_Bus_ID_Last().ToString();

        command = get_insert_command(count_seat, Route_has_Bus_ID);

        if (command != "")
        {
            String insertCommand = "INSERT INTO [Seat] "
            + " (Route_has_Bus_ID, Seat_Number, Seat_Name, Seat_Status) "
            + " VALUES "
            + command
            + ";";

            seat.InsertCommand = insertCommand;
            seat.Insert();
        }
        Response.Redirect(Request.RawUrl);
    }
Ejemplo n.º 2
0
 private void excuteNonQuery(string sql)
 {
     SqlDataSource x = new SqlDataSource();
     x.ConnectionString = @"Data Source=iii0.database.windows.net;Initial Catalog=prjTRK;Persist Security Info=True;User ID=iii;Password=P@ssw0rd";
     x.InsertCommand = sql;
     x.Insert();
     Response.Redirect("~/windowCompany/companyCheck.aspx");
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        ArrayList al = (ArrayList)Session["AnswerList"];

        if (al == null)
        {
            Response.Redirect("Exam.aspx");
        }

        resultGrid.DataSource = al;
        resultGrid.DataBind();

        // Save the results into the database.
        try {
            if (IsPostBack == false)
            {

                double questions = al.Count;
                double correct = 0.0;


                for (int i = 0; i < al.Count; i++)
                {
                    Answer a = (Answer)al[i];
                    if (a.Result == Answer.ResultValue.Correct)
                        correct++;
                }

                double score = (correct / questions) * 100;

                SqlDataSource userExamDataSource = new SqlDataSource();
                userExamDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["OnlineExamConnectionString"].ToString();
                userExamDataSource.InsertCommand = "INSERT INTO [StudentExam] ([ExamID], [DateTimeComplete], [Score], [Username]) VALUES (@ExamID, @DateTimeComplete, @Score, @Username)";

                userExamDataSource.InsertParameters.Add("ExamID", Session["ExamID"].ToString());
                userExamDataSource.InsertParameters.Add("DateTimeComplete", DateTime.Now.ToString());
                userExamDataSource.InsertParameters.Add("Score", score.ToString());
                userExamDataSource.InsertParameters.Add("Username", Session["Student"].ToString());

                int rowsAffected = userExamDataSource.Insert();
            }
        }
        catch(Exception){
                errorLabel.Text ="There was a problem saving your quiz results into our database.  Therefore, the results from this quiz will not be displayed on the list on the main menu.";
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง DIPLOMA
    /// </summary>
    /// <param name="dataInsert">Diploma Object</param>
    /// <returns>Success</returns>
    public string insertDiploma(Diploma dataInsert)
    {
        string response = "";

        int    sleepTime   = 5000;
        string DiplomaCode = dataInsert.DiplomaCode;

        for (int i = 0; i < 10; i++)
        {
            if (getDiploma(DiplomaCode).DiplomaCode != null)
            {
                Thread.Sleep(sleepTime);
                DiplomaCode = new utility().getMaxID("DIPLOMACODE", "DIPLOMA");
                sleepTime  += 5000;
            }
            else
            {
                dataInsert.DiplomaCode = DiplomaCode;
                break;
            }
        }

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle_tqf2();

        string sql = "Insert into DIPLOMA (YEARVERSION, DIPLOMACODE, CURRCODE, DOMAINTHNAME, DOMAINENNAME, DOMAINTHSHORTNAME, DOMAINENSHORTNAME) values ('" + dataInsert.YearVersion + "','" + dataInsert.DiplomaCode + "','" + dataInsert.CurrCode + "','" + dataInsert.DomainThName + "','" + dataInsert.DomainEnName + "','" + dataInsert.DomainThShortName + "','" + dataInsert.DomainEnShortName + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "Success";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertDiploma: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง PROCEEDING_DB
    /// </summary>
    /// <param name="dataInsert">EnglishDb Object</param>
    /// <returns>OK</returns>
    public string insertProceedingDb(ProceedingDbData dataInsert)
    {
        string response = "";

        int    sleepTime      = 5000;
        string ProceedingDbId = dataInsert.ProceedingDbId;

        for (int i = 0; i < 10; i++)
        {
            if (getProceedingDb(ProceedingDbId).ProceedingDbId != null)
            {
                Thread.Sleep(sleepTime);
                ProceedingDbId = getMaxIdProceedingDb();
                sleepTime     += 5000;
            }
            else
            {
                dataInsert.ProceedingDbId = ProceedingDbId;
                break;
            }
        }

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "Insert into PROCEEDING_DB (PROCEEDING_DB_ID, PROCEEDING_DB_TITLE, PROCEEDING_DB_LEVEL) values ('" + dataInsert.ProceedingDbId + "','" + dataInsert.ProceedingDbTitle + "','" + dataInsert.ProceedingDbLevel + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertProceedingDb: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ArrayList al = (ArrayList)Session["AnswerList"];

            GridView1.DataSource = al;
            GridView1.DataBind();
            //save the result into DB
            if (IsPostBack == false)
            {
                //calculate score
                double questions = al.Count;
                double correct   = 0.0;



                for (int i = 0; i < al.Count; i++)
                {
                    Answer a = (Answer)al[i];
                    if (a.Result == Answer.ResultValue.Correct)
                    {
                        correct++;
                    }
                }

                double score = (correct / questions) * 100;

                SqlDataSource test = new SqlDataSource();
                // test.ConnectionString = ConfigurationManager.ConnectionStrings["Data Source=DESKTOP-V5N37D7;Initial Catalog=OnlineQuiz;Integrated Security=True"].ToString();
                test.ConnectionString = @"Data Source=ASUS\SQLEXPRESS;Initial Catalog=OnlineQuiz;Integrated Security=True";
                test.InsertCommand    = "INSERT INTO [UserQuiz]([QuizID],[DateTimeCompleted],[CorrectAnswerCount],[UserName],[Score]) values(@QuizID,@DateTimeCompleted,@CorrectAnswerCount,@UserName,@Score)";

                test.InsertParameters.Add("QuizID", Session["QuizID"].ToString());
                test.InsertParameters.Add("DateTimeCompleted", DateTime.Now.ToString());
                test.InsertParameters.Add("CorrectAnswerCount", "12");
                test.InsertParameters.Add("UserName", User.Identity.Name);
                test.InsertParameters.Add("Score", score.ToString());
                // test.Insert();
                int rowsAffected = test.Insert();
                if (rowsAffected == 0)
                {
                    //now we have to notify that insertion did not work
                    LabelError.Text = "there was a problem in saving the data. because of this problem this quiz's result will not be displayed in the main menu";
                }
            }
        }
Ejemplo n.º 7
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง TQF2SEC4SUB1
    /// </summary>
    /// <param name="dataInsert">TQF2Sec4Sub1 Object</param>
    /// <returns>Success</returns>
    public string insertTQF2Sec4Sub1(TQF2Sec4Sub1 dataInsert)
    {
        string response = "";

        int    sleepTime  = 5000;
        string T2S4Sub1No = dataInsert.T2S4Sub1No;

        for (int i = 0; i < 10; i++)
        {
            if (getTQF2Sec4Sub1(T2S4Sub1No).T2S4Sub1No != null)
            {
                Thread.Sleep(sleepTime);
                T2S4Sub1No = new TQF.TQFUtility().getMaxID("T2S4SUB1NO", "TQF2SEC4SUB1");
                sleepTime += 5000;
            }
            else
            {
                dataInsert.T2S4Sub1No = T2S4Sub1No;
                break;
            }
        }

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle_tqf2();

        string sql = "Insert into TQF2SEC4SUB1 (T2S4SUB1NO, CURRCODE, DOMAINTYPECODE, DETAILTYPE, DETAIL, YEARVERSION) values ('" + dataInsert.T2S4Sub1No + "','" + dataInsert.CurrCode + "','" + dataInsert.DomainTypeCode + "','" + dataInsert.DetailType + "','" + dataInsert.Detail + "','" + dataInsert.YearVersion + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "Success";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertTQF2Sec4Sub1: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 8
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง STUDENT_ENGLISH_TEST
    /// </summary>
    /// <param name="dataInsert">StudentEnglishTest Object</param>
    /// <returns>OK</returns>
    public string insertStudentEnglishTest(StudentEnglishTestData dataInsert)
    {
        string response = "";

        int    sleepTime            = 5000;
        string StudentEnglishTestId = dataInsert.StudentEnglishTestId;

        for (int i = 0; i < 10; i++)
        {
            if (getStudentEnglishTest(StudentEnglishTestId).StudentEnglishTestId != null)
            {
                Thread.Sleep(sleepTime);
                StudentEnglishTestId = getMaxIdStudentEnglishTest();
                sleepTime           += 5000;
            }
            else
            {
                dataInsert.StudentEnglishTestId = StudentEnglishTestId;
                break;
            }
        }

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "Insert into STUDENT_ENGLISH_TEST (STUDENT_ENGLISH_TEST_ID, STUDENT_ID, ENGLISH_DB_ID, STUDENT_ENGLISH_TEST_SCORE) values ('" + dataInsert.StudentEnglishTestId + "','" + dataInsert.StudentId + "','" + dataInsert.EnglishDbId + "','" + dataInsert.StudentEnglishTestScore + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertStudentEnglishTest: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 9
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง STUDENT_JOURNAL
    /// </summary>
    /// <param name="dataInsert">StudentEnglishTest Object</param>
    /// <returns>OK</returns>
    public string insertStudentJournal(StudentJournalData dataInsert)
    {
        string response = "";

        int    sleepTime        = 5000;
        string StudentJournalId = dataInsert.StudentJournalId;

        for (int i = 0; i < 10; i++)
        {
            if (getStudentJournal(StudentJournalId).StudentJournalId != null)
            {
                Thread.Sleep(sleepTime);
                StudentJournalId = getMaxIdStudentJournal();
                sleepTime       += 5000;
            }
            else
            {
                dataInsert.StudentJournalId = StudentJournalId;
                break;
            }
        }

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "Insert into STUDENT_JOURNAL (STUDENT_JOURNAL_ID,STUDENT_ID,STUDENT_JOURNAL_TITLE,JOURNAL_NAME,JOURNAL_YEAR,JOURNAL_VOLUM,JOURNAL_LEVEL,PROCEEDING_DB_ID) values ('" + dataInsert.StudentJournalId + "','" + dataInsert.StudentId + "','" + dataInsert.StudentJournalTitle + "','" + dataInsert.JournalName + "','" + dataInsert.JournalYear + "','" + dataInsert.JournalVolum + "','" + dataInsert.JournalLevel + "','" + dataInsert.ProceedingDbId + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertStudentJournal: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 10
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง TQF1
    /// </summary>
    /// <param name="dataInsert"></param>
    /// <returns></returns>
    public string insertTQF1(TQF1 dataInsert)
    {
        string response = "";

        int    sleepTime = 5000;
        string NumTQF1   = dataInsert.NumTQF1;

        for (int i = 0; i < 10; i++)
        {
            if (getTQF1(NumTQF1).NumTQF1 != null)
            {
                Thread.Sleep(sleepTime);
                NumTQF1    = new TQF.TQFUtility().getMaxID("NUMTQF1", "TQF1");
                sleepTime += 5000;
            }
            else
            {
                dataInsert.NumTQF1 = NumTQF1;
                break;
            }
        }

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle_tqf2();

        string sql = "Insert into TQF1 (NUMTQF1, YEAR, LEVELCODE, MAJORNAME, FILENAME) values ('" + dataInsert.NumTQF1 + "','" + dataInsert.Year + "','" + dataInsert.LevelCode + "','" + dataInsert.TQF1Major + "','" + dataInsert.FileName + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "Success";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertTQF1: " + exception;
            HttpContext.Current.Response.Redirect("../err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 11
0
 private void addAssessItemContentStyle(CContent content, int ID_Item)
 {
     try
     {
         SqlDataSource sds = new SqlDataSource();
         sds.ConnectionString  = connectionString;
         sds.InsertCommand     = "dbo.addAssessItemContentStyle";
         sds.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
         sds.InsertParameters.Add(new Parameter("ID_Item", DbType.Int32, ID_Item.ToString()));
         sds.InsertParameters.Add(new Parameter("Score", DbType.Int32, content.score.ToString()));
         sds.InsertParameters.Add(new Parameter("Content", DbType.String, content.content));
         sds.Insert();
     }
     catch (Exception ex)
     {
         message = ex.Message;
     }
 }
        protected void btnOK_Click(object sender, EventArgs e)
        {
            SqlDataSource sds = new SqlDataSource();

            sds.ConnectionString = @"Data Source=.;Initial Catalog=Guardian_Angel;Integrated Security=True";

            sds.InsertCommand = getInsertSql();
            sds.Insert();

            lblMsg.Visible = true;
            lblMsg.Text    = "新預約【" + tbxClinic.Text + "】資料新增成功!";
            btnOK.Enabled  = false;


            //跳出訊息告知新增成功
            //Response.Write("<script language=javascript>alert('資料新增成功!將返回資料頁')</script>");
            //Response.Redirect("GaCare.aspx");
        }
Ejemplo n.º 13
0
        public void InsertTest1()
        {
            SqlDataSource ds = CreateDataSource();

            ds.SelectCommand = "SELECT * FROM Table1 WHERE UserName = ?";
            ds.SelectParameters.Add(new Parameter("UserName", TypeCode.String, "newuser"));

            ds.InsertCommand = "INSERT INTO Table1 (UserId, UserName, Description) VALUES (?, ?, ?)";
            ds.InsertParameters.Add(new Parameter("UserId", TypeCode.Int32, "15"));
            ds.InsertParameters.Add(new Parameter("UserName", TypeCode.String, "newuser"));
            ds.InsertParameters.Add(new Parameter("Description", TypeCode.String, "newuser"));

            int      records  = ds.Insert();
            DataView dataView = (DataView)ds.Select(new DataSourceSelectArguments());

            Assert.AreEqual(1, dataView.Count);
            Assert.AreEqual(1, records);
        }
Ejemplo n.º 14
0
        }//(方法)刪除舊資料

        private void saveNotice()
        {
            DateTime dt1      = DateTime.UtcNow;
            string   dateTime = dt1.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss.f");

            //string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.f");
            initOid = Request.Form["dataOid"].ToString();
            SqlDataSource sql = new SqlDataSource();

            /*換資料庫的連結*/
            sql.ConnectionString =
                @"Data Source=.;Initial Catalog=Guardian_Angel;Integrated Security=True;";
            string strNotice = "insert into Accident" +
                               "(A_style,A_date,A_status,O_id)values('3','" + dateTime + "','1','" + initOid + "')";

            sql.InsertCommand = strNotice;
            sql.Insert();
        }//(方法)儲存異常狀況記錄
Ejemplo n.º 15
0
        /* Add the time when an employee starts working on a repair */
        protected void UpdateMethod()
        {
            /* connect to the dataset */
            SqlDataSource table = SqlDataSource1;
            /* Get ID of repair_details table */
            string repairID = Request.QueryString["repairID"];
            /* get current date and time */
            string currentDate = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            /* get employeeID */
            string employeeID = employees.Select("empLogin = '******'")[0]["ID"].ToString();
            /* make a sql command to update start time where ID=ID */
            string query = "INSERT INTO repair_progress(employeeID, repairID, startDate) VALUES(" + employeeID.ToString() + ", " + repairID.ToString() + ", '" + currentDate.ToString() + "');";

            /* send sql command to database */
            table.InsertCommand = query;
            table.Insert();
            /* refresh page */
        }
Ejemplo n.º 16
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        var NewItem = new SqlDataSource();

        NewItem.ConnectionString  = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
        NewItem.InsertCommandType = SqlDataSourceCommandType.Text;
        NewItem.InsertCommand     = "INSERT INTO Rooms_To_Rent VALUES (@Room_Name, @Image, @Image2, @Image3, @Description, @Price, @Seller, @Status, @where)";
        NewItem.InsertParameters.Add("Room_Name", TextBox1.Text.ToString());
        NewItem.InsertParameters.Add("Image", TextBox2.Text.ToString());
        NewItem.InsertParameters.Add("Image2", TextBox3.Text.ToString());
        NewItem.InsertParameters.Add("Image3", TextBox4.Text.ToString());
        NewItem.InsertParameters.Add("Description", TextBox5.Text.ToString());
        NewItem.InsertParameters.Add("Price", TextBox6.Text.ToString());
        NewItem.InsertParameters.Add("Seller", TextBox7.Text.ToString());
        NewItem.InsertParameters.Add("Status", TextBox8.Text.ToString());
        NewItem.InsertParameters.Add("where", TextBox9.Text.ToString());
        NewItem.Insert();
    }
Ejemplo n.º 17
0
    /// <summary>
    /// Table OTHER_AUTHORIZED_SYSTEM
    /// </summary>
    /// <param name="dataInsert"></param>
    /// <returns></returns>
    public string insertOtherAuthorizedSystem(UserAuthorizedSystemData dataInsert)
    {
        string response = "";

        UserLoginData loginData = new UserLoginData();

        loginData = (UserLoginData)HttpContext.Current.Session["login_data"];
        LogData log_data = new LogData();

        log_data.ModuleCode = new LogData().Module_Setting;
        log_data.Username   = loginData.User_ID;
        log_data.Message    = "Insert OtherAuthorizedSystem with: " + dataInsert.Other_Users_Group_Id + ", " + dataInsert.Other_User_Id + ", " + dataInsert.Other_Authorized_Code;

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into OTHER_AUTHORIZED_SYSTEM (USERS_GROUP_ID, USER_ID, OTHER_AUTHORIZED_CODE) Values ('" + dataInsert.Other_Users_Group_Id + "','" + dataInsert.Other_User_Id + "','" + dataInsert.Other_Authorized_Code + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response            = "OK";
                log_data.StatusCode = log_data.LogStatus_SUCCESS;
            }
            else
            {
                log_data.StatusCode = log_data.LogStatus_FAILED;
            }
        }
        catch (Exception e)
        {
            response            = e.Message.ToString() + " ";
            log_data.StatusCode = log_data.LogStatus_ERROR;
            log_data.Message   += " [" + e.ToString() + "]";
        }

        new Log().WriteLog(log_data);
        return(response);
    }
Ejemplo n.º 18
0
    public string insertEScholarshipLoan(ScholarshipEstduentLoan dataInsert)
    {
        string response = "";

        UserLoginData loginData = new UserLoginData();

        loginData = (UserLoginData)HttpContext.Current.Session["login_data"];
        LogData log_data = new LogData();

        log_data.ModuleCode = new LogData().Module_Scholarship;
        log_data.Username   = loginData.User_ID;
        log_data.Message    = "Insert ScholarshipEstduentLoan with: " + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_STUDENT_ID + ", " + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_SCHOLARSHIP_CODE;

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into SCHOLARSHIP_ESTUDENT_LOAN(STUDENT_ID, NATION_ID, CONTRACT_NUMBER, CONFIRMATION_NUMBER, DATE_APPROVE, LOAN_STUDY, LOAN_ETC, LOAN_LIVE, LOAN_TOTAL, SCHOLARSHIP_CODE, STUDY_YEAR, ACADEMIC_YEAR, SEMESTER) Values('" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_STUDENT_ID + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_NATION_ID + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_CONTRACT_NUMBER + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_CONFIRMATION_NUMBER + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_DATE_APPROVE + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_LOAN_STUDY + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_LOAN_ETC + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_LOAN_LIVE + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_LOAN_TOTAL + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_SCHOLARSHIP_CODE + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_STUDY_YEAR + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_ACADEMIC_YEAR + "','" + dataInsert.SCHOLARSHIP_ESTUDENT_LOAN_SEMESTER + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response            = "OK";
                log_data.StatusCode = log_data.LogStatus_SUCCESS;
            }
            else
            {
                log_data.StatusCode = log_data.LogStatus_FAILED;
            }
        }
        catch (Exception e)
        {
            response            = e.Message.ToString() + " ";
            log_data.StatusCode = log_data.LogStatus_ERROR;
            log_data.Message   += " [" + e.ToString() + "]";
        }

        new Log().WriteLog(log_data);
        return(response);
    }
Ejemplo n.º 19
0
    /// <summary>
    /// Table USERS_FACULTY_AUTHORIZED
    /// </summary>
    /// <param name="dataInsert"></param>
    /// <returns></returns>
    public string insertFacultyAuthorized(UserAuthorizedData dataInsert)
    {
        string response = "";

        UserLoginData loginData = new UserLoginData();

        loginData = (UserLoginData)HttpContext.Current.Session["login_data"];
        LogData log_data = new LogData();

        log_data.ModuleCode = new LogData().Module_Setting;
        log_data.Username   = loginData.User_ID;
        log_data.Message    = "Insert FacultyAuthorized with: " + dataInsert.Faculty_Authorized_User_Id + ", " + dataInsert.Faculty_Authorized_Faculty_Code + ", " + dataInsert.Faculty_Authorized_Allow_Status;

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into USERS_FACULTY_AUTHORIZED (USER_ID, FACULTY_CODE, ALLOW_STATUS) Values ('" + dataInsert.Faculty_Authorized_User_Id + "','" + dataInsert.Faculty_Authorized_Faculty_Code + "','" + dataInsert.Faculty_Authorized_Allow_Status + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response            = "OK";
                log_data.StatusCode = log_data.LogStatus_SUCCESS;
            }
            else
            {
                log_data.StatusCode = log_data.LogStatus_FAILED;
            }
        }
        catch (Exception e)
        {
            response            = e.Message.ToString() + " ";
            log_data.StatusCode = log_data.LogStatus_ERROR;
            log_data.Message   += " [" + e.ToString() + "]";
        }

        new Log().WriteLog(log_data);
        return(response);
    }
Ejemplo n.º 20
0
    // V 1.0.0
    public string[] updateAvailableStudent(List <AvailableStudentData> available_student, AvailableStudentData old_available_student, string degree_char)
    {
        string TableName = getTableName(degree_char);

        string[] response = new string[available_student.Count];

        int           i         = 0;
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        if (deleteAvailableStudent(old_available_student, degree_char) == "OK")
        {
            foreach (AvailableStudentData data in available_student)
            {
                string sql = "Insert Into " + TableName + "(ACADEMIC_YEAR,SEMESTER,COURSE_CODE,SEC_NO,COURSE_TYPE,CURR_CODE,STD_CATEGORY_CODE,STD_GROUP_CODE,SECTION_CODE,STUDENT_YEAR,SUBSEC_NO,FACULTY_CODE) Values('" + data.AcademicYear + "','" + data.Semester + "','" + data.Course_Code + "'," + data.Sec_No + ",'" + data.Course_Type + "','" + data.Curr_Code + "','" + data.Student_Category_Code + "','" + data.Student_Group_Code + "','" + data.Section_Code + "'," + data.Student_Year + "," + data.SubSec_No + ",'" + data.Faculty_Code + "')";

                oracleObj.InsertCommand = sql;

                try
                {
                    if (oracleObj.Insert() == 1)
                    {
                        response[i] = "OK";
                    }
                }
                catch (Exception e)
                {
                    response[i] = e.Message.ToString() + " ";
                }

                i++;
            }
        }
        else
        {
            for (int j = 0; j < response.Length; j++)
            {
                response[j] = "Can't Update";
            }
        }


        return(response);
    }
Ejemplo n.º 21
0
    public string insertUsers(UsersInfo dataInsert)
    {
        string response = "";

        UserLoginData loginData = new UserLoginData();

        loginData = (UserLoginData)HttpContext.Current.Session["login_data"];
        LogData log_data = new LogData();

        log_data.ModuleCode = new LogData().Module_Setting;
        log_data.Username   = loginData.User_ID;
        log_data.Message    = "Insert UsersInfo with: " + dataInsert.USERS_INFO_USER_ID;

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into USERS_INFO(USER_ID, NATIONAL_ID, OFFICIAL_ID, TITLE_THAINAME, FIRST_THAINAME, FAMILY_THAINAME, TITLE_ENGNAME, FIRST_ENGNAME, FAMILY_ENGNAME, FACULTY_ID, DEPARTMENT_ID, INTERNAL_PHONE, EXTERNAL_PHONE, OTHEROFFICE_CODE, STATUS, PASSWORD) Values('" + dataInsert.USERS_INFO_USER_ID + "','" + dataInsert.USERS_INFO_NATIONAL_ID + "','" + dataInsert.USERS_INFO_OFFICIAL_ID + "','" + dataInsert.USERS_INFO_TITLE_THAINAME + "','" + dataInsert.USERS_INFO_FIRST_THAINAME + "','" + dataInsert.USERS_INFO_FAMILY_THAINAME + "','" + dataInsert.USERS_INFO_TITLE_ENGNAME + "','" + dataInsert.USERS_INFO_FIRST_ENGNAME + "','" + dataInsert.USERS_INFO_FAMILY_ENGNAME + "','" + dataInsert.USERS_INFO_FACULTY_ID + "','" + dataInsert.USERS_INFO_DEPARTMENT_ID + "','" + dataInsert.USERS_INFO_INTERNAL_PHONE + "','" + dataInsert.USERS_INFO_EXTERNAL_PHONE + "','" + dataInsert.OTHEROFFICE_CODE + "','" + dataInsert.STATUS + "','" + dataInsert.PASSWORD + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response            = "OK";
                log_data.StatusCode = log_data.LogStatus_SUCCESS;
            }
            else
            {
                log_data.StatusCode = log_data.LogStatus_FAILED;
            }
        }
        catch (Exception e)
        {
            response            = e.Message.ToString() + " ";
            log_data.StatusCode = log_data.LogStatus_ERROR;
            log_data.Message   += " [" + e.ToString() + "]";
        }

        new Log().WriteLog(log_data);
        return(response);
    }
Ejemplo n.º 22
0
    public string insertScholarshipType(ScholarshipTypeData dataInsert)
    {
        string response = "";

        UserLoginData loginData = new UserLoginData();

        loginData = (UserLoginData)HttpContext.Current.Session["login_data"];
        LogData log_data = new LogData();

        log_data.ModuleCode = new LogData().Module_Scholarship;
        log_data.Username   = loginData.User_ID;
        log_data.Message    = "Insert ScholarshipType with: " + dataInsert.Type_Code;

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into SCHOLARSHIP_TYPE(TYPE_CODE,TYPE_THAINAME,TYPE_ENGNAME,TYPE_CATALOG) Values('" + dataInsert.Type_Code + "','" + dataInsert.Type_Thai + "','" + dataInsert.Type_Eng + "','" + dataInsert.Type_Catalog + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response            = "OK";
                log_data.StatusCode = log_data.LogStatus_SUCCESS;
            }
            else
            {
                log_data.StatusCode = log_data.LogStatus_FAILED;
            }
        }
        catch (Exception e)
        {
            response            = e.Message.ToString() + " ";
            log_data.StatusCode = log_data.LogStatus_ERROR;
            log_data.Message   += " [" + e.ToString() + "]";
        }

        new Log().WriteLog(log_data);
        return(response);
    }
Ejemplo n.º 23
0
    public string insertScholarship(Scholarship dataInsert)
    {
        string response = "";

        UserLoginData loginData = new UserLoginData();

        loginData = (UserLoginData)HttpContext.Current.Session["login_data"];
        LogData log_data = new LogData();

        log_data.ModuleCode = new LogData().Module_Scholarship;
        log_data.Username   = loginData.User_ID;
        log_data.Message    = "Insert Scholarship with: " + dataInsert.SCHOLARSHIP_SCHOLARSHIP_CODE;

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into SCHOLARSHIP(ACADEMIC_YEAR, SEMESTER, SCHOLARSHIP_CODE, SCHOLARSHIP_THAINAME, SCHOLARSHIP_ENGNAME, SCHOLARSHIP_IN_OUT, SCHOLARSHIP_TYPE, SCHOLARSHIP_SOURCE, NEW_REGIS_FEE, PROPERTIES_FEE, STUDY_FACILITY_FEE, IT_FEE, LIBRARY_FEE, HEALTH_FEE, ACTIVITY_FEE, CREDIT_3000, ACCIDENT_FEE, ACADEMIC_FEE_BACHELOR, SPECIAL_PROJECT_FEE, SCHOLAR_FEE_COMMENT, MULTIPLE_SCHOLARSHIP, ACADEMIC_FEE_MASTER, FINE_FEE, THEORY_PRACTICE_FEE, THESIS_FEE, SCHOLARSHIP_STATUS) Values('" + dataInsert.SCHOLARSHIP_ACADEMIC_YEAR + "','" + dataInsert.SCHOLARSHIP_SEMESTER + "','" + dataInsert.SCHOLARSHIP_SCHOLARSHIP_CODE + "','" + dataInsert.SCHOLARSHIP_SCHOLARSHIP_THAINAME + "','" + dataInsert.SCHOLARSHIP_SCHOLARSHIP_ENGNAME + "','" + dataInsert.SCHOLARSHIP_SCHOLARSHIP_IN_OUT + "','" + dataInsert.SCHOLARSHIP_SCHOLARSHIP_TYPE + "','" + dataInsert.SCHOLARSHIP_SCHOLARSHIP_SOURCE + "','" + dataInsert.SCHOLARSHIP_NEW_REGIS_FEE + "','" + dataInsert.SCHOLARSHIP_PROPERTIES_FEE + "','" + dataInsert.SCHOLARSHIP_STUDY_FACILITY_FEE + "','" + dataInsert.SCHOLARSHIP_IT_FEE + "','" + dataInsert.SCHOLARSHIP_LIBRARY_FEE + "','" + dataInsert.SCHOLARSHIP_HEALTH_FEE + "','" + dataInsert.SCHOLARSHIP_ACTIVITY_FEE + "','" + dataInsert.SCHOLARSHIP_CREDIT_3000 + "','" + dataInsert.SCHOLARSHIP_ACCIDENT_FEE + "','" + dataInsert.SCHOLARSHIP_ACADEMIC_FEE_BACHELOR + "','" + dataInsert.SCHOLARSHIP_SPECIAL_PROJECT_FEE + "','" + dataInsert.SCHOLARSHIP_SCHOLAR_FEE_COMMENT + "','" + dataInsert.SCHOLARSHIP_MULTIPLE_SCHOLARSHIP + "','" + dataInsert.SCHOLARSHIP_ACADEMIC_FEE_MASTER + "','" + dataInsert.SCHOLARSHIP_FINE_FEE + "','" + dataInsert.SCHOLARSHIP_THEORY_PRACTICE_FEE + "','" + dataInsert.SCHOLARSHIP_THESIS_FEE + "','" + dataInsert.SCHOLARSHIP_SCHOLARSHIP_STATUS + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response            = "OK";
                log_data.StatusCode = log_data.LogStatus_SUCCESS;
            }
            else
            {
                log_data.StatusCode = log_data.LogStatus_FAILED;
            }
        }
        catch (Exception e)
        {
            response            = e.Message.ToString() + " ";
            log_data.StatusCode = log_data.LogStatus_ERROR;
            log_data.Message   += " [" + e.ToString() + "]";
        }

        new Log().WriteLog(log_data);
        return(response);
    }
Ejemplo n.º 24
0
    /// <summary>
    /// เพิ่มข้อมูลลงตาราง DIVISIONEXTENSION
    /// </summary>
    /// <param name="dataInsert">DivisionExtension Object</param>
    /// <returns>Success</returns>
    public string insertDivisionExtension(DivisionExtension dataInsert)
    {
        string response = "";

        //int sleepTime = 5000;
        //string DivisionNo = dataInsert.DivisionNo;
        //for (int i = 0; i < 10; i++)
        //{
        //    if (getDivisionExtension(DivisionNo).DivisionNo != null)
        //    {
        //        Thread.Sleep(sleepTime);
        //        DivisionNo = new utility().getMaxID("DIVISIONNO", "DIVISIONEXTENSION");
        //        sleepTime += 5000;
        //    }
        //    else
        //    {
        //        dataInsert.DivisionNo = DivisionNo;
        //        break;
        //    }
        //}

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle_tqf2();

        string sql = "Insert into DIVISIONEXTENSION (CURRCODE, YEARVERSION, DIVISIONNO, DIVISIONCODE) values ('" + dataInsert.CurrCode + "','" + dataInsert.YearVersion + "','" + dataInsert.DivisionNo + "','" + dataInsert.DivisionCode + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "Success";
            }
        }
        catch (Exception e)
        {
            string exception = e.Message;
            HttpContext.Current.Session["response"] = "insertDivisionExtension: " + exception;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(response);
    }
        public void chendulieunguoidung()
        {
            SqlDataSource sqldata     = new SqlDataSource();
            KetNoi        chuoiketnoi = new KetNoi();

            sqldata.ConnectionString  = chuoiketnoi.ConnectionString();
            sqldata.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
            sqldata.InsertCommand     = "NguoiDung_Insert";
            sqldata.InsertParameters.Add("HoTen", Nguoidung.Hoten.ToString());
            sqldata.InsertParameters.Add("TenDangNhap", Nguoidung.Tendangnhap.ToString());
            sqldata.InsertParameters.Add("DiaChi", Nguoidung.Diachi.ToString());
            sqldata.InsertParameters.Add("MaDienThoai", Nguoidung.Madienthoai.ToString());
            sqldata.InsertParameters.Add("SoDienThoai", Nguoidung.Sodienthoai.ToString());
            sqldata.InsertParameters.Add("SoFax", Nguoidung.Sofax.ToString());
            sqldata.InsertParameters.Add("Email", Nguoidung.Email.ToString());
            sqldata.InsertParameters.Add("IDKieuNguoiDung", Nguoidung.Idkieunguoidung.ToString());
            sqldata.InsertParameters.Add("MatKhau", Nguoidung.Matkhau.ToString());
            sqldata.Insert();
        }
Ejemplo n.º 26
0
    /// <summary>新增身分角色到資料庫</summary>
    public void addRole(CRole role)
    {
        try
        {
            SqlDataSource sds = new SqlDataSource();
            sds.ConnectionString  = connectionString;
            sds.InsertCommand     = "dbo.addRole";
            sds.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
            sds.InsertParameters.Add(new Parameter("ID_Role", DbType.String, role.id));
            sds.InsertParameters.Add(new Parameter("RoleName", DbType.String, role.name));
            sds.Insert();

            message = "add success";
        }
        catch (Exception ex)
        {
            message = ex.Message;
        }
    }
Ejemplo n.º 27
0
 // event handler to insert the book
 protected void bookInsertButton_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         SqlDataSource.InsertParameters["BookCode"].DefaultValue      = bookCodeTextBox.Text;
         SqlDataSource.InsertParameters["PublisherCode"].DefaultValue = publisherCodeTextBox.Text;
         SqlDataSource.InsertParameters["Type"].DefaultValue          = bookTypeTextBox.Text;
         SqlDataSource.InsertParameters["Title"].DefaultValue         = bookTitleTextBox.Text;
         SqlDataSource.InsertParameters["Price"].DefaultValue         = bookPriceTextBox.Text;
         SqlDataSource.Insert();
         status.ForeColor = System.Drawing.Color.Green;
         status.Text      = "[Input Good!]";
         Response.Redirect("BookTable.aspx");
     }
     catch
     {
         status.ForeColor = System.Drawing.Color.Red;
         status.Text      = "[Exception caught, check input!]";
     }
 }
Ejemplo n.º 28
0
        //新增用藥時間送出
        protected void btnSendTime_Click(object sender, EventArgs e)
        {
            SqlDataSource sds = new SqlDataSource();

            sds.ConnectionString = @"Data Source=.;Initial Catalog=Guardian_Angel;Integrated Security=True;";
            String hourSet   = DropDownList1.SelectedItem.ToString();
            String minuteSet = DropDownList2.SelectedItem.ToString();

            sds.InsertCommand = "insert [dbo].[Time] ([N_id],[T_hour],[T_minute]) values (" + nid + "," + hourSet + "," + minuteSet + ")";
            sds.Insert();
            DropDownList1.Visible = false;
            DropDownList2.Visible = false;
            lblHour.Visible       = false;
            lblMinute.Visible     = false;
            btnAddTime.Enabled    = true;
            btnSendTime.Visible   = false;
            lblHour.Visible       = false;
            lblMinute.Visible     = false;
            Response.Redirect("OldMedicine_ViewAndUpdate.aspx");
        }
Ejemplo n.º 29
0
        }//(方法)新增資料進RS資料表

        //修改資料相關
        private void UpdateEC()
        {
            initEidint = Convert.ToInt32(Session["Eid"].ToString());
            //修改sql字串
            string sqlUpdateEC = "update Emergency_Contact set " +
                                 "E_name='" + tbName.Text +
                                 "', E_phone='" + tbPhone.Text +
                                 "',E_email='" + tbEmail.Text +
                                 "' where E_id = " + initEidint;

            SqlDataSource sql = new SqlDataSource();

            //選擇連結的資料庫
            sql.ConnectionString =
                @"Data Source=.;Initial Catalog=Guardian_Angel;Integrated Security=True;";
            //要輸入的sql指令(修改資料)
            sql.InsertCommand = sqlUpdateEC;
            //執行輸入
            sql.Insert();
        }//(方法)修改資料進EC資料表
Ejemplo n.º 30
0
        }//(方法)從EC資料表檢索資料

        //新增資料相關
        private void InsertEC()
        {
            int priorityInt = Convert.ToInt32(Session["newPriority"].ToString());
            //sql指令  資料存入Emergency_contact資料庫的指令碼
            string sqlInsertEC = "insert into Emergency_Contact" +
                                 "(E_name,E_phone,E_email,priority)values('" +
                                 tbName.Text + "', '" +
                                 tbPhone.Text + "', '" +
                                 tbEmail.Text + "', '" +
                                 priorityInt + "')";
            SqlDataSource sql = new SqlDataSource();

            //選擇連結的資料庫
            sql.ConnectionString =
                @"Data Source=.;Initial Catalog=Guardian_Angel;Integrated Security=True;";
            //要輸入的sql指令(存入名字電話信箱,之後查詢Eid)
            sql.InsertCommand = sqlInsertEC;
            //執行輸入
            sql.Insert();
        }//(方法)新增資料進EC資料表
        protected void Button10_Click(object sender, EventArgs e)
        {
            SqlDataSource P1_SqlDataSource_Save = (SqlDataSource)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("P1_SqlDataSource_Save");

            P1_SqlDataSource_Save.Insert();

            HiddenField   HiddenField_Visited_StafEmpId0      = (HiddenField)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("HiddenField_Visited_StafEmpId0");
            HiddenField   HiddenField_Vehicle_Requisition_Id0 = (HiddenField)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("HiddenField_Vehicle_Requisition_Id0");
            GridView      GridView9      = (GridView)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("GridView9");
            SqlDataSource SqlDataSource2 = (SqlDataSource)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("SqlDataSource2");

            for (int i = 0; i < GridView9.Rows.Count; i++)
            {
                HiddenField HiddenField_Visited_StafEmpId      = (HiddenField)GridView9.Rows[i].FindControl("HiddenField_Visited_StafEmpId");
                HiddenField HiddenField_Vehicle_Requisition_Id = (HiddenField)GridView9.Rows[i].FindControl("HiddenField_Vehicle_Requisition_Id");
                CheckBox    CheckBox1 = (CheckBox)GridView9.Rows[i].FindControl("CheckBox1");

                if (CheckBox1.Checked)
                {
                    HiddenField_Visited_StafEmpId0.Value      = HiddenField_Visited_StafEmpId.Value;
                    HiddenField_Vehicle_Requisition_Id0.Value = HiddenField_Vehicle_Requisition_Id.Value;
                    SqlDataSource2.Insert();
                }
            }
            GridView      GridView8 = (GridView)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("GridView8");
            HiddenField   HiddenField_VFType_Id0        = (HiddenField)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("HiddenField_VFType_Id0");
            HiddenField   HiddenField_VF_Current        = (HiddenField)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("HiddenField_VF_Current");
            SqlDataSource P1A_SqlDataSource_CurrentFuel = (SqlDataSource)P1_GridViewAllreadyReservedV.Rows[Convert.ToInt32(P1_HiddenField_SelectedRow.Value)].FindControl("P1A_SqlDataSource_CurrentFuel");

            for (int j = 0; j < GridView8.Rows.Count; j++)
            {
                HiddenField HiddenField_VFType_Id = (HiddenField)GridView8.Rows[j].FindControl("HiddenField_VFType_Id");
                TextBox     TextBox1 = (TextBox)GridView8.Rows[j].FindControl("TextBox1");
                HiddenField_VFType_Id0.Value = HiddenField_VFType_Id.Value;
                HiddenField_VF_Current.Value = TextBox1.Text;
                P1A_SqlDataSource_CurrentFuel.Insert();
            }


            P1_GridViewAllreadyReservedV.DataBind();
        }
Ejemplo n.º 32
0
    /// <summary>新增使用者到資料庫</summary>
    public void addUser(CUser user)
    {
        try
        {
            SqlDataSource sds = new SqlDataSource();
            sds.ConnectionString  = connectionString;
            sds.InsertCommand     = "dbo.addUser";
            sds.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
            sds.InsertParameters.Add(new Parameter("UserName", DbType.String, user.name));
            sds.InsertParameters.Add(new Parameter("ID_Role", DbType.String, user.role_id));
            sds.InsertParameters.Add(new Parameter("UserAccount", DbType.String, user.account));
            sds.InsertParameters.Add(new Parameter("UserPassword", DbType.String, user.password));
            sds.Insert();

            message = "add success";
        }
        catch (Exception ex)
        {
            message = ex.Message;
        }
    }
Ejemplo n.º 33
0
    /// <summary>新增住民到資料庫</summary>
    public void addPatient(CPatient patient)
    {
        try
        {
            SqlDataSource sds = new SqlDataSource();
            sds.ConnectionString  = connectionString;
            sds.InsertCommand     = "dbo.addPatient";
            sds.InsertCommandType = SqlDataSourceCommandType.StoredProcedure;
            sds.InsertParameters.Add(new Parameter("PatientName", DbType.String, patient.name));
            sds.InsertParameters.Add(new Parameter("PatientIDCard", DbType.String, patient.idcard));
            sds.InsertParameters.Add(new Parameter("PatientBirthday", DbType.Date, patient.birthday.ToShortDateString()));
            sds.InsertParameters.Add(new Parameter("PatientPhotoPath", DbType.String, patient.photoPath));
            sds.Insert();

            message = "add success";
        }
        catch (Exception ex)
        {
            message = ex.Message;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlDataSource SqlDataSource1 = new SqlDataSource();
        SqlDataSource1.ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlDataSource1.InsertParameters.Add("Order_date", TextBox1.Text);
        SqlDataSource1.InsertParameters.Add("Assign_numbers", TextBox2.Text);
        SqlDataSource1.InsertParameters.Add("Account_numbers", DropDownList1.Text);
        SqlDataSource1.InsertParameters.Add("Account_abstract", TextBox3.Text);
        SqlDataSource1.InsertParameters.Add("Income", TextBox4.Text);
        SqlDataSource1.InsertParameters.Add("Spend", TextBox5.Text);
        SqlDataSource1.InsertCommand = "Insert into Account_Order_M(Order_date,Assign_numbers,Account_numbers,Account_abstract,Income,Spend) values(@Order_date,@Assign_numbers,@Account_numbers,@Account_abstract,@Income,@Spend)";

        int affraw = SqlDataSource1.Insert();
        if (affraw == 0)
        {
            Label1.Text = "Error";
        }
        else
        {
            Label1.Text = "OK";
            Button1.Visible = false;
        }
        SqlDataSource1.Dispose();
    }
    protected void DetailsView_Route_has_Bus_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
    {
        String Route_has_Bus_ID = DetailsView_Route_has_Bus.SelectedValue.ToString();
        DropDownList D_Bus_ID_NEW = (DropDownList)DetailsView_Route_has_Bus.FindControl("DropDownList3");
        DropDownList D_Bus_ID_OLD = (DropDownList)DetailsView_Route_has_Bus.FindControl("DropDownList7");
        String Bus_ID_NEW = D_Bus_ID_NEW.SelectedValue;
        String Bus_ID_OLD = D_Bus_ID_OLD.SelectedValue;
        if (Bus_ID_NEW != Bus_ID_OLD)
        {
            delete_seat(Route_has_Bus_ID);

            SqlDataSource seat = new SqlDataSource();
            seat.ConnectionString =
                ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();

            String count_seat = get_seat_count(Bus_ID_NEW).ToString();
            String command = "";

            command = get_insert_command(count_seat, Route_has_Bus_ID);

            if (command != "")
            {
                String insertCommand = "INSERT INTO [Seat] "
                + " (Route_has_Bus_ID, Seat_Number, Seat_Name, Seat_Status) "
                + " VALUES "
                + command
                + ";";

                seat.InsertCommand = insertCommand;
                seat.Insert();
            }
        }
    }
Ejemplo n.º 36
0
    protected void Button_Submit_Click(object sender, EventArgs e)
    {
        String Route1 = Request.QueryString["Route1"];
        String Route2 = Request.QueryString["Route2"];
        String Seat_Q_R1 = Request.QueryString["S_R1"];
        String Seat_Q_R2 = Request.QueryString["S_R2"];
        String R1 = "";
        String R2 = "";

        String[] Seat_R1 = { };
        String[] Seat_R2 = { };

        if (Seat_Q_R1 != null)
        {
            if (Seat_Q_R1.ToString() != "")
            {
                Seat_R1 = Seat_Q_R1.Split('_');
            }
        }

        if (Seat_Q_R2 != null)
        {
            if (Seat_Q_R2.ToString() != "")
            {
                Seat_R2 = Seat_Q_R2.Split('_');
            }
        }

        if (Route1 != null)
        {
            if (Route1.ToString() != "")
            {
                R1 = Route1;
            }
        }
        if (Route2 != null)
        {
            if (Route2.ToString() != "")
            {
                R2 = Route2;
            }
        }

        set_seat(); // set Seat to จอง

        SqlDataSource Res = new SqlDataSource();
        Res.ConnectionString =
            ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();

        Res.InsertCommand = "INSERT INTO [Reservation] ([Member_UserName], [Res_Name], "
            +"[Res_Sex], [Res_Phone], [Res_R1], [Res_Price_R1], [Res_R2], [Res_Price_R2], "
            + "[Res_Serviece_Price], [Res_Sum_Price], [Res_Status], [Res_Seat_Name_R1], [Res_Seat_Name_R2]) "
            +"VALUES (@Member_UserName, @Res_Name, @Res_Sex, @Res_Phone, @Res_R1, "
            + "@Res_Price_R1, @Res_R2, @Res_Price_R2, @Res_Serviece_Price, @Res_Sum_Price, @Res_Status, @Res_Seat_Name_R1, @Res_Seat_Name_R2)";

        Res.InsertParameters.Clear();
        Res.InsertParameters.Add("Member_UserName", User.Identity.Name.ToString());
        Res.InsertParameters.Add("Res_Name", TextBox_Name.Text + " " + TextBox_LastName.Text);
        Res.InsertParameters.Add("Res_Sex", RadioButtonList_Sex.SelectedValue);
        Res.InsertParameters.Add("Res_Phone", TextBox_Phone.Text);
        Res.InsertParameters.Add("Res_R1", R1);
        Res.InsertParameters.Add("Res_R2", R2);
        Res.InsertParameters.Add("Res_Seat_Name_R1", (String)Session["Seat_R1"]);
        Res.InsertParameters.Add("Res_Seat_Name_R2", (String)Session["Seat_R2"]);
        Res.InsertParameters.Add("Res_Price_R1", Label_price_R1.Text);
        Res.InsertParameters.Add("Res_Price_R2", Label_price_R2.Text);
        Res.InsertParameters.Add("Res_Serviece_Price", Label_serviece_price_SUM.Text);
        Res.InsertParameters.Add("Res_Sum_Price", Label_price_SUM_ALL.Text);
        Res.InsertParameters.Add("Res_Status", "ค้างชำระ");
        Res.Insert();

        int ID = get_Res_ID_Last();

        SqlDataSource Res_Seat = new SqlDataSource();
        Res_Seat.ConnectionString =
            ConfigurationManager.ConnectionStrings["BusTicketConnectionString1"].ToString();
        Res_Seat.InsertCommand = "INSERT INTO [Res_Seat] ([Res_ID], [Seat_ID]) "
            + "VALUES (@Res_ID, @Seat_ID)";

        if (Route1 != null)
        {
            if (Route1.ToString() != "")
            {
                for (int i = 0; i < Seat_R1.Length; i++)
                {
                    Res_Seat.InsertParameters.Clear();
                    Res_Seat.InsertParameters.Add("Res_ID", ID.ToString());
                    int Sead_ID = get_Seat_ID(Route1, Seat_R1[i]);
                    Res_Seat.InsertParameters.Add("Seat_ID", Sead_ID.ToString());
                    Res_Seat.Insert();
                }
            }
        }
        if (Route2 != null)
        {
            if (Route2.ToString() != "")
            {
                for (int i = 0; i < Seat_R2.Length; i++)
                {
                    Res_Seat.InsertParameters.Clear();
                    Res_Seat.InsertParameters.Add("Res_ID", ID.ToString());
                    int Sead_ID = get_Seat_ID(Route2, Seat_R2[i]);
                    Res_Seat.InsertParameters.Add("Seat_ID", Sead_ID.ToString());
                    Res_Seat.Insert();
                }
            }
        }
        Response.Redirect("~/Members/Ticket.aspx?res_id="+ID.ToString()+"");
    }