protected void lbuSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertBudgetName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อประเภทเงินจ้าง')", true); return; } ClassBudget b = new ClassBudget(); b.BUDGET_NAME = txtInsertBudgetName.Text; if (b.CheckUseBudgetName()) { b.InsertBudget(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true); } }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { Label lblBudgetIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblBudgetIDEdit"); TextBox txtBudgetNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBudgetNameEdit"); ClassBudget b = new ClassBudget(Convert.ToInt32(lblBudgetIDEdit.Text) , txtBudgetNameEdit.Text); if (b.CheckUseBudgetName()) { b.UpdateBudget(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true); } }