protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { Label lblDivisionIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblDivisionIDEdit"); TextBox txtDivisionNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtDivisionNameEdit"); DropDownList ddlCampusIDEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlCampusIDEdit"); DropDownList ddlFacultyIDEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlFacultyIDEdit"); ClassDivision d = new ClassDivision(Convert.ToInt32(lblDivisionIDEdit.Text) , txtDivisionNameEdit.Text , Convert.ToInt32(ddlCampusIDEdit.SelectedValue) , Convert.ToInt32(ddlFacultyIDEdit.SelectedValue)); if (d.CheckUseDivisionName()) { d.UpdateDivision(); 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(txtInsertDivisionName.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; } ClassDivision d = new ClassDivision(); d.DIVISION_NAME = txtInsertDivisionName.Text; d.CAMPUS_ID = Convert.ToInt32(ddlInsertCampus.SelectedValue); d.FACULTY_ID = Convert.ToInt32(ddlInsertFaculty.SelectedValue); if (d.CheckUseDivisionName()) { d.InsertDivision(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true); } }