コード例 #1
0
        protected void modDeleteCommand5(Object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(GridViewPAS.DataKeys[e.RowIndex].Value);

            PS_POSITION_AND_SALARY PPAS = new PS_POSITION_AND_SALARY();
            PPAS.PS_PAS_ID = id;
            PPAS.DELETE_PS_POSITION_AND_SALARY();

            PS_PERSON P0 = new PS_PERSON();
            int salary = DatabaseManager.ExecuteInt("SELECT * FROM (SELECT PS_SALARY FROM PS_POSITION_AND_SALARY ORDER BY PS_DATE DESC) WHERE ROWNUM = 1");
            int posisalary = DatabaseManager.ExecuteInt("SELECT * FROM (SELECT PS_SALARY_POSITION FROM PS_POSITION_AND_SALARY ORDER BY PS_DATE DESC) WHERE ROWNUM = 1");

            P0.PS_SALARY = Convert.ToInt32(salary);
            P0.PS_POSS_SALARY = Convert.ToInt32(posisalary);
            P0.PS_CITIZEN_ID = p;
            P0.UPDATE_CURRENT_SALARY_PERSON();

            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true);

            if (string.IsNullOrEmpty(labelCitizenID.Text))
            {
                GridViewPAS.EditIndex = -1;
                BindData();
            }
            else
            {
                GridViewPAS.EditIndex = -1;
                BindData1();
            }
        }
コード例 #2
0
        protected void lbuTab4Save_Click(object sender, EventArgs e)
        {
            using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING)) {
                con.Open();
                int staffTypeID = -1;
                using (OracleCommand com = new OracleCommand("SELECT PS_STAFFTYPE_ID FROM PS_PERSON WHERE PS_CITIZEN_ID = '" + p + "'", con)) {
                    using (OracleDataReader reader = com.ExecuteReader()) {
                        while (reader.Read()) {
                            staffTypeID = reader.GetInt32(0);
                        }
                    }
                }

                idPositionShowAll.Visible = false;
                idPositionShowGover.Visible = false;
                idPositionShowOfficeEmp.Visible = false;

                GridviewPDHgover.Visible = false;
                GridviewPDHemp.Visible = false;

                if (staffTypeID == 1)
                {
                    idPositionShowAll.Visible = true;
                    idPositionShowGover.Visible = true;
                    GridviewPDHgover.Visible = true;
                }
                else if (staffTypeID == 2)
                {
                    idPositionShowAll.Visible = true;
                }
                else if (staffTypeID == 3)
                {
                    idPositionShowAll.Visible = true;
                }
                else if (staffTypeID == 4)
                {
                    idPositionShowAll.Visible = true;
                }
                else if (staffTypeID == 5)
                {
                    idPositionShowAll.Visible = true;
                }
                else if (staffTypeID == 6)
                {
                    idPositionShowAll.Visible = true;
                    idPositionShowOfficeEmp.Visible = true;
                    GridviewPDHemp.Visible = true;
                }

                {
                    if (ddlTab4PositionWorkRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งในสายงาน</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlTab4AdminPositionRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งทางบริหาร</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlTab4AcadPositionRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งทางวิชาการ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }

                    //บันทึก 3 ตัว
                    PS_PERSON P0 = new PS_PERSON();
                    P0.PS_WORK_POS_ID = Convert.ToInt32(ddlTab4PositionWorkRow1.SelectedValue);
                    P0.PS_ADMIN_POS_ID = Convert.ToInt32(ddlTab4AdminPositionRow1.SelectedValue);
                    P0.PS_ACAD_POS_ID = Convert.ToInt32(ddlTab4AcadPositionRow1.SelectedValue);
                    P0.PS_CITIZEN_ID = p;
                    P0.UPDATE_PS_PERSON_TAB4_EVERYONE();

                    if (chkBoxWorkPosition.Checked)
                    {
                        PS_PERSON P2 = new PS_PERSON();
                        P2.PS_START_POSI_ID = Convert.ToInt32(ddlTab4PositionWorkRow1.SelectedValue);
                        P2.PS_CITIZEN_ID = p;
                        P2.UPDATE_PS_PERSON_START_WORK_POSITION_FIRST_TIME();

                    }
                    if (chkBoxAdminPosition.Checked)
                    {
                        PS_PERSON P3 = new PS_PERSON();
                        P3.PS_START_ADMIN_POSI_ID = Convert.ToInt32(ddlTab4AdminPositionRow1.SelectedValue);
                        P3.PS_CITIZEN_ID = p;
                        P3.UPDATE_PS_PERSON_START_ADMIN_POSITION_FIRST_TIME();
                    }

                    notification.Attributes["class"] = "alert alert_success";
                    notification.InnerHtml = "";
                    notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลตำแหน่งสำเร็จ</strong></div>";
                }

                if (staffTypeID == 1) {

                    if (ddlTab4PositionWorkRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งในสายงาน</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlTab4AdminPositionRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งทางบริหาร</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlTab4AcadPositionRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งทางวิชาการ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }

                    //ถ้าเลือกดรอป ต้องกรอกวันที่
                    if (ddlShowMenuGoverTab4.SelectedIndex == 1)
                    {
                        if (tbDateGetPositionGoverTab4.Text == "" || ddlTab4AdminPositionDegreeRow2.SelectedIndex == 0)
                        {
                            notification.Attributes["class"] = "alert alert_danger";
                            notification.InnerHtml = "";
                            notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                            notification.InnerHtml += "<div>กรุณากรอกวันที่ได้รับตำแหน่งและเลือกตำแหน่งประเภทบริหาร</div>";
                            return;
                        }
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlShowMenuGoverTab4.SelectedIndex == 2)
                    {
                        if (tbDateGetPositionGoverTab4.Text == "" || ddlTab4DirectPositionDegreeRow2.SelectedIndex == 0)
                        {
                            notification.Attributes["class"] = "alert alert_danger";
                            notification.InnerHtml = "";
                            notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                            notification.InnerHtml += "<div>กรุณากรอกวันที่ได้รับตำแหน่งและเลือกตำแหน่งประเภทอำนวยการ</div>";
                            return;
                        }
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlShowMenuGoverTab4.SelectedIndex == 3)
                    {
                        if (tbDateGetPositionGoverTab4.Text == "" || ddlTab4AcadPositionDegreeRow2.SelectedIndex == 0)
                        {
                            notification.Attributes["class"] = "alert alert_danger";
                            notification.InnerHtml = "";
                            notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                            notification.InnerHtml += "<div>กรุณากรอกวันที่ได้รับตำแหน่งและเลือกตำแหน่งประเภทวิชาการ</div>";
                            return;
                        }
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlShowMenuGoverTab4.SelectedIndex == 4)
                    {
                        if (tbDateGetPositionGoverTab4.Text == "" || ddlTab4GeneralPositionDegreeRow2.SelectedIndex == 0)
                        {
                            notification.Attributes["class"] = "alert alert_danger";
                            notification.InnerHtml = "";
                            notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                            notification.InnerHtml += "<div>กรุณากรอกวันที่ได้รับตำแหน่งและเลือกตำแหน่งประเภททั่วไป</div>";
                            return;
                        }
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }

                    //เลือกได้แค่ 1 อัน
                    //***

                    ddlShowMenuGoverTab4.SelectedIndex = 0;

                    //มีอยู่แล้วในระบบ ห้ามเลือกซ้ำ
                    //DropMiddle1 - ตำแหน่งประเภทบริหาร
                    string result1 = "";
                    using (OracleCommand com = new OracleCommand("SELECT PDH_POSITION_GET FROM TB_PDH_GOVER WHERE PDH_POSITION_GET = '" + ddlTab4AdminPositionDegreeRow2.SelectedValue + "'", con))
                    {
                        using (OracleDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result1 = reader.GetInt32(0).ToString();
                            }
                        }
                    }
                    if (result1 == ddlTab4AdminPositionDegreeRow2.SelectedValue)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
                        notification.InnerHtml += "<div> - มีข้อมูลตำแหน่งข้าราชการที่คุณเลือกนี้อยู่แล้วในระบบ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    //DropMiddle2 - ตำแหน่งประเภทอำนวยการ
                    string result2 = "";
                    using (OracleCommand com = new OracleCommand("SELECT PDH_POSITION_GET FROM TB_PDH_GOVER WHERE PDH_POSITION_GET = '" + ddlTab4DirectPositionDegreeRow2.SelectedValue + "'", con))
                    {
                        using (OracleDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result2 = reader.GetInt32(0).ToString();
                            }
                        }
                    }
                    if (result2 == ddlTab4DirectPositionDegreeRow2.SelectedValue)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
                        notification.InnerHtml += "<div> - มีข้อมูลตำแหน่งข้าราชการที่คุณเลือกนี้อยู่แล้วในระบบ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    //DropMiddle3 - ตำแหน่งประเภทวิชาการ
                    string result3 = "";
                    using (OracleCommand com = new OracleCommand("SELECT PDH_POSITION_GET FROM TB_PDH_GOVER WHERE PDH_POSITION_GET = '" + ddlTab4AcadPositionDegreeRow2.SelectedValue + "'", con))
                    {
                        using (OracleDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result3 = reader.GetInt32(0).ToString();
                            }
                        }
                    }
                    if (result3 == ddlTab4AcadPositionDegreeRow2.SelectedValue)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
                        notification.InnerHtml += "<div> - มีข้อมูลตำแหน่งข้าราชการที่คุณเลือกนี้อยู่แล้วในระบบ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    //DropMiddle4 - ตำแหน่งประเภททั่วไป
                    string result4 = "";
                    using (OracleCommand com = new OracleCommand("SELECT PDH_POSITION_GET FROM TB_PDH_GOVER WHERE PDH_POSITION_GET = '" + ddlTab4GeneralPositionDegreeRow2.SelectedValue + "'", con))
                    {
                        using (OracleDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result4 = reader.GetInt32(0).ToString();
                            }
                        }
                    }
                    if (result4 == ddlTab4GeneralPositionDegreeRow2.SelectedValue)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
                        notification.InnerHtml += "<div> - มีข้อมูลตำแหน่งข้าราชการที่คุณเลือกนี้อยู่แล้วในระบบ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }

                    if (ddlTab4AdminPositionDegreeRow2.SelectedIndex == 0 && ddlTab4DirectPositionDegreeRow2.SelectedIndex == 0 && ddlTab4AcadPositionDegreeRow2.SelectedIndex == 0 && ddlTab4GeneralPositionDegreeRow2.SelectedIndex == 0)
                    {
                        //กลาง
                        PS_PERSON P0 = new PS_PERSON();
                        TB_PDH_GOVER P1 = new TB_PDH_GOVER();
                        P0.PS_WORK_POS_ID = Convert.ToInt32(ddlTab4PositionWorkRow1.SelectedValue);
                        P0.PS_ADMIN_POS_ID = Convert.ToInt32(ddlTab4AdminPositionRow1.SelectedValue);
                        P0.PS_ACAD_POS_ID = Convert.ToInt32(ddlTab4AcadPositionRow1.SelectedValue);
                        P0.PS_POSI_ADMIN = Convert.ToInt32(ddlTab4AdminPositionDegreeRow2.SelectedValue);
                        P0.PS_POSI_DIRECT = Convert.ToInt32(ddlTab4DirectPositionDegreeRow2.SelectedValue);
                        P0.PS_POSI_ACAD = Convert.ToInt32(ddlTab4AcadPositionDegreeRow2.SelectedValue);
                        P0.PS_POSI_GENERAL = Convert.ToInt32(ddlTab4GeneralPositionDegreeRow2.SelectedValue);
                        P0.PS_CITIZEN_ID = p;
                        P0.UPDATE_PS_PERSON_TAB4_EVERYONE_GOVER();

                        DataTable dt = P1.SELECT_POSI_GOVER_ONLY(p, "", "");
                        GridviewPDHgover.DataSource = dt;
                        GridviewPDHgover.DataBind();
                        SetViewState(dt);

                        notification.Attributes["class"] = "alert alert_success";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลตำแหน่งสำเร็จ</strong></div>";
                    }
                    else
                    {
                        //กลาง ////////////////////////////
                        PS_PERSON P0 = new PS_PERSON();
                        P0.PS_WORK_POS_ID = Convert.ToInt32(ddlTab4PositionWorkRow1.SelectedValue);
                        P0.PS_ADMIN_POS_ID = Convert.ToInt32(ddlTab4AdminPositionRow1.SelectedValue);
                        P0.PS_ACAD_POS_ID = Convert.ToInt32(ddlTab4AcadPositionRow1.SelectedValue);
                        P0.PS_POSI_ADMIN = Convert.ToInt32(ddlTab4AdminPositionDegreeRow2.SelectedValue);
                        P0.PS_POSI_DIRECT = Convert.ToInt32(ddlTab4DirectPositionDegreeRow2.SelectedValue);
                        P0.PS_POSI_ACAD = Convert.ToInt32(ddlTab4AcadPositionDegreeRow2.SelectedValue);
                        P0.PS_POSI_GENERAL = Convert.ToInt32(ddlTab4GeneralPositionDegreeRow2.SelectedValue);
                        P0.PS_CITIZEN_ID = p;
                        P0.UPDATE_PS_PERSON_TAB4_EVERYONE_GOVER();

                        TB_PDH_GOVER P1 = new TB_PDH_GOVER();
                        P1.PDH_CITIZEN_ID = p;
                        P1.PDH_DATE_START = Util.ODT(tbDateGetPositionGoverTab4.Text);

                        if(ddlTab4AdminPositionDegreeRow2.SelectedIndex != 0)
                        {
                            P1.PDH_POSITION_GET = Convert.ToInt32(ddlTab4AdminPositionDegreeRow2.SelectedValue);
                        }
                        if (ddlTab4DirectPositionDegreeRow2.SelectedIndex != 0)
                        {
                            P1.PDH_POSITION_GET = Convert.ToInt32(ddlTab4DirectPositionDegreeRow2.SelectedValue);
                        }
                        if (ddlTab4AcadPositionDegreeRow2.SelectedIndex != 0)
                        {
                            P1.PDH_POSITION_GET = Convert.ToInt32(ddlTab4AcadPositionDegreeRow2.SelectedValue);
                        }
                        if (ddlTab4GeneralPositionDegreeRow2.SelectedIndex != 0)
                        {
                            P1.PDH_POSITION_GET = Convert.ToInt32(ddlTab4GeneralPositionDegreeRow2.SelectedValue);
                        }

                        P1.INSERT_POSI_GOVER_ONLY();

                        ClearMiddleTab4();
                        DataTable dt = P1.SELECT_POSI_GOVER_ONLY(p, "", "");
                        GridviewPDHgover.DataSource = dt;
                        GridviewPDHgover.DataBind();
                        SetViewState(dt);

                        notification.Attributes["class"] = "alert alert_success";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลตำแหน่งสำเร็จ</strong></div>";
                    }

                } else if (staffTypeID == 6) {
                    if (ddlTab4PositionWorkRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งในสายงาน</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlTab4AdminPositionRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งทางบริหาร</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }
                    if (ddlTab4AcadPositionRow1.SelectedIndex == 0)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                        notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งทางวิชาการ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }

                    //ถ้าเลือกดรอป ต้องกรอกวันที่
                    if (ddlTab4EmpPositionRow3.SelectedIndex != 0)
                    {
                        if (tbDateGetPositionEMPTab4.Text == "")
                        {
                            notification.Attributes["class"] = "alert alert_danger";
                            notification.InnerHtml = "";
                            notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                            notification.InnerHtml += "<div>กรุณากรอกวันที่ได้รับตำแหน่ง</div>";
                            return;
                        }
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }

                    //DropRight1 - ตำแหน่งพนักงานราชการ
                    string result5 = "";
                    using (OracleCommand com = new OracleCommand("SELECT PDH_POSITION_GET FROM TB_PDH_EMP WHERE PDH_POSITION_GET = '" + ddlTab4EmpPositionRow3.SelectedValue + "'", con))
                    {
                        using (OracleDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                result5 = reader.GetInt32(0).ToString();
                            }
                        }
                    }
                    if (result5 == ddlTab4EmpPositionRow3.SelectedValue)
                    {
                        notification.Attributes["class"] = "alert alert_danger";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
                        notification.InnerHtml += "<div> - มีข้อมูลตำแหน่งพนักงานราชการที่คุณเลือกนี้อยู่แล้วในระบบ</div>";
                        return;
                    }
                    else
                    {
                        notification.Attributes["class"] = "none";
                        notification.InnerHtml = "";
                    }

                    if (ddlTab4EmpPositionRow3.SelectedIndex == 0)
                    {
                        //ขวา
                        PS_PERSON P0 = new PS_PERSON();
                        TB_PDH_EMP P2 = new TB_PDH_EMP();
                        P0.PS_WORK_POS_ID = Convert.ToInt32(ddlTab4PositionWorkRow1.SelectedValue);
                        P0.PS_ADMIN_POS_ID = Convert.ToInt32(ddlTab4AdminPositionRow1.SelectedValue);
                        P0.PS_ACAD_POS_ID = Convert.ToInt32(ddlTab4AcadPositionRow1.SelectedValue);
                        P0.PS_POSI_EMP_GROUP = Convert.ToInt32(ddlTab4EmpPositionRow3.SelectedValue);
                        P0.PS_CITIZEN_ID = p;
                        P0.UPDATE_PS_PERSON_TAB4_EVERYONE_EMP();

                        DataTable dt = P2.SELECT_POSI_EMP_ONLY(p, "", "");
                        GridviewPDHemp.DataSource = dt;
                        GridviewPDHemp.DataBind();
                        SetViewState(dt);

                        notification.Attributes["class"] = "alert alert_success";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลตำแหน่งสำเร็จ</strong></div>";
                    }
                    else
                    {
                        //ขวา
                        PS_PERSON P0 = new PS_PERSON();
                        P0.PS_WORK_POS_ID = Convert.ToInt32(ddlTab4PositionWorkRow1.SelectedValue);
                        P0.PS_ADMIN_POS_ID = Convert.ToInt32(ddlTab4AdminPositionRow1.SelectedValue);
                        P0.PS_ACAD_POS_ID = Convert.ToInt32(ddlTab4AcadPositionRow1.SelectedValue);
                        P0.PS_POSI_EMP_GROUP = Convert.ToInt32(ddlTab4EmpPositionRow3.SelectedValue);
                        P0.PS_CITIZEN_ID = p;
                        P0.UPDATE_PS_PERSON_TAB4_EVERYONE_EMP();

                        TB_PDH_EMP P2 = new TB_PDH_EMP();
                        P2.PDH_CITIZEN_ID = p;
                        P2.PDH_DATE_START = Util.ODT(tbDateGetPositionEMPTab4.Text);

                        if (ddlTab4EmpPositionRow3.SelectedIndex != 0)
                        {
                            P2.PDH_POSITION_GET = Convert.ToInt32(ddlTab4EmpPositionRow3.SelectedValue);
                        }

                        P2.INSERT_POSI_EMP_ONLY();

                        ClearRightTab4();
                        DataTable dt = P2.SELECT_POSI_EMP_ONLY(p, "", "");
                        GridviewPDHemp.DataSource = dt;
                        GridviewPDHemp.DataBind();
                        SetViewState(dt);

                        notification.Attributes["class"] = "alert alert_success";
                        notification.InnerHtml = "";
                        notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลตำแหน่งสำเร็จ</strong></div>";
                    }

                }
            }
        }
コード例 #3
0
        protected void lbuTab9Save_Click(object sender, EventArgs e)
        {
            if (tbDate14.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกวัน เดือน ปี</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbPosition14.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกตำแหน่ง</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbPositionNo14.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกเลขที่ตำแหน่ง</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlPositionType14.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกตำแหน่งประเภท</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlPositionDegree14.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกระดับ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbSalary14.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกเงินเดือน</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbSalaryPosition14.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกเงินประจำตำแหน่ง</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbRef14.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกเอกสารอ้างอิง</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            PS_PERSON P0 = new PS_PERSON();
            PS_POSITION_AND_SALARY PPAS = new PS_POSITION_AND_SALARY();
            PPAS.PS_CITIZEN_ID = p;
            PPAS.PS_DATE = Util.ODT(tbDate14.Text);
            PPAS.PS_POSITION = tbPosition14.Text;
            PPAS.PS_POSITION_NO = tbPositionNo14.Text;
            PPAS.PS_POSITION_TYPE = ddlPositionType14.SelectedValue;
            PPAS.PS_POSITION_DEGREE = ddlPositionDegree14.SelectedValue;
            PPAS.PS_SALARY = Convert.ToInt32(tbSalary14.Text);
            PPAS.PS_SALARY_POSITION = Convert.ToInt32(tbSalaryPosition14.Text);
            PPAS.PS_REF = tbRef14.Text;
            PPAS.INSERT_PS_POSITION_AND_SALARY();

            int salary = DatabaseManager.ExecuteInt("SELECT * FROM (SELECT PS_SALARY FROM PS_POSITION_AND_SALARY ORDER BY PS_DATE DESC) WHERE ROWNUM = 1");
            int posisalary = DatabaseManager.ExecuteInt("SELECT * FROM (SELECT PS_SALARY_POSITION FROM PS_POSITION_AND_SALARY ORDER BY PS_DATE DESC) WHERE ROWNUM = 1");

            P0.PS_SALARY = Convert.ToInt32(salary);
            P0.PS_POSS_SALARY = Convert.ToInt32(posisalary);
            P0.PS_CITIZEN_ID = p;
            P0.UPDATE_CURRENT_SALARY_PERSON();

            ClearPPAS14();
            DataTable dt5 = PPAS.SELECT_PS_POSITION_AND_SALARY(p, "", "", "", "", "", "", "", "");
            GridViewPAS.DataSource = dt5;
            GridViewPAS.DataBind();
            SetViewState(dt5);

            notification.Attributes["class"] = "alert alert_success";
            notification.InnerHtml = "";
            notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลตำแหน่งและเงินเดือนสำเร็จ</strong></div>";
        }
コード例 #4
0
        protected void lbuTab3Save_Click(object sender, EventArgs e)
        {
            if (ddlCampus.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกวิทยาเขต</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlFaculty.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกสำนัก / สถาบัน / คณะ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlDivision.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกกอง / สำนักงานเลขา / ภาควิชา</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING))
            {
                con.Open();
                using (OracleCommand com = new OracleCommand("SELECT COUNT(*) FROM TB_WORK_DIVISION WHERE DIVISION_ID = " + ddlDivision.SelectedValue, con))
                {
                    using (OracleDataReader reader = com.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (reader.GetInt32(0) != 0 && ddlWorkDivision.SelectedIndex == 0)
                            {
                                notification.Attributes["class"] = "alert alert_danger";
                                notification.InnerHtml = "";
                                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                                notification.InnerHtml += "<div>กรุณาเลือกงาน / ฝ่าย</div>";
                                return;
                            }
                            else
                            {
                                notification.Attributes["class"] = "none";
                                notification.InnerHtml = "";
                            }
                            if(reader.GetInt32(0) == 0)
                            {
                                ddlWorkDivision.SelectedIndex = 0;
                                using (OracleCommand com1 = new OracleCommand("UPDATE PS_PERSON SET PS_WORK_DIVISION_ID = null where ps_citizen_id = '" + p + "'", con))
                                {
                                    com1.ExecuteNonQuery();
                                }
                            }
                        }
                    }
                }
            }

            if (ddlStaffType.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกประเภทบุคลากร</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbDateInwork.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกวันที่บรรจุ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            //วันที่บรรจุไม่สามารถน้อยกว่าวันเกิด
            DateTime dtFromDateInwork = Util.ToDateTimeOracle(tbDateInwork.Text);
            DateTime dtToDateBirthday = Util.ToDateTimeOracle(tbBirthday.Text);
            int totalDayDateInwork = (int)(dtFromDateInwork - dtToDateBirthday.AddYears(20)).TotalDays + 1;
            if (totalDayDateInwork <= 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>วันที่บรรจุไม่สามารถต่ำกว่า 20 ปีของวันเกิด</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            //วันที่ลาออกว่าง
            if (ddlTab10StatusWork.SelectedValue == "19" && string.IsNullOrEmpty(tbDateQuit.Text))
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกวันที่ลาออก</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            //วันที่ลาออก ต้องไม่ต่ำกว่าวันที่เข้าทำงาน
            if (tbDateQuit.Text != "")
            {
                DateTime dtFromDate = Util.ToDateTimeOracle(tbDateInwork.Text);
                DateTime dtToDate = Util.ToDateTimeOracle(tbDateQuit.Text);
                int totalDay = (int)(dtToDate - dtFromDate).TotalDays + 1;

                if (totalDay <= 0)
                {
                    notification.Attributes["class"] = "alert alert_danger";
                    notification.InnerHtml = "";
                    notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                    notification.InnerHtml += "<div>วันที่ลาออกไม่สามารถต่ำกว่าวันที่บรรจุได้</div>";
                    return;
                }
                else
                {
                    notification.Attributes["class"] = "none";
                    notification.InnerHtml = "";
                }
            }

            if (ddlWorkDivision.SelectedIndex == 0)
            {
                PS_PERSON P0 = new PS_PERSON();
                P0.PS_CAMPUS_ID = Convert.ToInt32(ddlCampus.SelectedValue);
                P0.PS_FACULTY_ID = Convert.ToInt32(ddlFaculty.SelectedValue);
                P0.PS_DIVISION_ID = Convert.ToInt32(ddlDivision.SelectedValue);
                P0.PS_STAFFTYPE_ID = Convert.ToInt32(ddlStaffType.SelectedValue);
                P0.PS_BUDGET_ID = Convert.ToInt32(ddlBudget.SelectedValue);
                P0.PS_SPECIAL_WORK = tbSpecialWork.Text;
                P0.PS_TEACH_ISCED_ID = ddlTeachISCED.SelectedValue;
                P0.PS_INWORK_DATE = Util.ODT(tbDateInwork.Text);
                P0.PS_SALARY = Convert.ToInt32(lblPositionSalary.Text);
                P0.PS_POSS_SALARY = Convert.ToInt32(lblPositionSalary.Text);
                P0.PS_SW_ID = Convert.ToInt32(ddlTab10StatusWork.SelectedValue);
                P0.PS_CITIZEN_ID = p;

                P0.UPDATE_PS_PERSON_TAB3_DV();
                notification.Attributes["class"] = "alert alert_success";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลการทำงานสำเร็จ</strong></div>";
            }
            else
            {
                PS_PERSON P0 = new PS_PERSON();
                P0.PS_CAMPUS_ID = Convert.ToInt32(ddlCampus.SelectedValue);
                P0.PS_FACULTY_ID = Convert.ToInt32(ddlFaculty.SelectedValue);
                P0.PS_DIVISION_ID = Convert.ToInt32(ddlDivision.SelectedValue);
                P0.PS_WORK_DIVISION_ID = Convert.ToInt32(ddlWorkDivision.SelectedValue);
                P0.PS_STAFFTYPE_ID = Convert.ToInt32(ddlStaffType.SelectedValue);
                P0.PS_BUDGET_ID = Convert.ToInt32(ddlBudget.SelectedValue);
                P0.PS_SPECIAL_WORK = tbSpecialWork.Text;
                P0.PS_TEACH_ISCED_ID = ddlTeachISCED.SelectedValue;
                P0.PS_INWORK_DATE = Util.ODT(tbDateInwork.Text);
                P0.PS_SALARY = Convert.ToInt32(lblPositionSalary.Text);
                P0.PS_POSS_SALARY = Convert.ToInt32(lblPositionSalary.Text);
                P0.PS_SW_ID = Convert.ToInt32(ddlTab10StatusWork.SelectedValue);
                P0.PS_CITIZEN_ID = p;

                P0.UPDATE_PS_PERSON_TAB3_WD();
                notification.Attributes["class"] = "alert alert_success";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลการทำงานสำเร็จ</strong></div>";
            }

            using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING))
            {
                using (OracleCommand com = new OracleCommand("UPDATE PS_PERSON SET PS_DATE_QUIT = :PS_DATE_QUIT WHERE PS_CITIZEN_ID = :PS_CITIZEN_ID", con))
                {

                    if (con.State != ConnectionState.Open)
                    {
                        con.Open();
                    }

                    if (ddlTab10StatusWork.SelectedValue != "19")
                    {
                        com.Parameters.Add(new OracleParameter("PS_DATE_QUIT", null));
                        com.Parameters.Add(new OracleParameter("PS_CITIZEN_ID", p));
                        com.ExecuteNonQuery();
                    }
                    else
                    {
                        com.Parameters.Add(new OracleParameter("PS_DATE_QUIT", Util.ODT(tbDateQuit.Text)));
                        com.Parameters.Add(new OracleParameter("PS_CITIZEN_ID", p));
                        com.ExecuteNonQuery();
                    }
                    com.Dispose();
                    con.Close();
                }
            }
        }
コード例 #5
0
        protected void lbuTab2Save_Click(object sender, EventArgs e)
        {
            PS_PERSON P0 = new PS_PERSON();
            P0.PS_HOMEADD = tbHomeAdd.Text;
            P0.PS_SOI = tbSoi.Text;
            P0.PS_MOO = tbMoo.Text;
            P0.PS_STREET = tbRoad.Text;
            P0.PS_PROVINCE_ID = Convert.ToInt32(ddlProvince.SelectedValue);
            P0.PS_AMPHUR_ID = Convert.ToInt32(ddlAmphur.SelectedValue);
            P0.PS_DISTRICT = Convert.ToInt32(ddlDistrict.SelectedValue);
            P0.PS_ZIPCODE = tbZipcode.Text;
            P0.PS_COUNTRY_ID = Convert.ToInt32(ddlCountry.SelectedValue);
            P0.PS_STATE = tbState.Text;
            P0.PS_HOMEADD_NOW = tbHomeAdd2.Text;
            P0.PS_SOI_NOW = tbSoi2.Text;
            P0.PS_MOO_NOW = tbMoo2.Text;
            P0.PS_STREET_NOW = tbRoad.Text;
            P0.PS_PROVINCE_ID_NOW = Convert.ToInt32(ddlProvince2.SelectedValue);
            P0.PS_AMPHUR_ID_NOW = Convert.ToInt32(ddlAmphur2.SelectedValue);
            P0.PS_DISTRICT_ID_NOW = Convert.ToInt32(ddlDistrict2.SelectedValue);
            P0.PS_ZIPCODE_NOW = tbZipcode2.Text;
            P0.PS_COUNTRY_ID_NOW = Convert.ToInt32(ddlCountry2.SelectedValue);
            P0.PS_STATE_NOW = tbState2.Text;
            P0.PS_CITIZEN_ID = p;

            P0.UPDATE_PS_PERSON_TAB2();
            notification.Attributes["class"] = "alert alert_success";
            notification.InnerHtml = "";
            notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลที่อยู่สำเร็จ</strong></div>";

            /*using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING))
            {
                using (OracleCommand com = new OracleCommand("UPDATE PS_PERSON SET PS_COUNTRY_ID = :PS_COUNTRY_ID WHERE PS_CITIZEN_ID = :PS_CITIZEN_ID", con))
                using (OracleCommand com1 = new OracleCommand("UPDATE PS_PERSON SET PS_COUNTRY_ID_NOW = :PS_COUNTRY_ID_NOW WHERE PS_CITIZEN_ID = :PS_CITIZEN_ID", con))
                {

                    if (con.State != ConnectionState.Open)
                    {
                        con.Open();
                    }

                    if (ddlCountry.SelectedIndex == 0)
                    {
                        com.Parameters.Add(new OracleParameter("PS_COUNTRY_ID", null));
                        com.Parameters.Add(new OracleParameter("PS_CITIZEN_ID", p));
                        com.ExecuteNonQuery();
                    }
                    else
                    {
                        com.Parameters.Add(new OracleParameter("PS_COUNTRY_ID", ddlCountry.SelectedValue));
                        com.Parameters.Add(new OracleParameter("PS_CITIZEN_ID", p));
                        com.ExecuteNonQuery();
                    }
                    if (ddlCountry2.SelectedIndex == 0)
                    {
                        com1.Parameters.Add(new OracleParameter("PS_COUNTRY_ID_NOW", null));
                        com1.Parameters.Add(new OracleParameter("PS_CITIZEN_ID", p));
                        com1.ExecuteNonQuery();
                    }
                    else
                    {
                        com1.Parameters.Add(new OracleParameter("PS_COUNTRY_ID_NOW", ddlCountry2.SelectedValue));
                        com1.Parameters.Add(new OracleParameter("PS_CITIZEN_ID", p));
                        com1.ExecuteNonQuery();
                    }
                    com.Dispose();
                    con.Close();
                }
            }*/
        }
コード例 #6
0
        protected void lbuTab1Save_Click(object sender, EventArgs e)
        {
            if (ddlTitle.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกคำนำหน้า</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbNameTH.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกชื่อ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbLastNameTH.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกนามสกุล</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlGender.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกเพศ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbBirthday.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกวันเกิด</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbEmail.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกอีเมล</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            PS_PERSON P0 = new PS_PERSON();
            P0.PS_CITIZEN_ID = p;
            P0.PS_RANK_ID = Convert.ToInt32(ddlRank.SelectedValue);
            P0.PS_TITLE_ID = Convert.ToInt32(ddlTitle.SelectedValue);
            P0.PS_FN_TH = tbNameTH.Text;
            P0.PS_LN_TH = tbLastNameTH.Text;
            P0.PS_FN_EN = tbNameEN.Text;
            P0.PS_LN_EN = tbLastNameEN.Text;
            P0.PS_GENDER_ID = Convert.ToInt32(ddlGender.SelectedValue);
            P0.PS_BIRTHDAY_DATE = Util.ODT(tbBirthday.Text);
            P0.PS_BIRTHDAY_LONG = Util.ToThaiWordBirthday(tbBirthday.Text);
            P0.PS_EMAIL = tbEmail.Text;
            P0.PS_PHONE = tbPhone.Text;
            P0.PS_TELEPHONE_WORK = tbTelephone.Text;
            P0.PS_RACE_ID = Convert.ToInt32(ddlRace.SelectedValue);
            P0.PS_NATION_ID = ddlNation.SelectedValue;
            P0.PS_BLOOD_ID = Convert.ToInt32(ddlBlood.SelectedValue);
            P0.PS_RELIGION_ID = Convert.ToInt32(ddlReligion.SelectedValue);
            P0.PS_STATUS_ID = Convert.ToInt32(ddlStatus.SelectedValue);
            P0.PS_DAD_FN = tbFatherName.Text;
            P0.PS_DAD_LN = tbFatherLastName.Text;
            P0.PS_MOM_FN = tbMotherName.Text;
            P0.PS_MOM_LN = tbMotherLastName.Text;
            P0.PS_MOM_LN_OLD = tbMotherOldLastName.Text;
            P0.PS_LOV_FN = tbCoupleName.Text;
            P0.PS_LOV_LN = tbCoupleLastName.Text;
            P0.PS_LOV_LN_OLD = tbCoupleOldLastName.Text;
            P0.PS_RETIRE_DATE = Util.ODT(Util.BirthdayToRetireDate(tbBirthday.Text));
            P0.PS_RETIRE_LONG = Util.ToThaiWordRetire(tbBirthday.Text);

            P0.UPDATE_PS_PERSON_TAB1();
            notification.Attributes["class"] = "alert alert_success";
            notification.InnerHtml = "";
            notification.InnerHtml += "<div><img src='Image/Small/correct.png' /><strong>บันทึกข้อมูลพื้นฐานสำเร็จ</strong></div>";
        }
コード例 #7
0
ファイル: Util.cs プロジェクト: OAT-TUU-TANG-FIRST/RMUTTO
        public static void SendMail(PS_PERSON ps)
        {
            var fromAddress = new MailAddress("*****@*****.**", "From Name");
            var toAddress = new MailAddress(ps.PS_EMAIL, "To Name");
            string fromPassword = "******";
            string subject = "Your registered successful for this site personnel.rmutto.ac.th";
            string body =
                "<div>ชื่อผู้ใช้ : " + ps.PS_CITIZEN_ID + "</div>" +
                "<div>รหัสผ่าน : " + ps.PS_PASSWORD + "</div>" +
                "<div style='border-bottom: 1px solid #c0c0c0' margin: 10px 0;></div>" +
                "<div><a href='http://localhost:65308/Access.aspx?ID=" + ps.PS_CITIZEN_ID + "&Password="******"&Action=1'>เปลี่ยนรหัสผ่านได้ที่นี่</a></div>";

            var smtp = new SmtpClient {
                Host = "smtp.live.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
            };
            MailMessage ms = new MailMessage(fromAddress, toAddress);
            ms.IsBodyHtml = true;
            ms.Subject = subject;
            ms.Body = body;
            smtp.Send(ms);

            /*using (var message = new MailMessage(fromAddress, toAddress) {
                message.IsBodyHtml = true,
                Subject = subject,
                Body = body
            }) {
                smtp.Send(message);
            }*/
        }
コード例 #8
0
        protected void lbSubmit_Click(object sender, EventArgs e)
        {
            if (tbCitizenID.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกบัตรประชาชน</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlTitle.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกคำนำหน้า</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbNameTH.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกชื่อ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbLastNameTH.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกนามสกุล</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlGender.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกเพศ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbBirthday.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกวันเกิด</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbEmail.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกอีเมล</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlCampus.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกวิทยาเขต</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlFaculty.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกสำนัก / สถาบัน / คณะ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (ddlDivision.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกกอง / สำนักงานเลขา / ภาควิชา</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING))
            {
                con.Open();
                using (OracleCommand com = new OracleCommand("SELECT COUNT(*) FROM TB_WORK_DIVISION WHERE DIVISION_ID = " + ddlDivision.SelectedValue, con))
                {
                    using (OracleDataReader reader = com.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            if (reader.GetInt32(0) != 0 && ddlWorkDivision.SelectedIndex == 0)
                            {
                                notification.Attributes["class"] = "alert alert_danger";
                                notification.InnerHtml = "";
                                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                                notification.InnerHtml += "<div>กรุณาเลือกงาน / ฝ่าย</div>";
                                return;
                            }
                            else
                            {
                                notification.Attributes["class"] = "none";
                                notification.InnerHtml = "";
                            }
                        }
                    }
                }
            }

            if (ddlStaffType.SelectedIndex == 0)
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณาเลือกประเภทบุคลากร</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }
            if (tbDateInwork.Text == "")
            {
                notification.Attributes["class"] = "alert alert_danger";
                notification.InnerHtml = "";
                notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>กรุณากรอกข้อมูลให้ครบถ้วน</strong></div>";
                notification.InnerHtml += "<div>กรุณากรอกวันที่บรรจุ</div>";
                return;
            }
            else
            {
                notification.Attributes["class"] = "none";
                notification.InnerHtml = "";
            }

            if (ddlWorkDivision.SelectedIndex == 0)
            {
                PS_PERSON P0 = new PS_PERSON();
                P0.PS_MINISTRY_ID = 1;
                P0.PS_GROM = "มหาวิทยาลัยเทคโนโลยีราชมงคลตะวันออก";
                P0.PS_CITIZEN_ID = tbCitizenID.Text;
                P0.PS_TITLE_ID = Convert.ToInt32(ddlTitle.SelectedValue);
                P0.PS_FN_TH = tbNameTH.Text;
                P0.PS_LN_TH = tbLastNameTH.Text;
                P0.PS_FN_EN = tbNameEN.Text;
                P0.PS_LN_EN = tbLastNameEN.Text;
                P0.PS_GENDER_ID = Convert.ToInt32(ddlGender.SelectedValue);
                P0.PS_BIRTHDAY_DATE = Util.ODT(tbBirthday.Text);
                P0.PS_BIRTHDAY_LONG = Util.ToThaiWordBirthday(tbBirthday.Text);
                P0.PS_EMAIL = tbEmail.Text;
                P0.PS_PHONE = tbPhone.Text;
                P0.PS_TELEPHONE_WORK = tbTelephone.Text;
                P0.PS_RACE_ID = Convert.ToInt32(ddlRace.SelectedValue);
                P0.PS_NATION_ID = ddlNation.SelectedValue;
                P0.PS_BLOOD_ID = Convert.ToInt32(ddlBlood.SelectedValue);
                P0.PS_RELIGION_ID = Convert.ToInt32(ddlReligion.SelectedValue);
                P0.PS_STATUS_ID = Convert.ToInt32(ddlStatus.SelectedValue);
                P0.PS_SW_ID = 6;
                P0.PS_CAMPUS_ID = Convert.ToInt32(ddlCampus.SelectedValue);
                P0.PS_FACULTY_ID = Convert.ToInt32(ddlFaculty.SelectedValue);
                P0.PS_DIVISION_ID = Convert.ToInt32(ddlDivision.SelectedValue);
                P0.PS_STAFFTYPE_ID = Convert.ToInt32(ddlStaffType.SelectedValue);
                P0.PS_INWORK_DATE = Util.ODT(tbDateInwork.Text);
                P0.PS_PASSWORD = Util.RandomPassword(8);
                P0.PS_POSI_ADMIN = 1;
                P0.PS_POSI_DIRECT = 3;
                P0.PS_POSI_ACAD = 5;
                P0.PS_POSI_GENERAL = 10;
                P0.PS_POSI_EMP_GROUP = 14;

                if (P0.CheckUseCitizenID())
                {
                    P0.INSERT_PS_PERSON_DV();
                    Util.SendMail(P0);
                    ClearText();
                    MultiView1.ActiveViewIndex = 1;
                }
                else
                {
                    notification.Attributes["class"] = "alert alert_danger";
                    notification.InnerHtml = "";
                    notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
                    notification.InnerHtml += "<div>มีรหัสบัตรประชาชนที่กรอกแล้วในฐานข้อมูล</div>";
                }
            }
            else
            {
                PS_PERSON P0 = new PS_PERSON();
                P0.PS_MINISTRY_ID = 1;
                P0.PS_GROM = "มหาวิทยาลัยเทคโนโลยีราชมงคลตะวันออก";
                P0.PS_CITIZEN_ID = tbCitizenID.Text;
                P0.PS_TITLE_ID = Convert.ToInt32(ddlTitle.SelectedValue);
                P0.PS_FN_TH = tbNameTH.Text;
                P0.PS_LN_TH = tbLastNameTH.Text;
                P0.PS_FN_EN = tbNameEN.Text;
                P0.PS_LN_EN = tbLastNameEN.Text;
                P0.PS_GENDER_ID = Convert.ToInt32(ddlGender.SelectedValue);
                P0.PS_BIRTHDAY_DATE = Util.ODT(tbBirthday.Text);
                P0.PS_BIRTHDAY_LONG = Util.ToThaiWordBirthday(tbBirthday.Text);
                P0.PS_EMAIL = tbEmail.Text;
                P0.PS_PHONE = tbPhone.Text;
                P0.PS_TELEPHONE_WORK = tbTelephone.Text;
                P0.PS_RACE_ID = Convert.ToInt32(ddlRace.SelectedValue);
                P0.PS_NATION_ID = ddlNation.SelectedValue;
                P0.PS_BLOOD_ID = Convert.ToInt32(ddlBlood.SelectedValue);
                P0.PS_RELIGION_ID = Convert.ToInt32(ddlReligion.SelectedValue);
                P0.PS_STATUS_ID = Convert.ToInt32(ddlStatus.SelectedValue);
                P0.PS_SW_ID = 6;
                P0.PS_CAMPUS_ID = Convert.ToInt32(ddlCampus.SelectedValue);
                P0.PS_FACULTY_ID = Convert.ToInt32(ddlFaculty.SelectedValue);
                P0.PS_DIVISION_ID = Convert.ToInt32(ddlDivision.SelectedValue);
                P0.PS_WORK_DIVISION_ID = Convert.ToInt32(ddlWorkDivision.SelectedValue);
                P0.PS_STAFFTYPE_ID = Convert.ToInt32(ddlStaffType.SelectedValue);
                P0.PS_INWORK_DATE = Util.ODT(tbDateInwork.Text);
                P0.PS_PASSWORD = Util.RandomPassword(8);
                P0.PS_POSI_ADMIN = 1;
                P0.PS_POSI_DIRECT = 3;
                P0.PS_POSI_ACAD = 5;
                P0.PS_POSI_GENERAL = 10;
                P0.PS_POSI_EMP_GROUP = 14;

                if (P0.CheckUseCitizenID())
                {
                    P0.INSERT_PS_PERSON_WD();
                    Util.SendMail(P0);
                    ClearText();
                    MultiView1.ActiveViewIndex = 1;
                }
                else
                {
                    notification.Attributes["class"] = "alert alert_danger";
                    notification.InnerHtml = "";
                    notification.InnerHtml += "<div><img src='Image/Small/red_alert.png' /><strong>แจ้งเตือน</strong></div>";
                    notification.InnerHtml += "<div>มีรหัสบัตรประชาชนที่กรอกแล้วในฐานข้อมูล</div>";
                }
            }
        }