private void setData()
        {
            view_Budget_money_head budget_money_head = null;
            cBudget_money          oBudget_money     = new cBudget_money();

            try
            {
                _strCriteria      = " and budget_money_doc = '" + ViewState["budget_money_doc"].ToString() + "' ";
                budget_money_head = oBudget_money.GET(_strCriteria);
                if (budget_money_head != null)
                {
                    #region set Control
                    TabContainer1.Tabs[1].Visible = true;
                    //Tab 1
                    txtUpdatedBy.Text        = budget_money_head.c_updated_by;
                    txtUpdatedDate.Text      = budget_money_head.d_updated_date.ToString();
                    chkStatus.Checked        = budget_money_head.c_active == "Y";
                    txtbudget_money_doc.Text = budget_money_head.budget_money_doc;

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

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

                    InitcboBudgetType();
                    if (cboBudget_type.Items.FindByValue(budget_money_head.budget_type) != null)
                    {
                        cboBudget_type.SelectedIndex = -1;
                        cboBudget_type.Items.FindByValue(budget_money_head.budget_type).Selected = true;
                    }
                    txtbudget_plan_code.Text = budget_money_head.budget_plan_code;
                    txtbudget_name.Text      = budget_money_head.budget_name;
                    txtproduce_name.Text     = budget_money_head.produce_name;
                    txtactivity_name.Text    = budget_money_head.activity_name;
                    txtplan_name.Text        = budget_money_head.plan_name;
                    txtwork_name.Text        = budget_money_head.work_name;
                    txtfund_name.Text        = budget_money_head.fund_name;
                    txtdirector_name.Text    = budget_money_head.director_name;
                    txtunit_name.Text        = budget_money_head.unit_name;
                    txtcomment.Text          = budget_money_head.comments;

                    BindGridViewDetail();

                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
        private bool DeleteDetail(string pbudget_money_detail_id)
        {
            var oBudget_money = new cBudget_money();

            try
            {
                return(oBudget_money.SP_BUDGET_MONEY_DETAIL_DEL(pbudget_money_detail_id));
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("REFERENCE constraint"))
                {
                    MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_money.Dispose();
            }
            return(false);
        }
Exemplo n.º 3
0
        private void InitcboMajor()
        {
            cBudget_money oMajor = new cBudget_money();
            string        strMessage = string.Empty, strCriteria = string.Empty;
            string        strYear       = cboYear.SelectedValue;
            string        strmajor_code = cboMajor.SelectedValue;
            DataSet       ds            = new DataSet();
            DataTable     dt            = new DataTable();

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

            if (oMajor.SP_BUDGET_MONEY_MAJOR_SEL(strCriteria, ref ds, ref strMessage))
            {
                dt = ds.Tables[0];
                cboMajor.Items.Clear();
                cboMajor.Items.Add(new ListItem("---- กรุณาเลือกข้อมูล ----", ""));
                int i;
                for (i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    cboMajor.Items.Add(new ListItem(dt.Rows[i]["major_name"].ToString(), dt.Rows[i]["major_code"].ToString()));
                }
                if (cboMajor.Items.FindByValue(strmajor_code) != null)
                {
                    cboMajor.SelectedIndex = -1;
                    cboMajor.Items.FindByValue(strmajor_code).Selected = true;
                }
            }
        }
Exemplo n.º 4
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         lblbudget_money_doc = (Label)GridView1.Rows[e.RowIndex].FindControl("lblbudget_money_doc");
            cBudget_money oBudget_money       = new cBudget_money();

            try
            {
                oBudget_money.SP_BUDGET_MONEY_HEAD_DEL(lblbudget_money_doc.Text);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("REFERENCE constraint"))
                {
                    MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_money.Dispose();
            }
            BindGridView(0);
        }
Exemplo n.º 5
0
        protected void lbkRefresh_Click(object sender, EventArgs e)
        {
            cBudget_money oBudget_money = new cBudget_money();
            string        strMessage = string.Empty, strCriteria = string.Empty;

            try
            {
                strCriteria = " and budget_money_doc = '" + txtbudget_money_doc.Text + "' ";
                var item = oBudget_money.GET(strCriteria);
                if (item != null)
                {
                    txtbudget_money_doc.Text = item.budget_money_doc;
                    txtbudget_plan_code.Text = item.budget_plan_code;
                    txtdirector_name.Text    = item.director_name;
                    txtunit_name.Text        = item.unit_name;
                    txtbudget_name.Text      = item.budget_name;
                    txtproduce_name.Text     = item.produce_name;
                    txtactivity_name.Text    = item.activity_name;
                    txtplan_name.Text        = item.plan_name;
                    txtwork_name.Text        = item.work_name;
                    txtfund_name.Text        = item.fund_name;
                    InitcboMajor();
                    InitcboItem_group_detail();
                }
            }
            catch (Exception ex)
            {
                //lblError.Text = ex.Message.ToString();
            }
        }
        protected void GridViewMajor_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string        strScript = string.Empty;
            HiddenField   hddbudget_money_major_id = (HiddenField)GridViewMajor.Rows[e.RowIndex].FindControl("hddbudget_money_major_id");
            cBudget_money oBudget_money            = new cBudget_money();

            try
            {
                oBudget_money.SP_BUDGET_MONEY_MAJOR_DEL(hddbudget_money_major_id.Value);
                setData();
                strScript = "window.parent.__doPostBack('ctl00$ContentPlaceHolder1$LinkButton1','');";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "OpenPage", strScript, true);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("REFERENCE constraint"))
                {
                    MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_money.Dispose();
            }
            BindGridView();
        }
        private bool saveData()
        {
            bool          blnResult     = false;
            string        strScript     = string.Empty;
            cBudget_money oBudget_money = new cBudget_money();
            DataSet       ds            = new DataSet();

            try
            {
                #region set Data
                var budget_money_detail = new Budget_money_detail()
                {
                    budget_money_doc               = ViewState["budget_money_doc"].ToString(),
                    item_detail_id                 = int.Parse(hdditem_detail_id.Value),
                    budget_money_detail_plan       = decimal.Parse(txtbudget_money_detail_plan.Value.ToString()),
                    budget_money_detail_contribute = decimal.Parse(txtbudget_money_detail_contribute.Value.ToString()),
                    budget_money_detail_use        = decimal.Parse(txtbudget_money_detail_contribute.Value.ToString()),
                    budget_money_detail_comment    = txtbudget_money_detail_comment.Text.Trim(),
                    c_created_by = Session["username"].ToString(),
                    c_updated_by = Session["username"].ToString()
                };
                #endregion
                if (ViewState["mode"].ToString().ToLower().Equals("edit"))
                {
                    if (oBudget_money.SP_BUDGET_MONEY_DETAIL_UPD(budget_money_detail))
                    {
                        saveDataDetail();
                    }
                    ;
                }
                else
                {
                    oBudget_money.SP_BUDGET_MONEY_DETAIL_INS(budget_money_detail);
                    ViewState["budget_money_detail_id"] = budget_money_detail.budget_money_detail_id;
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_money.Dispose();
            }
            return(blnResult);
        }
        private void setData()
        {
            cBudget_money oBudget_money = new cBudget_money();
            string        strMessage = string.Empty, strCriteria = string.Empty;

            try
            {
                strCriteria = " and budget_money_detail_id = '" + ViewState["budget_money_detail_id"].ToString() + "' ";
                var item = oBudget_money.GETDETAIL(strCriteria);
                if (item != null)
                {
                    #region set Control

                    InitcboLot();
                    if (cboLot.Items.FindByValue(item.lot_code) != null)
                    {
                        cboLot.SelectedIndex = -1;
                        cboLot.Items.FindByValue(item.lot_code).Selected = true;
                    }
                    InitcboItem_group();
                    if (cboItem_group.Items.FindByValue(item.item_group_code) != null)
                    {
                        cboItem_group.SelectedIndex = -1;
                        cboItem_group.Items.FindByValue(item.item_group_code).Selected = true;
                    }

                    InitcboItemGroupDetail();
                    if (cboItem_group_detail.Items.FindByValue(item.item_group_detail_id.ToString()) != null)
                    {
                        cboItem_group_detail.SelectedIndex = -1;
                        cboItem_group_detail.Items.FindByValue(item.item_group_detail_id.ToString()).Selected = true;
                    }
                    ViewState["budget_money_doc"]           = item.budget_money_doc;
                    hdditem_detail_id.Value                 = item.item_detail_id.ToString();
                    txtitem_detail_code.Text                = item.item_detail_code;
                    txtitem_detail_name.Text                = item.item_detail_name;
                    txtitem_name.Text                       = item.item_name;
                    txtbudget_money_detail_comment.Text     = item.budget_money_detail_comment;
                    txtbudget_money_detail_plan.Value       = item.budget_money_detail_plan;
                    txtbudget_money_detail_contribute.Value = item.budget_money_detail_contribute;
                    txtbudget_money_detail_transfer.Value   = item.budget_money_detail_transfer;
                    txtbudget_money_detail_use.Value        = item.budget_money_detail_use;
                    txtbudget_money_detail_remain.Value     = item.budget_money_detail_remain;
                    txtUpdatedBy.Text                       = item.c_updated_by;
                    txtUpdatedDate.Text                     = item.d_updated_date.ToString();

                    #endregion
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
        private bool saveDataDetail()
        {
            bool               blnResult                   = false;
            string             strScript                   = string.Empty;
            cBudget_money      oBudget_money               = new cBudget_money();
            HiddenField        hddbudget_money_major_id    = null;
            AwNumeric          txtbudget_money_major_plan  = null;
            AwNumeric          txtbudget_money_major_plan2 = null;
            AwNumeric          txtbudget_money_major_plan3 = null;
            Budget_money_major budget_money_major          = null;

            try
            {
                #region set Data
                //GridViewRow item = (GridViewRow)GridView1.Controls[0].Controls[0];
                for (var index = 0; index < GridViewMajor.Rows.Count; index++)
                {
                    hddbudget_money_major_id    = (HiddenField)GridViewMajor.Rows[index].FindControl("hddbudget_money_major_id");
                    txtbudget_money_major_plan  = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan");
                    txtbudget_money_major_plan2 = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan2");
                    txtbudget_money_major_plan3 = (AwNumeric)GridViewMajor.Rows[index].FindControl("txtbudget_money_major_plan3");
                    budget_money_major          = new Budget_money_major
                    {
                        budget_money_major_id    = long.Parse(hddbudget_money_major_id.Value),
                        budget_money_major_plan  = decimal.Parse(txtbudget_money_major_plan.Value.ToString()),
                        budget_money_major_plan2 = decimal.Parse(txtbudget_money_major_plan2.Value.ToString()),
                        budget_money_major_plan3 = decimal.Parse(txtbudget_money_major_plan3.Value.ToString()),
                        c_updated_by             = Session["username"].ToString()
                    };
                    oBudget_money.SP_BUDGET_MONEY_MAJOR_UPD(budget_money_major);
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_money.Dispose();
            }
            return(blnResult);
        }
Exemplo n.º 10
0
        private bool saveData()
        {
            bool blnResult = false;
            Budget_money_head budget_money_head = new Budget_money_head();
            cBudget_money     oBudget_money     = new cBudget_money();

            try
            {
                #region set Data
                budget_money_head.budget_money_doc  = txtbudget_money_doc.Text;
                budget_money_head.budget_money_year = cboYear.SelectedValue;
                budget_money_head.budget_type       = cboBudget_type.SelectedValue;
                budget_money_head.budget_plan_code  = txtbudget_plan_code.Text;
                budget_money_head.degree_code       = cboDegree.SelectedValue;
                budget_money_head.comments          = txtcomment.Text.Trim();
                budget_money_head.c_active          = chkStatus.Checked == true ? "Y" : "N";
                budget_money_head.c_created_by      = Session["username"].ToString();
                budget_money_head.c_updated_by      = Session["username"].ToString();
                #endregion
                if (ViewState["mode"].ToString().ToLower().Equals("edit"))
                {
                    oBudget_money.SP_BUDGET_MONEY_HEAD_UPD(budget_money_head);
                }
                else
                {
                    oBudget_money.SP_BUDGET_MONEY_HEAD_INS(budget_money_head);
                    ViewState["budget_money_doc"] = budget_money_head.budget_money_doc;
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_money.Dispose();
            }
            return(blnResult);
        }
        private void BindGridView()
        {
            cBudget_money oBudget_money = new cBudget_money();
            DataSet       ds            = new DataSet();
            string        strMessage    = string.Empty;
            string        strCriteria   = string.Empty;

            strCriteria = " And  (budget_money_detail_id = '" + ViewState["budget_money_detail_id"].ToString() + "') ";
            try
            {
                if (!oBudget_money.SP_BUDGET_MONEY_MAJOR_SEL(strCriteria, ref ds, ref strMessage))
                {
                    lblError.Text = strMessage;
                }
                else
                {
                    try
                    {
                        GridViewMajor.PageIndex       = 0;
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridViewMajor.DataSource      = ds.Tables[0];
                        GridViewMajor.DataBind();
                    }
                    catch
                    {
                        GridViewMajor.PageIndex       = 0;
                        ds.Tables[0].DefaultView.Sort = ViewState["sort"] + " " + ViewState["direction"];
                        GridViewMajor.DataSource      = ds.Tables[0];
                        GridViewMajor.DataBind();
                    }
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                if (GridViewMajor.Rows.Count == 0)
                {
                    EmptyGridFix(GridViewMajor);
                }
                oBudget_money.Dispose();
                ds.Dispose();
            }
        }
Exemplo n.º 12
0
        private bool saveData()
        {
            bool   blnResult    = false;
            string strUpdatedBy = string.Empty;

            strUpdatedBy = Session["username"].ToString();
            CheckBox           chkSelect;
            Label              lblmajor_code;
            var                oBudget_money      = new cBudget_money();
            Budget_money_major budget_money_major = null;

            try
            {
                foreach (GridViewRow gvRow in GridView1.Rows)
                {
                    chkSelect = (CheckBox)gvRow.FindControl("chkSelect");
                    if (chkSelect.Checked)
                    {
                        lblmajor_code      = (Label)gvRow.FindControl("lblmajor_code");
                        budget_money_major = new Budget_money_major()
                        {
                            budget_money_detail_id = long.Parse(ViewState["budget_money_detail_id"].ToString()),
                            major_code             = lblmajor_code.Text,
                            c_created_by           = strUpdatedBy
                        };
                        oBudget_money.SP_BUDGET_MONEY_MAJOR_INS(budget_money_major);
                    }
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
            finally
            {
                oBudget_money.Dispose();
            }
            return(blnResult);
        }
        private void SetBudgetMoneyMajor_to()
        {
            cBudget_money oBudget_money = new cBudget_money();
            string        strMessage = string.Empty, strCriteria = string.Empty;

            try
            {
                strCriteria = " and budget_money_year = '" + BudgetYear + "' and budget_type='" + this.BudgetType + "' " +
                              " and degree_code = '" + MyBudgetTransferHead.degree_code_to + "' " +
                              " and major_code = '" + MyBudgetTransferHead.major_code_to + "' " +
                              " and budget_plan_code = '" + MyBudgetTransferHead.budget_plan_code_to + "' " +
                              " and item_detail_id = '" + cboItem_detail_to.SelectedValue + "' ";
                var item = oBudget_money.GETMAJOR(strCriteria);
                hddbudget_money_major_id_to.Value = string.Empty;
                if (item != null)
                {
                    hddbudget_money_major_id_to.Value = item.budget_money_major_id.ToString();
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }
Exemplo n.º 14
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;
                }
            }
        }
Exemplo n.º 15
0
        private void BindGridView()
        {
            cBudget_money           oBudget_money = new cBudget_money();
            DataSet                 ds            = new DataSet();
            string                  strMessage    = string.Empty;
            string                  strCriteria   = string.Empty;
            view_Budget_money_major item          = new view_Budget_money_major();
            string                  strScript     = string.Empty;

            item.item_year = ViewState["year"].ToString();

            item.item_group_code      = cboItem_group.SelectedValue;
            item.item_group_detail_id = string.IsNullOrEmpty(cboItem_group_detail.SelectedValue) ? 0 : int.Parse(cboItem_group_detail.SelectedValue);
            item.item_code            = cboItem.SelectedValue;
            item.item_detail_code     = txtitem_detail_code.Text.Replace("'", "''").Trim();
            item.item_detail_name     = txtitem_detail_name.Text.Replace("'", "''").Trim();
            item.budget_plan_code     = ViewState["budget_plan_code"].ToString();
            item.degree_code          = ViewState["degree_code"].ToString();
            item.major_code           = ViewState["major_code"].ToString();

            if (!item.item_year.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_year = '" + item.item_year + "') ";
            }
            if (!item.item_group_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_group_code = '" + item.item_group_code + "') ";
            }
            if (item.item_group_detail_id.GetValueOrDefault() > 0)
            {
                strCriteria = strCriteria + "  And  (item_group_detail_id = '" + item.item_group_detail_id.GetValueOrDefault() + "') ";
            }
            if (!item.item_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_code = '" + item.item_code + "') ";
            }

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

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

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

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

            if (!item.major_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (major_code like '%" + item.major_code + "%') ";
            }
            strCriteria = strCriteria + "  And  budget_money_major_id not in (select budget_money_major_id from Budget_open_detail where budget_open_doc = '" + ViewState["budget_open_doc"].ToString() + "' ) ";

            try
            {
                if (oBudget_money.SP_BUDGET_MONEY_MAJOR_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
            {
                oBudget_money.Dispose();
                ds.Dispose();
            }
        }
Exemplo n.º 16
0
        private void BindGridView()
        {
            cBudget_money           oBudget_money = new cBudget_money();
            DataSet                 ds            = new DataSet();
            string                  strMessage    = string.Empty;
            string                  strCriteria   = string.Empty;
            view_Budget_money_major item          = new view_Budget_money_major();
            string                  strScript     = string.Empty;

            if (this.BudgetType == "B")
            {
                item.item_year = ((DataSet)Application["xmlconfig"]).Tables["default"].Rows[0]["yearnow"].ToString();
            }
            else
            {
                item.item_year = ((DataSet)Application["xmlconfig"]).Tables["default"].Rows[0]["yearnow2"].ToString();
            }
            item.item_group_code      = cboItem_group.SelectedValue;
            item.item_group_detail_id = string.IsNullOrEmpty(cboItem_group_detail.SelectedValue) ? 0 : int.Parse(cboItem_group_detail.SelectedValue);
            item.item_code            = cboItem.SelectedValue;
            item.item_detail_code     = txtitem_detail_code.Text.Replace("'", "''").Trim();
            item.item_detail_name     = txtitem_detail_name.Text.Replace("'", "''").Trim();
            item.budget_plan_code     = ViewState["budget_plan_code"].ToString();
            item.degree_code          = ViewState["degree_code"].ToString();
            item.major_code           = ViewState["major_code"].ToString();

            if (!item.item_year.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_year = '" + item.item_year + "') ";
            }
            if (!item.item_group_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_group_code = '" + item.item_group_code + "') ";
            }
            if (item.item_group_detail_id.GetValueOrDefault() > 0)
            {
                strCriteria = strCriteria + "  And  (item_group_detail_id = '" + item.item_group_detail_id.GetValueOrDefault() + "') ";
            }
            if (!item.item_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (item_code = '" + item.item_code + "') ";
            }

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

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

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

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

            if (!item.major_code.Equals(""))
            {
                strCriteria = strCriteria + "  And  (major_code like '%" + item.major_code + "%') ";
            }
            strCriteria = strCriteria + "  And  budget_money_major_id not in (select budget_money_major_id from Budget_open_detail where budget_open_doc = '" + ViewState["budget_open_doc"].ToString() + "' ) ";

            try
            {
                if (oBudget_money.SP_BUDGET_MONEY_MAJOR_SEL(strCriteria, ref ds, ref strMessage))
                {
                    //if (ds.Tables[0].Rows.Count == 1)
                    //{

                    //    if (!ViewState["show"].ToString().Equals("1"))
                    //    {
                    //        strScript = "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["hddbudget_money_major_id"].ToString() + "').value='" + ds.Tables[0].Rows[0]["budget_money_major_id"].ToString() + "';\n " +
                    //                    "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["txtitem_detail_code"].ToString() + "').value='" + ds.Tables[0].Rows[0]["item_detail_code"].ToString() + "';\n " +
                    //                    "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["txtitem_detail_name"].ToString() + "').value='" + ds.Tables[0].Rows[0]["item_detail_name"].ToString() + "';\n " +
                    //                    "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["txtlot_name"].ToString() + "').value='" + ds.Tables[0].Rows[0]["lot_name"].ToString() + "';\n " +
                    //                    "window.parent.frames['iframeShow" + (int.Parse(ViewState["show"].ToString()) - 1) + "'].document.getElementById('" + ViewState["txtitem_group_detail_name"].ToString() + "').value='" + ds.Tables[0].Rows[0]["item_group_detail_name"].ToString() + "';\n ";
                    //    }
                    //    else
                    //    {
                    //        strScript = "window.parent.document.getElementById('" + ViewState["hddbudget_money_major_id"].ToString() + "').value='" + ds.Tables[0].Rows[0]["budget_money_major_id"].ToString() + "';\n " +
                    //                    "window.parent.document.getElementById('" + ViewState["txtitem_detail_code"].ToString() + "').value='" + ds.Tables[0].Rows[0]["item_detail_code"].ToString() + "';\n " +
                    //                    "window.parent.document.getElementById('" + ViewState["txtitem_detail_name"].ToString() + "').value='" + ds.Tables[0].Rows[0]["item_detail_name"].ToString() + "';\n " +
                    //                    "window.parent.document.getElementById('" + ViewState["txtlot_name"].ToString() + "').value='" + ds.Tables[0].Rows[0]["lot_name"].ToString() + "';\n " +
                    //                    "window.parent.document.getElementById('" + ViewState["txtitem_group_detail_name"].ToString() + "').value='" + ds.Tables[0].Rows[0]["item_group_detail_name"].ToString() + "';\n ";
                    //    }

                    //    strScript += "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();
                    }
                }
                else
                {
                    lblError.Text = strMessage;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oBudget_money.Dispose();
                ds.Dispose();
            }
        }
Exemplo n.º 17
0
        private bool saveRecvDetail()
        {
            bool            blnResult       = false;
            cBudget_receive oBudget_receive = new cBudget_receive();
            cBudget_money   oBudget_money   = new cBudget_money();
            cCommon         oCommon         = new cCommon();
            var             ds = new DataSet();
            DataTable       dt = null;
            var             major_director_code = string.Empty;

            oCommon.SEL_SQL("select g_code from General where g_type = 'main_director_code'", ref ds, ref _strMessage);
            dt = ds.Tables[0];
            if (dt.Rows.Count > 0)
            {
                major_director_code = "M" + cboYear.SelectedValue.Substring(2, 2) + dt.Rows[0]["g_code"].ToString();
            }
            _strCriteria  = " and budget_money_doc = '" + txtbudget_money_doc.Text + "' ";
            _strCriteria += " and major_code in (select '" + major_director_code + "' union all select '" + cboMajor.SelectedValue + "') ";

            var listBudget_major = oBudget_money.GETMONEYDETAILS(_strCriteria);

            if (listBudget_major != null)
            {
                List <Budget_receive_detail> listBudget_receive_detail = new List <Budget_receive_detail>();
                try
                {
                    decimal detail_contribute = 0;
                    foreach (var row in listBudget_major)
                    {
                        if (row.major_code == major_director_code)
                        {
                            detail_contribute = decimal.Parse(txtdeduct_total_reduce_director.Value.ToString());
                        }
                        else
                        {
                            detail_contribute = decimal.Parse(txtdeduct_total_remain.Value.ToString());
                        }
                        listBudget_receive_detail.Add(new Budget_receive_detail
                        {
                            budget_receive_doc               = txtbudget_receive_doc.Text,
                            budget_money_major_id            = row.budget_money_major_id,
                            budget_receive_detail_contribute = detail_contribute,
                            c_created_by = Session["username"].ToString(),
                            c_updated_by = Session["username"].ToString()
                        });
                    }
                    DeleteRecvDetail(txtbudget_receive_doc.Text);
                    if (listBudget_receive_detail.Any())
                    {
                        foreach (var major in listBudget_receive_detail)
                        {
                            oBudget_receive.SP_BUDGET_RECEIVE_DETAIL_INS(major);
                        }
                    }
                    blnResult = true;
                }
                catch (Exception ex)
                {
                    if (ex.Message.Contains("duplicate key"))
                    {
                        MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                    }
                    else
                    {
                        lblError.Text = ex.Message.ToString();
                    }
                }
                finally
                {
                    oBudget_receive.Dispose();
                }
            }
            return(blnResult);
        }
Exemplo n.º 18
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();
            }
        }