예제 #1
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string  strMessage     = string.Empty;
            string  strCheck       = string.Empty;
            string  strScript      = string.Empty;
            string  strUpdatedBy   = Session["username"].ToString();
            Label   lblperson_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblperson_code");
            cPerson oPerson        = new cPerson();

            try
            {
                if (!oPerson.SP_PERSON_DEL(lblperson_code.Text, "N", strUpdatedBy, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oPerson.Dispose();
            }
            BindGridView(0);
        }
예제 #2
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string  strMessage     = string.Empty;
            string  strCheck       = string.Empty;
            string  strScript      = string.Empty;
            string  strUpdatedBy   = Session["username"].ToString();
            Label   lblperson_code = (Label)GridView1.Rows[e.RowIndex].FindControl("lblperson_code");
            cPerson oPerson        = new cPerson();

            try
            {
                if (!oPerson.SP_PERSON_DEL(lblperson_code.Text, "N", strUpdatedBy, ref strMessage))
                {
                    if (strMessage.Contains("REFERENCE constraint"))
                    {
                        MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                    }
                    else
                    {
                        lblError.Text = strMessage;
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("REFERENCE constraint"))
                {
                    MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oPerson.Dispose();
            }
            BindGridView(0);
        }
예제 #3
0
        private void BindGridView(int nPageNo)
        {
            cPerson oPerson                    = new cPerson();
            DataSet ds                         = new DataSet();
            string  strMessage                 = string.Empty;
            string  strCriteria                = string.Empty;
            string  strperson_group_code       = string.Empty;
            string  strdirector_code           = string.Empty;
            string  strunit_code               = string.Empty;
            string  strperson_code             = string.Empty;
            string  strperson_name             = string.Empty;
            string  strperson_work_status_code = string.Empty;
            string  struser_group_code         = string.Empty;
            string  struser_group_list         = string.Empty;

            strperson_group_code       = cboPerson_group.SelectedValue;
            strdirector_code           = cboDirector.SelectedValue;
            strunit_code               = cboUnit.SelectedValue;
            strperson_work_status_code = cboPerson_work_status.SelectedValue;
            strperson_code             = txtperson_code.Text.Replace("'", "''").Trim();
            strperson_name             = txtperson_name.Text.Replace("'", "''").Trim();
            struser_group_list         = cboUserGroup.SelectedValue;

            var strperson_id = txtperson_id.Text.Replace("'", "''").Trim();

            if (!strperson_id.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_id like '%" + strperson_id + "%') ";
            }

            if (Request.Form[strPrefixCtr + "cboPerson_work_status"] != null)
            {
                strperson_work_status_code = Request.Form[strPrefixCtr + "cboPerson_work_status"].ToString();
            }
            if (!strperson_group_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_group_code like '%" + strperson_group_code + "%') ";
            }

            if (!strdirector_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (director_code = '" + strdirector_code + "') ";
            }

            if (!strunit_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (unit_code= '" + strunit_code + "') ";
            }

            if (!strperson_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_code= '" + strperson_code + "') ";
            }

            if (!strperson_name.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_thai_name like '%" + strperson_name + "%'  " +
                              "  OR person_thai_surname like '%" + strperson_name + "%'  " +
                              "  OR person_eng_name like '%" + strperson_name + "%'  " +
                              "  OR person_eng_surname like '%" + strperson_name + "%')";
            }

            if (!strperson_work_status_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_work_status_code= '" + strperson_work_status_code + "') ";
            }

            if (RadioActive.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='Y') ";
            }
            else if (RadioCancel.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='N') ";
            }
            if (!struser_group_list.Equals(""))
            {
                if (struser_group_list == "User")
                {
                    strCriteria = strCriteria + "  And  (user_group_list is null or user_group_list  = '') ";
                }
                else
                {
                    strCriteria = strCriteria + "  And  (user_group_list  Like '%" + struser_group_list + "%') ";
                }
            }

            try
            {
                if (!oPerson.SP_PERSON_LIST_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    try
                    {
                        GridView1.PageIndex           = nPageNo;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                    catch
                    {
                        GridView1.PageIndex           = 0;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oPerson.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }
예제 #4
0
        private void BindGridView()
        {
            InitcboWork_status();
            InitcboPerson_group();

            cPerson oPerson               = new cPerson();
            DataSet ds                    = new DataSet();
            string  strMessage            = string.Empty;
            string  strCriteria           = string.Empty;
            string  strYear               = string.Empty;
            string  strActive             = string.Empty;
            string  strperson_group_code  = string.Empty;
            string  strperson_group_name  = string.Empty;
            string  strunit_code          = string.Empty;
            string  strdirector_code      = string.Empty;
            string  strperson_code        = string.Empty;
            string  strperson_name        = string.Empty;
            string  strperson_manage_name = string.Empty;

            string strperson_work_status_code = string.Empty;

            strperson_group_code       = cboPerson_group.Text;
            strdirector_code           = cboDirector.SelectedValue;
            strunit_code               = cboUnit.SelectedValue;
            strperson_code             = txtperson_code.Text.Replace("'", "''").Trim();
            strperson_name             = txtperson_name.Text.Replace("'", "''").Trim();
            strperson_manage_name      = txtperson_manage_name.Text.Replace("'", "''").Trim();
            strperson_work_status_code = cboPerson_work_status.SelectedValue;

            if (!strYear.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_plan_year = '" + strYear + "') ";
            }

            if (!strperson_group_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_group_code like '%" + strperson_group_code + "%') ";
            }

            if (!strdirector_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (director_code = '" + strdirector_code + "') ";
            }

            if (!strunit_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (unit_code= '" + strunit_code + "') ";
            }

            if (!strperson_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_code= '" + strperson_code + "') ";
            }

            if (!strperson_manage_name.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_manage_name like '%" + strperson_manage_name + "%') ";
            }


            if (!strperson_name.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_thai_name like '%" + strperson_name + "%'  " +
                              "  OR person_thai_surname like '%" + strperson_name + "%'  " +
                              "  OR person_eng_name like '%" + strperson_name + "%'  " +
                              "  OR person_eng_surname like '%" + strperson_name + "%'" +
                              "  OR '" + strperson_name + "' like ('%'+person_thai_name+'%'+person_thai_surname+'%')) ";
            }

            if (!strperson_work_status_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_work_status_code= '" + strperson_work_status_code + "') ";
            }

            if (RadioActive.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='Y') ";
            }
            else if (RadioCancel.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='N') ";
            }

            //strCriteria += " and person_group_code IN (" + PersonGroupList + ") ";
            //if (DirectorLock == "Y")
            //{
            //    strCriteria += " and substring(director_code,4,2) = substring('" + DirectorCode + "',4,2) ";
            //}


            try
            {
                if (!oPerson.SP_PERSON_LIST_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        string strScript = string.Empty;
                        strperson_code = ds.Tables[0].Rows[0]["person_code"].ToString();
                        strperson_name = ds.Tables[0].Rows[0]["person_thai_name"].ToString() + " " + ds.Tables[0].Rows[0]["person_thai_surname"].ToString();

                        if (!ViewState["show"].ToString().Equals("1"))
                        {
                            strScript = "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl1"].ToString() + "').value='" + strperson_code + "';\n " +
                                        "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["ctrl2"].ToString() + "').value='" + strperson_name + "';\n" +
                                        "ClosePopUp('" + ViewState["show"].ToString() + "');";
                        }
                        else
                        {
                            strScript = "window.parent.document.getElementById('" + ViewState["ctrl1"].ToString() + "').value='" + strperson_code + "';\n " +
                                        "window.parent.document.getElementById('" + ViewState["ctrl2"].ToString() + "').value='" + strperson_name + "';\n" +
                                        "ClosePopUp('" + ViewState["show"].ToString() + "');";
                        }
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "close", strScript, true);
                    }
                    else
                    {
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oPerson.Dispose();
                ds.Dispose();
            }
        }
예제 #5
0
        private void BindGridView(int nPageNo)
        {
            InitcboYear();
            InitcboWork_status();
            InitcboPerson_group();
            //InitcboDirector();
            // InitcboUnit();
            cPerson oPerson                    = new cPerson();
            DataSet ds                         = new DataSet();
            string  strMessage                 = string.Empty;
            string  strCriteria                = string.Empty;
            string  strYear                    = string.Empty;
            string  strActive                  = string.Empty;
            string  strperson_group_code       = string.Empty;
            string  strperson_group_name       = string.Empty;
            string  strdirector_code           = string.Empty;
            string  strunit_code               = string.Empty;
            string  strperson_code             = string.Empty;
            string  strperson_name             = string.Empty;
            string  strperson_work_status_code = string.Empty;

            strperson_group_code       = cboPerson_group.SelectedValue;
            strdirector_code           = cboDirector.SelectedValue;
            strunit_code               = cboUnit.SelectedValue;
            strperson_work_status_code = cboPerson_work_status.SelectedValue;
            strYear        = cboYear.SelectedValue;
            strperson_code = txtperson_code.Text.Replace("'", "''").Trim();
            strperson_name = txtperson_name.Text.Replace("'", "''").Trim();
            if (Request.Form[strPrefixCtr + "cboPerson_work_status"] != null)
            {
                strperson_work_status_code = Request.Form[strPrefixCtr + "cboPerson_work_status"].ToString();
            }

            //if (!strYear.Equals(""))
            //{
            //    strCriteria = strCriteria + "  And  (budget_plan_year = '" + strYear + "') ";
            //}

            if (!strperson_group_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_group_code like '%" + strperson_group_code + "%') ";
            }

            if (!strdirector_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (director_code = '" + strdirector_code + "') ";
            }

            if (!strunit_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (unit_code= '" + strunit_code + "') ";
            }

            if (!strperson_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_code= '" + strperson_code + "') ";
            }

            if (!strperson_name.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_thai_name like '%" + strperson_name + "%'  " +
                              "  OR person_thai_surname like '%" + strperson_name + "%'  " +
                              "  OR person_eng_name like '%" + strperson_name + "%'  " +
                              "  OR person_eng_surname like '%" + strperson_name + "%')";
            }

            if (!strperson_work_status_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_work_status_code= '" + strperson_work_status_code + "') ";
            }

            if (RadioActive.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='Y') ";
            }
            else if (RadioCancel.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='N') ";
            }
            strCriteria += " and person_group_code IN (" + PersonGroupList + ",'') ";
            if (DirectorLock == "Y")
            {
                strCriteria += " and substring(director_code,4,2) = substring('" + DirectorCode + "',4,2) ";
            }
            try
            {
                if (!oPerson.SP_PERSON_LIST_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    try
                    {
                        GridView1.PageIndex           = nPageNo;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                    catch
                    {
                        GridView1.PageIndex           = 0;
                        txthTotalRecord.Value         = ds.Tables[0].Rows.Count.ToString();
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridView1.DataSource          = ds.Tables[0];
                        GridView1.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oPerson.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }
예제 #6
0
        private void BindGridView()
        {
            InitcboWork_status();
            InitcboPerson_group();

            cPerson oPerson                    = new cPerson();
            DataSet ds                         = new DataSet();
            string  strMessage                 = string.Empty;
            string  strCriteria                = string.Empty;
            string  strYear                    = string.Empty;
            string  strActive                  = string.Empty;
            string  strperson_group_code       = string.Empty;
            string  strperson_group_name       = string.Empty;
            string  strmajor_code              = string.Empty;
            string  strperson_code             = string.Empty;
            string  strperson_name             = string.Empty;
            string  strperson_work_status_code = string.Empty;

            strperson_group_code       = cboPerson_group.Text;
            strmajor_code              = cboMajor.SelectedValue;
            strperson_code             = txtperson_code.Text.Replace("'", "''").Trim();
            strperson_name             = txtperson_name.Text.Replace("'", "''").Trim();
            strperson_work_status_code = cboPerson_work_status.SelectedValue;

            if (!strYear.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_plan_year = '" + strYear + "') ";
            }

            if (!strperson_group_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_group_code like '%" + strperson_group_code + "%') ";
            }


            if (!strmajor_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (major_code= '" + strmajor_code + "') ";
            }

            if (!strperson_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_code= '" + strperson_code + "') ";
            }

            if (!strperson_name.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_thai_name like '%" + strperson_name + "%'  " +
                              "  OR person_thai_surname like '%" + strperson_name + "%'  " +
                              "  OR (person_thai_surname + ' ' +person_eng_surname) like '%" + strperson_name + "%')";
            }

            if (!strperson_work_status_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (person_work_status_code= '" + strperson_work_status_code + "') ";
            }

            if (RadioActive.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='Y') ";
            }
            else if (RadioCancel.Checked)
            {
                strCriteria = strCriteria + "  And  (c_active ='N') ";
            }

            strCriteria += " and person_group_code IN (" + PersonGroupList + ") ";


            if (DirectorLock == "Y")
            {
                strCriteria += " and substring(director_code,4,2) = substring('" + DirectorCode + "',4,2) ";
            }



            try
            {
                if (!oPerson.SP_PERSON_LIST_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                    GridView1.DataSource          = ds.Tables[0];
                    GridView1.DataBind();
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oPerson.Dispose();
                ds.Dispose();
            }
        }