void BindData() { ClassWorkDivision wd = new ClassWorkDivision(); DataTable dt = wd.GetWorkDivision("", "", "", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
void BindData1() { if (!string.IsNullOrEmpty(txtSearchWorkDivisionName.Text)) { ClassWorkDivision wd1 = new ClassWorkDivision(); DataTable dt1 = wd1.GetWorkDivision(txtSearchWorkDivisionName.Text, "", "", ""); GridView1.DataSource = dt1; GridView1.DataBind(); SetViewState(dt1); } if (ddlSearchCampus.SelectedIndex != 0) { ClassWorkDivision wd2 = new ClassWorkDivision(); DataTable dt2 = wd2.GetWorkDivision("", ddlSearchCampus.SelectedValue, "", ""); GridView1.DataSource = dt2; GridView1.DataBind(); SetViewState(dt2); } if (ddlSearchFaculty.SelectedIndex != 0) { ClassWorkDivision wd3 = new ClassWorkDivision(); DataTable dt3 = wd3.GetWorkDivision("", "", ddlSearchFaculty.SelectedValue, ""); GridView1.DataSource = dt3; GridView1.DataBind(); SetViewState(dt3); } if (ddlSearchDivision.SelectedIndex != 0) { ClassWorkDivision wd4 = new ClassWorkDivision(); DataTable dt4 = wd4.GetWorkDivision("", "", "", ddlSearchDivision.SelectedValue); GridView1.DataSource = dt4; GridView1.DataBind(); SetViewState(dt4); } }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { Label lblWorkDivisionIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblWorkDivisionIDEdit"); TextBox txtWorkDivisionNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtWorkDivisionNameEdit"); DropDownList ddlCampusIDEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlCampusIDEdit"); DropDownList ddlFacultyIDEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlFacultyIDEdit"); DropDownList ddlDivisionIDEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlDivisionIDEdit"); ClassWorkDivision wd = new ClassWorkDivision(Convert.ToInt32(lblWorkDivisionIDEdit.Text) , txtWorkDivisionNameEdit.Text , Convert.ToInt32(ddlCampusIDEdit.SelectedValue) , Convert.ToInt32(ddlFacultyIDEdit.SelectedValue) , Convert.ToInt32(ddlDivisionIDEdit.SelectedValue)); if (wd.CheckUseWorkDivisionName()) { wd.UpdateWorkDivision(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true); } }
protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); ClassWorkDivision wd = new ClassWorkDivision(); wd.WORK_ID = id; wd.DeleteWorkDivision(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true); if (txtSearchWorkDivisionName.Text != "" || ddlSearchCampus.SelectedIndex != 0 || ddlSearchFaculty.SelectedIndex != 0 || ddlSearchDivision.SelectedIndex != 0) { GridView1.EditIndex = -1; ; BindData1(); } else { GridView1.EditIndex = -1; ; BindData(); } }
protected void lbuSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertWorkDivisionName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่องาน / ฝ่าย')", true); return; } if (ddlInsertCampus.SelectedIndex == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก วิทยาเขต')", true); return; } if (ddlInsertFaculty.SelectedIndex == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก สำนัก / สถาบัน / คณะ')", true); return; } if (ddlInsertDivision.SelectedIndex == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก กอง / สำนักงานเลขา / ภาควิชา')", true); return; } ClassWorkDivision wd = new ClassWorkDivision(); wd.WORK_NAME = txtInsertWorkDivisionName.Text; wd.CAMPUS_ID = Convert.ToInt32(ddlInsertCampus.SelectedValue); wd.FACULTY_ID = Convert.ToInt32(ddlInsertFaculty.SelectedValue); wd.DIVISION_ID = Convert.ToInt32(ddlInsertDivision.SelectedValue); if (wd.CheckUseWorkDivisionName()) { wd.InsertWorkDivision(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true); } }
protected void lbuSearch_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchWorkDivisionName.Text) && ddlSearchCampus.SelectedIndex == 0 && ddlSearchFaculty.SelectedIndex == 0 && ddlSearchDivision.SelectedIndex == 0) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true); return; } else { if (!string.IsNullOrEmpty(txtSearchWorkDivisionName.Text)) { ClassWorkDivision wd1 = new ClassWorkDivision(); DataTable dt1 = wd1.GetWorkDivision(txtSearchWorkDivisionName.Text, "", "", ""); GridView1.DataSource = dt1; GridView1.DataBind(); SetViewState(dt1); } if (ddlSearchCampus.SelectedIndex != 0) { ClassWorkDivision wd2 = new ClassWorkDivision(); DataTable dt2 = wd2.GetWorkDivision("", ddlSearchCampus.SelectedValue, "", ""); GridView1.DataSource = dt2; GridView1.DataBind(); SetViewState(dt2); } if (ddlSearchFaculty.SelectedIndex != 0) { ClassWorkDivision wd3 = new ClassWorkDivision(); DataTable dt3 = wd3.GetWorkDivision("", "", ddlSearchFaculty.SelectedValue, ""); GridView1.DataSource = dt3; GridView1.DataBind(); SetViewState(dt3); } if (ddlSearchDivision.SelectedIndex != 0) { ClassWorkDivision wd4 = new ClassWorkDivision(); DataTable dt4 = wd4.GetWorkDivision("", "", "", ddlSearchDivision.SelectedValue); GridView1.DataSource = dt4; GridView1.DataBind(); SetViewState(dt4); } } }
protected void lbuRefresh_Click(object sender, EventArgs e) { ClearData(); ClassWorkDivision wd = new ClassWorkDivision(); DataTable dt = wd.GetWorkDivision("", "", "", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }