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_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty)) { /*=============================*/ code = Request.QueryString["token"]; if (!Page.IsPostBack) { data = obj.getStdCategory(code); txtCATEGORY_CODE.Text = data.StdCategory_Code; txtCATEGORY_SHORT.Text = data.StdCategory_Short; txtCATEGORY_THAINAME.Text = data.StdCategory_Thai; txtCATEGORY_ENGNAME.Text = data.StdCategory_Eng; } /*=============================*/ } else { HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน"; HttpContext.Current.Response.Redirect("err_response.aspx"); } } }
protected void btnSAVE_Click(object sender, EventArgs e) { StdCategoryData dataSave = new StdCategoryData(); dataSave.StdCategory_Code = txtCATEGORY_CODE.Text; dataSave.StdCategory_Short = txtCATEGORY_SHORT.Text; dataSave.StdCategory_Thai = txtCATEGORY_THAINAME.Text; dataSave.StdCategory_Eng = txtCATEGORY_ENGNAME.Text; string result = ""; try { result = new StdCategory().updateStdCategory(dataSave); if (result == "OK") { Response.Redirect("list_Student_Category.aspx"); } else { Response.Redirect("list_Student_Category.aspx"); } } catch (Exception E) { //string response = E.Message.ToString(); //HttpContext.Current.Session["response"] = "Unit Test: " + response; //HttpContext.Current.Response.Redirect("err_response.aspx"); } }
public string insertStdCategory(StdCategoryData dataInsert) { string response = ""; ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); string sql = ""; sql = "Insert Into STUDENT_CATEGORY(CATEGORY_CODE, CATEGORY_THAINAME, CATEGORY_ENGNAME, CATEGORY_SHORT) Values('" + dataInsert.StdCategory_Code + "','" + dataInsert.StdCategory_Thai + "','" + dataInsert.StdCategory_Eng + "','" + dataInsert.StdCategory_Short + "')"; 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); }
public StdCategoryData getStdCategory(string stdcategory_code) { StdCategoryData StdCategory_data = new StdCategoryData(); ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); string response = ""; try { oracleObj.SelectCommand = "Select * From STUDENT_CATEGORY Where CATEGORY_CODE='" + stdcategory_code + "'"; DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty); foreach (DataRowView rowData in allData) { StdCategory_data.StdCategory_Code = rowData["CATEGORY_CODE"].ToString(); StdCategory_data.StdCategory_Thai = rowData["CATEGORY_THAINAME"].ToString(); StdCategory_data.StdCategory_Eng = rowData["CATEGORY_ENGNAME"].ToString(); StdCategory_data.StdCategory_Short = rowData["CATEGORY_SHORT"].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(StdCategory_data); }
public string updateStdCategory(StdCategoryData updateData) { string response = ""; ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); string sql = "Update STUDENT_CATEGORY Set CATEGORY_THAINAME = '" + updateData.StdCategory_Thai + "', CATEGORY_ENGNAME='" + updateData.StdCategory_Eng + "', CATEGORY_SHORT='" + updateData.StdCategory_Short + "' Where CATEGORY_CODE='" + updateData.StdCategory_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); }
protected void btnSAVE_Click(object sender, EventArgs e) { string sql = "Select * From STUDENT_CATEGORY Where CATEGORY_CODE='" + txtCATEGORY_CODE.Text + "'"; List <StdCategoryData> chkDup = new StdCategory().getStdCategoryManual(sql); if (chkDup.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('รหัสประเภทนักศึกษาซ้ำ!');", true); } else { StdCategoryData data = new StdCategoryData(); data.StdCategory_Code = txtCATEGORY_CODE.Text; data.StdCategory_Short = txtCATEGORY_SHORT.Text; data.StdCategory_Thai = txtCATEGORY_THAINAME.Text; data.StdCategory_Eng = txtCATEGORY_ENGNAME.Text; string result = ""; result = new StdCategory().insertStdCategory(data); if (result == "OK") { Response.Redirect("list_Student_Category.aspx"); } } }
//Pongsarun 26/2/2016: use for config system public List <StdCategoryData> getStdCategoryManual(string sql) { List <StdCategoryData> StdCategory_data = new List <StdCategoryData>(); ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); oracleObj.SelectCommand = sql; DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty); foreach (DataRowView rowData in allData) { StdCategoryData StdCategory = new StdCategoryData(); StdCategory.StdCategory_Code = rowData["CATEGORY_CODE"].ToString(); StdCategory.StdCategory_Thai = rowData["CATEGORY_THAINAME"].ToString(); StdCategory.StdCategory_Eng = rowData["CATEGORY_ENGNAME"].ToString(); StdCategory.StdCategory_Short = rowData["CATEGORY_SHORT"].ToString(); StdCategory_data.Add(StdCategory); } return(StdCategory_data); }