Exemple #1
0
    public string updateBoardPos(BoardPosData updateData)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "Update BOARD_POSITION Set POSITION_THAINAME='" + updateData.Position_Thai + "', POSITION_ENGNAME='" + updateData.Position_Eng + "', STATUS='" + updateData.Status + "' Where POSITION_CODE='" + updateData.Position_Code + "'";

        oracleObj.UpdateCommand = sql;

        try
        {
            if (oracleObj.Update() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:BoardPos:updateBoardPos" + " ไม่สามารถดำเนินการได้";
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(response);
    }
Exemple #2
0
    public List <BoardPosData> getAllBoardPos()
    {
        string response = "";

        List <BoardPosData> BoardPos_Data = new List <BoardPosData>();

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


        string sql = "Select * From BOARD_POSITION Order By POSITION_CODE";

        try
        {
            oracleObj.SelectCommand = sql;
            DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView rowData in allData)
            {
                BoardPosData BoardPos_data = new BoardPosData();
                BoardPos_data.Position_Code = rowData["POSITION_CODE"].ToString();
                BoardPos_data.Position_Thai = rowData["POSITION_THAINAME"].ToString();
                BoardPos_data.Position_Eng  = rowData["POSITION_ENGNAME"].ToString();
                BoardPos_data.Status        = rowData["STATUS"].ToString();
                BoardPos_Data.Add(BoardPos_data);
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:BoardPos:getBoardPos " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(BoardPos_Data);
    }
Exemple #3
0
    public string insertBoardPos(BoardPosData dataInsert)
    {
        int           sleeptime = 5000;
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();
        string        sql       = "";

        string position_code = getPostionCode();

        for (int i = 0; i < 10; i++)
        {
            if (getBoardPos(position_code).Position_Code != null)
            {
                System.Threading.Thread.Sleep(sleeptime);
                position_code = getPostionCode();
                sleeptime    += 5000;
            }
            else
            {
                dataInsert.Position_Code = position_code;
                break;
            }
        }


        sql = "Insert Into BOARD_POSITION(POSITION_CODE, POSITION_THAINAME, POSITION_ENGNAME, STATUS) Values('" + dataInsert.Position_Code + "','" + dataInsert.Position_Thai + "','" + dataInsert.Position_Eng + "','" + dataInsert.Status + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:BoardPos:insertBoardPos" + " ไม่สามารถดำเนินการได้";
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(response);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login_data"] == null)
        {
            Response.Redirect("../index.aspx");
        }
        else
        {
            //ตรวจสอบสิทธิ์
            login_data = (UserLoginData)Session["login_data"];
            if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
            {
                /*=============================*/
                try
                {
                    if (!Page.IsPostBack)
                    {
                        fail.Visible       = false;
                        divSuccess.Visible = false;

                        string position_code = Request.QueryString["position"];

                        BoardPosData position_data = new BoardPosData();
                        position_data = new BoardPos().getBoardPos(position_code);

                        txtWork_Position_Thai.Text = position_data.Position_Thai;
                        txtWork_Position_Eng.Text  = position_data.Position_Eng;
                        ddlStatus.Items.FindByValue(position_data.Status).Selected = true;
                    }
                }
                catch (Exception err)
                {
                    Session["response"] = err.ToString();
                    Response.Redirect("err_response.aspx");
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        utility utlObj = new utility();

        txtWork_Position_Thai.Text = utlObj.removeAllQuotes(txtWork_Position_Thai.Text);
        txtWork_Position_Eng.Text  = utlObj.removeAllQuotes(txtWork_Position_Eng.Text);

        if (txtWork_Position_Thai.Text.Length <= 0 || txtWork_Position_Thai.Text.Length > 50)
        {
            MsgValidate("โปรดระบุ ชื่อตำแหน่งาน (ภาษาไทย)");
        }
        else if (txtWork_Position_Eng.Text.Length <= 0 || txtWork_Position_Eng.Text.Length > 50)
        {
            MsgValidate("โปรดระบุ ชื่อตำแหน่งาน (ภาษาอังกฤษ)");
        }
        else
        {
            BoardPosData update_data = new BoardPosData();

            update_data.Position_Thai = txtWork_Position_Thai.Text;
            update_data.Position_Eng  = txtWork_Position_Eng.Text;
            update_data.Status        = ddlStatus.SelectedValue;
            update_data.Position_Code = Request.QueryString["position"];

            string result = new BoardPos().updateBoardPos(update_data);

            if (result == "OK")
            {
                divSuccess.Visible = true;
                showDiv.Visible    = false;
            }
            else
            {
                MsgValidate("ไม่สามารถตำแหน่งงานบริหาร กรุณาทำใหม่อีกครั้ง");
            }
        }
    }