Esempio n. 1
0
    //Pongsarun 26/2/2016: use for config system
    public List <MajorData> getMajorManual(string sql)
    {
        List <MajorData> Major_data = new List <MajorData>();

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

        oracleObj.SelectCommand = sql;
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            MajorData major = new MajorData();
            major.Major_Code           = rowData["MAJOR_CODE"].ToString();
            major.Major_Thai           = rowData["MAJOR_THAINAME"].ToString();
            major.Major_Eng            = rowData["MAJOR_ENGNAME"].ToString();
            major.Major_ShortName      = rowData["MAJOR_SHORTNAME"].ToString();
            major.Major_DepartmentCode = rowData["DEPARTMENT_CODE"].ToString();
            major.Major_Code_StudentID = rowData["MAJOR_CODE_STUDENTID"].ToString();
            major.Major_Status         = rowData["MAJOR_STATUS"].ToString();
            Major_data.Add(major);
        }

        return(Major_data);
    }
Esempio n. 2
0
    public List <MajorData> getMajorwithDepartment(string department_code)
    {
        List <MajorData> Major_data = new List <MajorData>();
        ConnectDB        db         = new ConnectDB();
        SqlDataSource    oracleObj  = db.ConnectionOracle();
        string           response   = "";
        string           sql        = "Select * From MAJOR Where DEPARTMENT_CODE = '" + department_code + "' And MAJOR_STATUS='0001' Order By MAJOR_CODE";

        try
        {
            oracleObj.SelectCommand = sql;

            DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView rowData in allData)
            {
                MajorData major = new MajorData();
                major.Major_Code           = rowData["MAJOR_CODE"].ToString();
                major.Major_Thai           = rowData["MAJOR_THAINAME"].ToString();
                major.Major_Eng            = rowData["MAJOR_ENGNAME"].ToString();
                major.Major_ShortName      = rowData["MAJOR_SHORTNAME"].ToString();
                major.Major_DepartmentCode = rowData["DEPARTMENT_CODE"].ToString();
                major.Major_Code_StudentID = rowData["MAJOR_CODE_STUDENTID"].ToString();
                major.Major_Status         = rowData["MAJOR_STATUS"].ToString();
                Major_data.Add(major);
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:Major: " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(Major_data);
    }
Esempio n. 3
0
    public MajorData getMajor(string Major_Code)
    {
        string    response   = "";
        MajorData Major_data = new MajorData();
        ConnectDB db         = new ConnectDB();

        try
        {
            SqlDataSource oracleObj = db.ConnectionOracle();

            oracleObj.SelectCommand = "Select * From MAJOR Where MAJOR_CODE='" + Major_Code + "'";
            DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView rowData in allData)
            {
                Major_data.Major_Code           = rowData["MAJOR_CODE"].ToString();
                Major_data.Major_Thai           = rowData["MAJOR_THAINAME"].ToString();
                Major_data.Major_Eng            = rowData["MAJOR_ENGNAME"].ToString();
                Major_data.Major_ShortName      = rowData["MAJOR_SHORTNAME"].ToString();
                Major_data.Major_DepartmentCode = rowData["DEPARTMENT_CODE"].ToString();
                Major_data.Major_Status         = rowData["MAJOR_STATUS"].ToString();
                Major_data.Major_Code_StudentID = rowData["MAJOR_CODE_STUDENTID"].ToString();
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:System Config: " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(Major_data);
    }
Esempio n. 4
0
    public string updateMajor(MajorData updateData)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "Update MAJOR Set MAJOR_THAINAME = '" + updateData.Major_Thai + "', MAJOR_ENGNAME='" + updateData.Major_Eng + "', MAJOR_SHORTNAME='" + updateData.Major_ShortName + "', DEPARTMENT_CODE='" + updateData.Major_DepartmentCode + "', MAJOR_CODE_STUDENTID='" + updateData.Major_Code_StudentID + "', MAJOR_STATUS='" + updateData.Major_Status + "' Where MAJOR_CODE='" + updateData.Major_Code + "'";

        oracleObj.UpdateCommand = sql;

        try
        {
            if (oracleObj.Update() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:System Config: " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(response);
    }
Esempio n. 5
0
    public string insertMajor(MajorData dataInsert)
    {
        string response = "";

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

        string sql = "";

        sql = "Insert Into MAJOR(MAJOR_CODE, MAJOR_THAINAME, MAJOR_ENGNAME, MAJOR_SHORTNAME, DEPARTMENT_CODE, MAJOR_CODE_STUDENTID, MAJOR_STATUS) Values('" + dataInsert.Major_Code + "','" + dataInsert.Major_Thai + "','" + dataInsert.Major_Eng + "','" + dataInsert.Major_ShortName + "','" + dataInsert.Major_DepartmentCode + "','" + dataInsert.Major_Code_StudentID + "','" + dataInsert.Major_Status + "')";

        oracleObj.InsertCommand = sql;

        try
        {
            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:System Config: " + response;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }
        return(response);
    }
Esempio n. 6
0
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        string           sql    = "Select * From MAJOR Where MAJOR_CODE='" + txtMAJOR_CODE.Text + "'";
        List <MajorData> chkDup = new Major().getMajorManual(sql);

        if (chkDup.Count > 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('รหัสสาขาวิชาซ้ำ!');", true);
        }
        else
        {
            MajorData data = new MajorData();

            data.Major_Code = txtMAJOR_CODE.Text;
            //data.Major_Code_StudentID = txtMAJOR_CODE_STUDENTID.Text;
            data.Major_Code_StudentID = "0";
            data.Major_DepartmentCode = ddlDEPARTMENT.SelectedValue;
            data.Major_Eng            = txtMAJOR_ENGNAME.Text;
            data.Major_ShortName      = txtMAJOR_SHORTNAME.Text;
            data.Major_Status         = ddlMAJOR_STATUS.SelectedValue;
            data.Major_Thai           = txtMAJOR_THAINAME.Text;

            string result = "";

            result = new Major().insertMajor(data);

            if (result == "OK")
            {
                Response.Redirect("list_Major.aspx");
            }
        }
    }
Esempio n. 7
0
        public void PopulateDropDownListMajor()
        {
            MajorData    data   = new MajorData();
            List <Major> majors = data.Majors();

            ddlMajor.DataTextField  = "mainMajor";
            ddlMajor.DataValueField = "idMajor";
            ddlMajor.DataSource     = majors;
            ddlMajor.DataBind();
        }
Esempio n. 8
0
    public List <MajorData> getCurriculumDivision(string Curriculum_Code)
    {
        string           curr_year         = Curriculum_Code.Substring(0, 4);
        string           curr_code         = Curriculum_Code.Substring(4);
        List <MajorData> CurrDivision_Data = new List <MajorData>();

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

        oracleObj.SelectCommand = "Select DIVISIONCODE From DIVISIONEXTENSION Where CURRCODE='" + curr_code + "' AND YEARVERSION=" + curr_year + "  Group By DIVISIONCODE Order By DIVISIONCODE";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            string    division_code     = rowData["DIVISIONCODE"].ToString();
            MajorData currdivision_data = new MajorData();
            currdivision_data = new Major().getMajor(division_code);
            CurrDivision_Data.Add(currdivision_data);
        }

        return(CurrDivision_Data);
    }
Esempio n. 9
0
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        MajorData saveData = new MajorData();

        saveData.Major_Code = txtMAJOR_CODE.Text;
        //saveData.Major_Code_StudentID = txtMAJOR_CODE_STUDENTID.Text;
        saveData.Major_Code_StudentID = "0";
        saveData.Major_DepartmentCode = ddlDEPARTMENT.SelectedValue;
        saveData.Major_Eng            = txtMAJOR_ENGNAME.Text;
        saveData.Major_ShortName      = txtMAJOR_SHORTNAME.Text;
        saveData.Major_Status         = ddlMAJOR_STATUS.SelectedValue;
        saveData.Major_Thai           = txtMAJOR_THAINAME.Text;

        string result = "";

        result = new Major().updateMajor(saveData);

        if (result == "OK")
        {
            Response.Redirect("list_Major.aspx");
        }
    }