void BindData1() { ClassGradCountry gn = new ClassGradCountry(); DataTable dt = gn.GetGradCountrySearch(txtSearchGradCountry2.Text, txtSearchGradCountryShort.Text, txtSearchGradCountryLong.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
void BindData() { ClassGradCountry gc = new ClassGradCountry(); DataTable dt = gc.GetGradCountry("", "", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void btnSearchRefresh_Click(object sender, EventArgs e) { ClearData(); ClassGradCountry cg = new ClassGradCountry(); DataTable dt = cg.GetGradCountry("", "", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); ClassGradCountry cg = new ClassGradCountry(); cg.GRAD_COUNTRY_ID = id; cg.DeleteGradCountry(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void btnSearchGradCountry_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchGradCountry2.Text) && string.IsNullOrEmpty(txtSearchGradCountryShort.Text) && string.IsNullOrEmpty(txtSearchGradCountryLong.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true); return; } else { ClassGradCountry cg = new ClassGradCountry(); DataTable dt = cg.GetGradCountrySearch(txtSearchGradCountry2.Text, txtSearchGradCountryShort.Text, txtSearchGradCountryLong.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); } }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { Label lblGradCountryID = (Label)GridView1.Rows[e.RowIndex].FindControl("lblGradCountryID"); TextBox txtGradCountry2Edit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtGradCountry2Edit"); TextBox txtGradCountryShortEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtGradCountryShortEdit"); TextBox txtGradCountryLongEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtGradCountryLongEdit"); ClassGradCountry cg = new ClassGradCountry(Convert.ToInt32(lblGradCountryID.Text) , txtGradCountry2Edit.Text , txtGradCountryShortEdit.Text , txtGradCountryLongEdit.Text); cg.UpdateGradCountry(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void btnSubmitGradCountry_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertGradCountry2.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสประเทศ 2 ตัวอักษร(ENG)')", true); return; } if (string.IsNullOrEmpty(txtInsertGradCountryShort.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อย่อของประเทศ(ENG)')", true); return; } if (string.IsNullOrEmpty(txtInsertGradCountryLong.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อเต็มของประเทศ(ENG)')", true); return; } ClassGradCountry cg = new ClassGradCountry(); cg.GRAD_ISO2 = txtInsertGradCountry2.Text; cg.GRAD_SHORT_NAME = txtInsertGradCountryShort.Text; cg.GRAD_LONG_NAME = txtInsertGradCountryLong.Text; if (cg.CheckUseGradCountryID()) { cg.InsertGradCountry(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสสัญชาตินี้ อยู่ในระบบแล้ว !')", true); } }