示例#1
0
        private void BindGridView(int nPageNo)
        {
            var     oBudget_money     = new cBudget_money();
            DataSet ds                = new DataSet();
            string  strMessage        = string.Empty;
            string  strCriteria       = string.Empty;
            var     budget_money_head = new view_Budget_money_head();
            string  strScript         = string.Empty;

            #region Criteria
            budget_money_head.degree_code       = cboDegree.SelectedValue;
            budget_money_head.budget_money_year = cboYear.SelectedValue;
            budget_money_head.budget_money_doc  = txtbudget_money_doc.Text.Replace("'", "''").Trim();
            budget_money_head.budget_plan_code  = txtbudget_plan_code.Text.Replace("'", "''").Trim();
            budget_money_head.budget_code       = cboBudget.SelectedValue;
            budget_money_head.produce_code      = cboProduce.SelectedValue;
            budget_money_head.director_code     = cboDirector.SelectedValue;
            budget_money_head.unit_code         = cboUnit.SelectedValue;
            budget_money_head.activity_code     = cboActivity.SelectedValue;
            budget_money_head.plan_code         = cboPlan_code.SelectedValue;

            if (!budget_money_head.budget_money_year.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_money_year = '" + budget_money_head.budget_money_year + "') ";
            }
            if (!budget_money_head.budget_money_doc.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_money_doc ='" + budget_money_head.budget_money_doc + "') ";
            }
            if (!budget_money_head.budget_plan_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_plan_code ='" + budget_money_head.budget_plan_code + "') ";
            }

            if (!budget_money_head.degree_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (degree_code ='" + budget_money_head.degree_code + "') ";
            }

            if (!budget_money_head.produce_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (produce_code ='" + budget_money_head.produce_code + "') ";
            }

            if (!budget_money_head.budget_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_code ='" + budget_money_head.budget_code + "') ";
            }

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

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

            //if (!budget_money_head.work_code.Equals(""))
            //{
            //    strCriteria = strCriteria + "  And  (work_code like '%" + budget_money_head.work_code + "%') ";
            //}


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

            #endregion

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

            strCriteria = strCriteria + " and budget_type ='" + this.BudgetType + "' ";

            try
            {
                if (!oBudget_money.SP_BUDGET_MONEY_HEAD_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
            {
                oBudget_money.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }
示例#2
0
        private void BindGridView()
        {
            cBudget_money oBudget_money       = new cBudget_money();
            DataSet       ds                  = new DataSet();
            string        strMessage          = string.Empty;
            string        strCriteria         = string.Empty;
            string        strbudget_year      = string.Empty;
            string        strbudget_money_doc = string.Empty;
            string        strbudget_plan_code = string.Empty;
            string        strbudget_code      = string.Empty;
            string        strproduce_code     = string.Empty;
            string        strunit_code        = string.Empty;
            string        strdirector_code    = string.Empty;
            string        stractivity_code    = string.Empty;
            string        strplan_code        = string.Empty;
            string        strwork_code        = string.Empty;
            string        strwork_name        = string.Empty;
            string        stractive           = string.Empty;
            string        strScript           = string.Empty;

            #region Criteria

            strbudget_year      = txtyear.Text.Replace("'", "''").Trim();
            strbudget_money_doc = txtbudget_money_doc.Text.Replace("'", "''").Trim();
            strbudget_plan_code = txtbudget_plan_code.Text.Replace("'", "''").Trim();
            strbudget_code      = cboBudget.SelectedValue;
            strproduce_code     = cboProduce.SelectedValue;
            strdirector_code    = cboDirector.SelectedValue;
            strunit_code        = cboUnit.SelectedValue;
            stractivity_code    = cboActivity.SelectedValue;
            strplan_code        = cboPlan_code.SelectedValue;
            strwork_code        = txtwork_code.Text.Replace("'", "''").Trim();
            strwork_name        = txtwork_name.Text.Replace("'", "''").Trim();

            if (!strbudget_year.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_money_year = '" + strbudget_year + "') ";
            }

            if (!strbudget_plan_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_plan_code ='" + strbudget_plan_code + "') ";
            }

            if (!strproduce_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (produce_code ='" + strproduce_code + "') ";
            }

            if (!strbudget_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (budget_code ='" + strbudget_code + "') ";
            }

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

            if (!strunit_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (unit_code ='" + strunit_code + "') ";
            }
            if (!stractivity_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (activity_code = '" + stractivity_code + "') ";
            }
            if (!strplan_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (plan_code = '" + strplan_code + "') ";
            }
            if (!strwork_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (work_code like '%" + strwork_code + "%') ";
            }
            if (!strwork_name.Equals(""))
            {
                strCriteria = strCriteria + "  And  (work_name like '%" + strwork_name + "%') ";
            }
            strCriteria = strCriteria + "  And  (c_active ='Y') ";

            if (ViewState["from_page"].ToString().Equals("budgetmoney"))
            {
                strCriteria = strCriteria + "  And  budget_type='" + this.BudgetType + "' ";
            }
            else
            {
                if (this.BudgetType != "M")
                {
                    strCriteria = strCriteria + " and budget_type ='" + this.BudgetType + "' ";
                }
            }


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


            //budget_type

            #endregion
            try
            {
                if (oBudget_money.SP_BUDGET_MONEY_HEAD_SEL(strCriteria, ref ds, ref strMessage))
                {
                    ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                    GridView1.DataSource          = ds.Tables[0];
                    GridView1.DataBind();
                }
                else
                {
                    lblError.Text = strMessage;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                //if (this.BudgetType == "R")
                //{
                //    foreach (Control c in Page.Controls)
                //    {
                //        base.SetLabel(c, "แผนงาน", "งานย่อย");
                //        base.SetLabel(c, "กิจกรรม", "งานรอง");
                //        base.SetLabel(c, "แผนงบประมาณ ", "แผนงาน");
                //        base.SetLabel(c, "ผลผลิต", "งานหลัก");
                //    }
                //}

                oBudget_money.Dispose();
                ds.Dispose();
            }
        }