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 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); } }