コード例 #1
0
        protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e)
        {
            Label lblpsPersonIDEdit = (Label)GridView1.Rows[e.RowIndex].FindControl("lblpsPersonIDEdit");
            TextBox txtpsPersonDegreeEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtpsPersonDegreeEdit");
            DropDownList ddlpsPersonGroupEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlpsPersonGroupEdit");
            DropDownList ddlpsPersonNameGroupEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlpsPersonNameGroupEdit");
            DropDownList ddlpsPersonTypeNameEdit = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlpsPersonTypeNameEdit");

            ClassPsPosition p = new ClassPsPosition(Convert.ToInt32(lblpsPersonIDEdit.Text)
                , txtpsPersonDegreeEdit.Text
                , Convert.ToInt32(ddlpsPersonGroupEdit.SelectedValue)
                , ddlpsPersonNameGroupEdit.SelectedValue
                , ddlpsPersonTypeNameEdit.SelectedValue);

            if (p.CheckUsePsPositionNameAndGroup())
            {
                p.UpdatePsPosition();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true);
                GridView1.EditIndex = -1;
                BindData();
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะอัพเดท มีอยู่ในระบบแล้ว !')", true);
            }
        }
コード例 #2
0
        protected void lbuSubmit_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtInsertDegree.Text))
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ชื่อระดับ')", true);
                return;
            }
            if (ddlInsertGroup.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก กลุ่มระดับ')", true);
                return;
            }
            if (ddlInsertNameGroup.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก ตำแหน่งประเภท')", true);
                return;
            }
            if (ddlInsertTypeName.SelectedIndex == 0)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาเลือก ประเภทของตำแหน่ง')", true);
                return;
            }
            ClassPsPosition p = new ClassPsPosition();
            p.P_NAME = txtInsertDegree.Text;
            p.P_GROUP = Convert.ToInt32(ddlInsertGroup.SelectedValue);
            p.P_NAMEGROUP = ddlInsertNameGroup.SelectedValue;
            p.P_TYPENAME = ddlInsertTypeName.SelectedValue;

            if (p.CheckUsePsPositionNameAndGroup())
            {
                p.InsertPsPosition();
                BindData();
                ClearData();
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true);
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ข้อมูลที่จะเพิ่ม มีอยู่ในระบบแล้ว !')", true);
            }
        }