Beispiel #1
0
        public view_Budget_open_head GET(string strCriteria)
        {
            view_Budget_open_head result = null;
            var     strMessage           = string.Empty;
            DataSet ds = null;

            if (SP_BUDGET_OPEN_HEAD_SEL(strCriteria, ref ds, ref strMessage))
            {
                result = Helper.ToClassInstanceCollection <view_Budget_open_head>(ds.Tables[0]).FirstOrDefault();
            }
            return(result);
        }
        private void BindGridView(int nPageNo)
        {
            var     oBudget_open     = new cBudget_open();
            DataSet ds               = new DataSet();
            string  strMessage       = string.Empty;
            string  strCriteria      = string.Empty;
            var     budget_open_head = new view_Budget_open_head();
            string  strScript        = string.Empty;

            #region Criteria
            budget_open_head.budget_open_year    = cboYear.SelectedValue;
            budget_open_head.degree_code         = cboDegree.SelectedValue;
            budget_open_head.budget_open_doc     = txtbudget_plan_code.Text.Replace("'", "''").Trim();
            budget_open_head.open_code           = string.IsNullOrEmpty(txtopen_code.Text) ? 0 : int.Parse(txtopen_code.Text);
            budget_open_head.open_title          = txtopen_title.Text;
            budget_open_head.budget_plan_code    = txtbudget_plan_code.Text;
            budget_open_head.unit_code           = cboUnit.SelectedValue;
            budget_open_head.budget_code         = cboBudget.SelectedValue;
            budget_open_head.produce_code        = cboProduce.SelectedValue;
            budget_open_head.activity_code       = cboActivity.SelectedValue;
            budget_open_head.major_code          = cboMajor.SelectedValue;
            budget_open_head.approve_head_status = cboApproveStatus.SelectedValue;

            budget_open_head.budget_open_no        = txtbudget_open_no.Text.Trim();
            budget_open_head.budget_open_ap        = txtbudget_open_ap.Text.Trim();
            budget_open_head.budget_open_pr        = txtbudget_open_pr.Text.Trim();
            budget_open_head.budget_open_budget_no = txtbudget_open_budget_no.Text.Trim();


            if (!string.IsNullOrEmpty(txtdate_begin.Text))
            {
                strCriteria = strCriteria + "  And  (budget_open_date >= '" + cCommon.SeekDate(txtdate_begin.Text) + "') ";
            }

            if (!string.IsNullOrEmpty(txtdate_end.Text))
            {
                strCriteria = strCriteria + "  And  (budget_open_date <= '" + cCommon.SeekDate(txtdate_end.Text) + "') ";
            }

            if (!string.IsNullOrEmpty(txtdate_actual_begin.Text))
            {
                strCriteria = strCriteria + "  And  (budget_open_date_actual >= '" + cCommon.SeekDate(txtdate_actual_begin.Text) + "') ";
            }

            if (!string.IsNullOrEmpty(txtdate_actual_end.Text))
            {
                strCriteria = strCriteria + "  And  (budget_open_date_actual <= '" + cCommon.SeekDate(txtdate_actual_end.Text) + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.budget_open_year))
            {
                strCriteria = strCriteria + "  And  (budget_open_year = '" + budget_open_head.budget_open_year + "') ";
            }
            if (!string.IsNullOrEmpty(budget_open_head.degree_code))
            {
                strCriteria = strCriteria + "  And  (degree_code ='" + budget_open_head.degree_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.budget_open_doc))
            {
                strCriteria = strCriteria + "  And  (budget_open_doc LIKE '%" + budget_open_head.budget_open_doc + "%') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.budget_open_no))
            {
                strCriteria = strCriteria + "  And  (budget_open_no LIKE '%" + budget_open_head.budget_open_no + "%') ";
            }


            if (!string.IsNullOrEmpty(budget_open_head.budget_open_ap))
            {
                strCriteria = strCriteria + "  And  (budget_open_ap LIKE '%" + budget_open_head.budget_open_ap + "%') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.budget_open_pr))
            {
                strCriteria = strCriteria + "  And  (budget_open_pr LIKE '%" + budget_open_head.budget_open_pr + "%') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.budget_open_budget_no))
            {
                strCriteria = strCriteria + "  And  (budget_open_budget_no LIKE '%" + budget_open_head.budget_open_budget_no + "%') ";
            }


            if (budget_open_head.open_code > 0)
            {
                strCriteria = strCriteria + "  And  (open_code ='" + budget_open_head.open_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.open_title))
            {
                strCriteria = strCriteria + "  And  (open_title ='" + budget_open_head.open_title + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.budget_plan_code))
            {
                strCriteria = strCriteria + "  And  (budget_plan_code ='" + budget_open_head.budget_plan_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.unit_code))
            {
                strCriteria = strCriteria + "  And  (unit_code ='" + budget_open_head.unit_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.budget_code))
            {
                strCriteria = strCriteria + "  And  (budget_code ='" + budget_open_head.budget_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.produce_code))
            {
                strCriteria = strCriteria + "  And  (produce_code ='" + budget_open_head.produce_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.activity_code))
            {
                strCriteria = strCriteria + "  And  (activity_code = '" + budget_open_head.activity_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.major_code))
            {
                strCriteria = strCriteria + "  And  (major_code = '" + budget_open_head.major_code + "') ";
            }

            if (!string.IsNullOrEmpty(budget_open_head.approve_head_status))
            {
                strCriteria = strCriteria + "  And  (approve_head_status = '" + budget_open_head.approve_head_status + "') ";
            }

            if (!string.IsNullOrEmpty(txtdescription.Text))
            {
                strCriteria = strCriteria + "  And  (budget_open_doc IN (SELECT budget_open_doc from view_Budget_open_detail where item_detail_name like '%" + txtdescription.Text.Trim() + "%') ) ";
            }

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

            if (MajorLock == "Y")
            {
                strCriteria += " and major_code = '" + PersonMajorCode + "' ";
            }

            #endregion

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

            try
            {
                if (!oBudget_open.SP_BUDGET_OPEN_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_open.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }
        private void setData()
        {
            view_Budget_open_head budget_open_head = null;
            cBudget_open          obudget_open     = new cBudget_open();

            try
            {
                _strCriteria     = " and budget_open_doc = '" + ViewState["budget_open_doc"].ToString() + "' ";
                budget_open_head = obudget_open.GET(_strCriteria);
                if (budget_open_head != null)
                {
                    #region set Control
                    TabContainer1.Tabs[1].Visible = true;
                    //Tab 1
                    txtUpdatedBy.Text        = budget_open_head.c_updated_by;
                    txtUpdatedDate.Text      = budget_open_head.d_updated_date.ToString();
                    txtbudget_open_doc.Text  = budget_open_head.budget_open_doc;
                    txtbudget_open_date.Text = budget_open_head.budget_open_date.Value.ToString("dd/MM/yyyy");
                    if (budget_open_head.budget_open_date_actual != null)
                    {
                        txtbudget_open_date_actual.Text = budget_open_head.budget_open_date_actual.Value.ToString("dd/MM/yyyy");
                    }

                    txtbudget_open_no.Text        = budget_open_head.budget_open_no;
                    txtbudget_open_ap.Text        = budget_open_head.budget_open_ap;
                    txtbudget_open_pr.Text        = budget_open_head.budget_open_pr;
                    txtbudget_open_budget_no.Text = budget_open_head.budget_open_budget_no;

                    InitcboYear();
                    if (cboYear.Items.FindByValue(budget_open_head.budget_open_year) != null)
                    {
                        cboYear.SelectedIndex = -1;
                        cboYear.Items.FindByValue(budget_open_head.budget_open_year).Selected = true;
                    }

                    InitcboDegree();
                    if (cboDegree.Items.FindByValue(budget_open_head.degree_code) != null)
                    {
                        cboDegree.SelectedIndex = -1;
                        cboDegree.Items.FindByValue(budget_open_head.degree_code).Selected = true;
                    }

                    InitcboBudgetType();
                    if (cboBudget_type.Items.FindByValue(budget_open_head.budget_type) != null)
                    {
                        cboBudget_type.SelectedIndex = -1;
                        cboBudget_type.Items.FindByValue(budget_open_head.budget_type).Selected = true;
                    }

                    txtbudget_plan_code.Text = budget_open_head.budget_plan_code;
                    txtbudget_name.Text      = budget_open_head.budget_name;
                    txtproduce_name.Text     = budget_open_head.produce_name;
                    txtactivity_name.Text    = budget_open_head.activity_name;
                    txtplan_name.Text        = budget_open_head.plan_name;
                    txtwork_name.Text        = budget_open_head.work_name;
                    txtfund_name.Text        = budget_open_head.fund_name;
                    txtdirector_name.Text    = budget_open_head.director_name;
                    txtunit_name.Text        = budget_open_head.unit_name;
                    txtopen_remark.Text      = budget_open_head.open_remark;
                    txtperson_code.Text      = budget_open_head.person_code;
                    txtperson_name.Text      = budget_open_head.person_thai_name + " " + budget_open_head.person_thai_surname;

                    txtef_open_doc.Text = budget_open_head.ef_open_doc;
                    if (budget_open_head.open_code != null)
                    {
                        txtopen_code.Text = budget_open_head.open_code.ToString();
                    }
                    txtopen_title.Text        = budget_open_head.open_title;
                    txtopen_desc.Text         = budget_open_head.open_desc;
                    txtopen_command_desc.Text = budget_open_head.open_command_desc;


                    InitcboMajor();
                    if (cboMajor.Items.FindByValue(budget_open_head.major_code) != null)
                    {
                        cboMajor.SelectedIndex = -1;
                        cboMajor.Items.FindByValue(budget_open_head.major_code).Selected = true;
                    }

                    if (cboApproveStatus.Items.FindByValue(budget_open_head.approve_head_status) != null)
                    {
                        cboApproveStatus.SelectedIndex = -1;
                        cboApproveStatus.Items.FindByValue(budget_open_head.approve_head_status).Selected = true;
                    }

                    if (MajorLock == "Y")
                    {
                        cboApproveStatus.Enabled = false;
                    }


                    BindGridDetail();

                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }