protected void lbuSubmit_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtInsertStatusWorkName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อสถานะการทำงาน')", true); return; } ClassStatusWork sw = new ClassStatusWork(); sw.SW_NAME = txtInsertStatusWorkName.Text; if (sw.CheckUseStatusWorkName()) { sw.InsertStatusWork(); 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 lblStatusWorkIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblStatusWorkIDEdit"); TextBox txtStatusWorkNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtStatusWorkNameEdit"); ClassStatusWork sw = new ClassStatusWork(Convert.ToInt32(lblStatusWorkIDEdit.Text) , txtStatusWorkNameEdit.Text); if (sw.CheckUseStatusWorkName()) { sw.UpdateStatusWork(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true); } }