protected void btnSubmitBlood_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertBloodID.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ รหัสกรุ๊ปเลือด')", true); return; } if (string.IsNullOrEmpty(txtInsertBloodName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อกรุ๊ปเลือด')", true); return; } ClassBlood b = new ClassBlood(); b.BLOOD_ID = Convert.ToInt32(txtInsertBloodID.Text); b.BLOOD_NAME = txtInsertBloodName.Text; if (b.CheckUseBloodID()) { b.InsertBlood(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีรหัสกรุ๊ปเลือดนี้นี้ อยู่ในระบบแล้ว !')", true); } }
void BindData1() { ClassBlood b = new ClassBlood(); DataTable dt = b.GetBloodSearch(txtSearchBloodID.Text, txtSearchBloodName.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
void BindData() { ClassBlood b = new ClassBlood(); DataTable dt = b.GetBlood("", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void btnSearchRefresh_Click(object sender, EventArgs e) { ClearData(); ClassBlood b = new ClassBlood(); DataTable dt = b.GetBlood("", ""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { TextBox txtBloodIDEDIT = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBloodIDEDIT"); TextBox txtBloodNameEDIT = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBloodNameEDIT"); ClassBlood b = new ClassBlood(Convert.ToInt32(txtBloodIDEDIT.Text), txtBloodNameEDIT.Text); b.UpdateBlood(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); ClassBlood b = new ClassBlood(); b.BLOOD_ID = id; b.DeleteBlood(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void btnSearchBlood_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchBloodID.Text) && string.IsNullOrEmpty(txtSearchBloodName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true); return; } else { ClassBlood b = new ClassBlood(); DataTable dt = b.GetBloodSearch(txtSearchBloodID.Text, txtSearchBloodName.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); } }