Exemplo n.º 1
0
        public view_Budget_transfer_head GET(string strCriteria)
        {
            view_Budget_transfer_head result = null;
            var     strMessage = string.Empty;
            DataSet ds         = null;

            if (SP_BUDGET_TRANSFER_HEAD_SEL(strCriteria, ref ds, ref strMessage))
            {
                result = Helper.ToClassInstanceCollection <view_Budget_transfer_head>(ds.Tables[0]).FirstOrDefault();
            }
            return(result);
        }
        private void SetBudgetTransferData()
        {
            cBudget_transfer oBudget_transfer = new cBudget_transfer();
            string           strMessage = string.Empty, strCriteria = string.Empty;

            try
            {
                strCriteria = " and budget_transfer_doc = '" + this.BudgetTransferDoc + "' ";
                this.MyBudgetTransferHead = oBudget_transfer.GET(strCriteria);
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
        private void setData()
        {
            view_Budget_transfer_head budget_transfer_head = null;
            cBudget_transfer          oBudget_transfer     = new cBudget_transfer();

            try
            {
                _strCriteria         = " and budget_transfer_doc = '" + ViewState["budget_transfer_doc"].ToString() + "' ";
                budget_transfer_head = oBudget_transfer.GET(_strCriteria);
                if (budget_transfer_head != null)
                {
                    #region set Control
                    TabContainer1.Tabs[1].Visible = true;
                    //Tab 1
                    txtUpdatedBy.Text            = budget_transfer_head.c_updated_by;
                    txtUpdatedDate.Text          = budget_transfer_head.d_updated_date.ToString();
                    txtbudget_transfer_doc.Text  = budget_transfer_head.budget_transfer_doc;
                    txtbudget_transfer_date.Text = budget_transfer_head.budget_transfer_date.Value.ToString("dd/MM/yyyy");
                    txtbudget_doc_no.Text        = budget_transfer_head.budget_doc_no;

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

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

                    InitcboDegree_from();
                    if (cboDegree_from.Items.FindByValue(budget_transfer_head.degree_code_from) != null)
                    {
                        cboDegree_from.SelectedIndex = -1;
                        cboDegree_from.Items.FindByValue(budget_transfer_head.degree_code_from).Selected = true;
                    }

                    InitcboMajor_from();
                    if (cboMajor_from.Items.FindByValue(budget_transfer_head.major_code_from) != null)
                    {
                        cboMajor_from.SelectedIndex = -1;
                        cboMajor_from.Items.FindByValue(budget_transfer_head.major_code_from).Selected = true;
                    }

                    txtbudget_plan_code_from.Text = budget_transfer_head.budget_plan_code_from;
                    txtbudget_name_from.Text      = budget_transfer_head.budget_name_from;
                    txtproduce_name_from.Text     = budget_transfer_head.produce_name_from;
                    txtactivity_name_from.Text    = budget_transfer_head.activity_name_from;
                    txtplan_name_from.Text        = budget_transfer_head.plan_name_from;
                    txtwork_name_from.Text        = budget_transfer_head.work_name_from;
                    txtfund_name_from.Text        = budget_transfer_head.fund_name_from;
                    txtunit_name_from.Text        = budget_transfer_head.unit_name_from;

                    InitcboDegree_to();
                    if (cboDegree_to.Items.FindByValue(budget_transfer_head.degree_code_to) != null)
                    {
                        cboDegree_to.SelectedIndex = -1;
                        cboDegree_to.Items.FindByValue(budget_transfer_head.degree_code_to).Selected = true;
                    }

                    InitcboMajor_to();
                    if (cboMajor_to.Items.FindByValue(budget_transfer_head.major_code_to) != null)
                    {
                        cboMajor_to.SelectedIndex = -1;
                        cboMajor_to.Items.FindByValue(budget_transfer_head.major_code_to).Selected = true;
                    }

                    txtbudget_plan_code_to.Text = budget_transfer_head.budget_plan_code_to;
                    txtbudget_name_to.Text      = budget_transfer_head.budget_name_to;
                    txtproduce_name_to.Text     = budget_transfer_head.produce_name_to;
                    txtactivity_name_to.Text    = budget_transfer_head.activity_name_to;
                    txtplan_name_to.Text        = budget_transfer_head.plan_name_to;
                    txtwork_name_to.Text        = budget_transfer_head.work_name_to;
                    txtfund_name_to.Text        = budget_transfer_head.fund_name_to;
                    txtunit_name_to.Text        = budget_transfer_head.unit_name_to;

                    txtbudget_transfer_remark.Text = budget_transfer_head.budget_transfer_remark;
                    BindGridDetail();

                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
        private void BindGridView(int nPageNo)
        {
            var oBudget_transfer = new cBudget_transfer();
            DataSet ds = new DataSet();
            string strMessage = string.Empty;
            string strCriteria = string.Empty;
            var budget_transfer_head = new view_Budget_transfer_head();
            string strScript = string.Empty;
            #region Criteria
            budget_transfer_head.budget_transfer_year = cboYear.SelectedValue;
            budget_transfer_head.budget_transfer_doc = txtbudget_plan_code_from.Text.Replace("'", "''").Trim();

            budget_transfer_head.degree_code_from = cboDegree_from.SelectedValue;
            budget_transfer_head.budget_plan_code_from = txtbudget_plan_code_from.Text;
            budget_transfer_head.unit_code_from = cboUnit_from.SelectedValue;
            budget_transfer_head.budget_code_from = cboBudget_from.SelectedValue;
            budget_transfer_head.produce_code_from = cboProduce_from.SelectedValue;
            budget_transfer_head.activity_code_from = cboActivity_from.SelectedValue;
            budget_transfer_head.major_code_from = cboMajor_from.SelectedValue;

            budget_transfer_head.degree_code_to = cboDegree_to.SelectedValue;
            budget_transfer_head.budget_plan_code_to = txtbudget_plan_code_to.Text;
            budget_transfer_head.unit_code_to = cboUnit_to.SelectedValue;
            budget_transfer_head.budget_code_to = cboBudget_to.SelectedValue;
            budget_transfer_head.produce_code_to = cboProduce_to.SelectedValue;
            budget_transfer_head.activity_code_to = cboActivity_to.SelectedValue;
            budget_transfer_head.major_code_to = cboMajor_to.SelectedValue;


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            #endregion

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

            try
            {
                if (!oBudget_transfer.SP_BUDGET_TRANSFER_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_transfer.Dispose();
                ds.Dispose();
                if (GridView1.Rows.Count > 0)
                {
                    GridView1.TopPagerRow.Visible = true;
                }
            }
        }