예제 #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        lblbudget_open_doc = (Label)GridView1.Rows[e.RowIndex].FindControl("lblbudget_open_doc");
            cBudget_open oBudget_open       = new cBudget_open();

            try
            {
                oBudget_open.SP_BUDGET_OPEN_HEAD_DEL(lblbudget_open_doc.Text);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("REFERENCE constraint"))
                {
                    MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_open.Dispose();
            }
            BindGridView(0);
        }
예제 #2
0
        private void ClearBudgetPlan()
        {
            txtbudget_plan_code.Text = string.Empty;
            txtdirector_name.Text    = string.Empty;
            txtunit_name.Text        = string.Empty;
            txtbudget_name.Text      = string.Empty;
            txtproduce_name.Text     = string.Empty;
            txtactivity_name.Text    = string.Empty;
            txtplan_name.Text        = string.Empty;
            txtwork_name.Text        = string.Empty;
            txtfund_name.Text        = string.Empty;

            if (ViewState["mode"].ToString() == "edit")
            {
                cBudget_open obudget_open = new cBudget_open();
                try
                {
                    obudget_open.SP_BUDGET_OPEN_DETAIL_DEL_BY_DOC(txtbudget_open_doc.Text);
                    BindGridDetail();
                }
                catch (Exception ex)
                {
                    lblError.Text = ex.Message;
                    throw ex;
                }
                finally
                {
                    obudget_open.Dispose();
                }
            }
        }
예제 #3
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            string       strMessage = string.Empty;
            string       strScript  = string.Empty;
            HiddenField  hddbudget_open_detail_id = (HiddenField)GridView1.Rows[e.RowIndex].FindControl("hddbudget_open_detail_id");
            cBudget_open oBudget_open             = new cBudget_open();

            try
            {
                oBudget_open.SP_BUDGET_OPEN_DETAIL_DEL(hddbudget_open_detail_id.Value);
                oBudget_open.SP_BUDGET_OPEN_TOTAL_UPD(txtbudget_open_doc.Text);
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("REFERENCE constraint"))
                {
                    MsgBox("ไม่สามารถลบข้อมูลได้เนื่องจากมีการนำไปใช้ในระบบแล้ว");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_open.Dispose();
            }
            BindGridDetail();
        }
예제 #4
0
        private void BindGridDetail()
        {
            var lstBudgetDetail = new List <view_Budget_open_detail>();

            try
            {
                cBudget_open oBudget_open = new cBudget_open();
                _strMessage          = string.Empty;
                _strCriteria         = " and budget_open_doc = '" + txtbudget_open_doc.Text + "' order by item_detail_code";
                lstBudgetDetail      = oBudget_open.GETDETAILS(_strCriteria);
                GridView1.DataSource = lstBudgetDetail;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                this.bIsGridDetailEmpty = false;
                if (!lstBudgetDetail.Any())
                {
                    this.bIsGridDetailEmpty = true;
                    EmptyGridFix(GridView1);
                }
                else
                {
                    GridView1.DataBind();
                }
            }
        }
예제 #5
0
        private bool saveDataDetail()
        {
            bool               blnResult                = false;
            string             strScript                = string.Empty;
            cBudget_open       oBudget_open             = new cBudget_open();
            HiddenField        hddbudget_open_detail_id = null;
            TextBox            txtmaterial_detail       = null;
            AwNumeric          txtopen_detail_amount    = null;
            Budget_open_detail budget_open_detail       = null;

            try
            {
                for (var index = 0; index < GridView1.Rows.Count; index++)
                {
                    hddbudget_open_detail_id = (HiddenField)GridView1.Rows[index].FindControl("hddbudget_open_detail_id");
                    txtmaterial_detail       = (TextBox)GridView1.Rows[index].FindControl("txtmaterial_detail");
                    txtopen_detail_amount    = (AwNumeric)GridView1.Rows[index].FindControl("txtopen_detail_amount");
                    if (!string.IsNullOrEmpty(hddbudget_open_detail_id.Value))
                    {
                        budget_open_detail = new Budget_open_detail
                        {
                            budget_open_doc           = ViewState["budget_open_doc"].ToString(),
                            budget_open_detail_id     = long.Parse(hddbudget_open_detail_id.Value),
                            budget_open_detail_amount = decimal.Parse(txtopen_detail_amount.Value.ToString()),
                            material_detail           = txtmaterial_detail.Text,
                            c_updated_by = Session["username"].ToString()
                        };
                        oBudget_open.SP_BUDGET_OPEN_DETAIL_UPD(budget_open_detail);
                    }
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_open.Dispose();
            }
            return(blnResult);
        }
예제 #6
0
        private bool saveData()
        {
            bool   blnResult    = false;
            string strUpdatedBy = string.Empty;

            strUpdatedBy = Session["username"].ToString();
            CheckBox           chkSelect;
            HiddenField        hddbudget_money_major_id;
            var                oBudget_open       = new cBudget_open();
            Budget_open_detail budget_open_detail = null;

            try
            {
                foreach (GridViewRow gvRow in GridView1.Rows)
                {
                    chkSelect = (CheckBox)gvRow.FindControl("chkSelect");
                    var select = Request.Form[chkSelect.UniqueID];
                    if (select != null && select == "on")
                    {
                        hddbudget_money_major_id = (HiddenField)gvRow.FindControl("hddbudget_money_major_id");
                        budget_open_detail       = new Budget_open_detail()
                        {
                            budget_open_doc           = ViewState["budget_open_doc"].ToString(),
                            budget_money_major_id     = long.Parse(hddbudget_money_major_id.Value),
                            budget_open_detail_amount = 0,
                            budget_open_detail_remark = string.Empty,
                            c_created_by = strUpdatedBy
                        };
                        oBudget_open.SP_BUDGET_OPEN_DETAIL_INS(budget_open_detail);
                    }
                    blnResult = true;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
            finally
            {
                oBudget_open.Dispose();
            }
            return(blnResult);
        }
예제 #7
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType.Equals(DataControlRowType.Header))
            {
                for (int iCol = 0; iCol < e.Row.Cells.Count; iCol++)
                {
                    e.Row.Cells[iCol].Attributes.Add("class", "table_h");
                    e.Row.Cells[iCol].Wrap = false;
                }
            }
            else if (e.Row.RowType.Equals(DataControlRowType.DataRow) || e.Row.RowState.Equals(DataControlRowState.Alternate))
            {
                #region Set datagrid row color
                string strEvenColor, strOddColor, strMouseOverColor;
                strEvenColor      = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Even"].ToString();
                strOddColor       = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["Odd"].ToString();
                strMouseOverColor = ((DataSet)Application["xmlconfig"]).Tables["colorDataGridRow"].Rows[0]["MouseOver"].ToString();

                e.Row.Style.Add("valign", "top");
                e.Row.Style.Add("cursor", "hand");
                e.Row.Attributes.Add("onMouseOver", "this.style.backgroundColor='" + strMouseOverColor + "'");

                if (e.Row.RowState.Equals(DataControlRowState.Alternate))
                {
                    e.Row.Attributes.Add("bgcolor", strOddColor);
                    e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strOddColor + "'");
                }
                else
                {
                    e.Row.Attributes.Add("bgcolor", strEvenColor);
                    e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='" + strEvenColor + "'");
                }
                #endregion

                DataRowView dv = (DataRowView)(e.Row.DataItem);

                Label lblNo = (Label)e.Row.FindControl("lblNo");
                int   nNo   = (GridView1.PageSize * GridView1.PageIndex) + e.Row.RowIndex + 1;
                lblNo.Text = nNo.ToString();
                Label lblbudget_plan_code    = (Label)e.Row.FindControl("lblbudget_plan_code");
                Label lblbudget_open_name    = (Label)e.Row.FindControl("lblbudget_open_name");
                Label lblapprove_head_status = (Label)e.Row.FindControl("lblapprove_head_status");



                #region set ImageView
                ImageButton imgView = (ImageButton)e.Row.FindControl("imgView");
                //imgView.Attributes.Add("onclick", "OpenPopUp('950px','350px','94%','แสดงข้อมูลผังงบประมาณ','budget_open_view.aspx?mode=view&budget_plan_code=" +
                //                                                lblbudget_plan_code.Text + "','1');return false;");
                imgView.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgView"].Rows[0]["img"].ToString();
                imgView.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgView"].Rows[0]["title"].ToString());
                #endregion

                #region set Image Edit & Delete
                ImageButton imgEdit = (ImageButton)e.Row.FindControl("imgEdit");
                //Label lblCanEdit = (Label)e.Row.FindControl("lblCanEdit");
                //imgEdit.Attributes.Add("onclick", "OpenPopUp('900px','350px','90%','แก้ไข" + base.PageDes + "','budget_open_control.aspx?budget_type=" + this.BudgetType + "&mode=edit&budget_plan_code="
                //                                            + lblbudget_plan_code.Text + "&page=" + GridView1.PageIndex.ToString() + "&canEdit=Y','1');return false;");
                imgEdit.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgEdit"].Rows[0]["img"].ToString();
                imgEdit.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgEdit"].Rows[0]["title"].ToString());

                ImageButton imgDelete = (ImageButton)e.Row.FindControl("imgDelete");
                imgDelete.ImageUrl = ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["img"].ToString();
                imgDelete.Attributes.Add("title", ((DataSet)Application["xmlconfig"]).Tables["imgDelete"].Rows[0]["title"].ToString());
                imgDelete.Attributes.Add("onclick", "return confirm(\"คุณต้องการลบผังงบประมาณ  : " + lblbudget_plan_code.Text + " ?\");");
                #endregion


                var rptItem = (Repeater)e.Row.FindControl("rptItem");
                _strCriteria = " and budget_open_doc = '" + dv["budget_open_doc"].ToString() + "' ";
                var oBudget_open = new cBudget_open();
                var list         = oBudget_open.GETDETAILS(_strCriteria);
                rptItem.DataSource = list;
                rptItem.DataBind();

                if (dv["approve_head_status"].ToString() == "P")
                {
                    lblapprove_head_status.Text = "รออนุมัติ";
                }
                else if (dv["approve_head_status"].ToString() == "A")
                {
                    lblapprove_head_status.Text = "อนุมัติ";
                }
                else if (dv["approve_head_status"].ToString() == "C")
                {
                    lblapprove_head_status.Text = "ยกเลิกรายการ";
                }


                #region check user can edit/delete
                imgEdit.Visible   = base.IsUserEdit;
                imgDelete.Visible = base.IsUserDelete;
                #endregion

                if (this.MajorLock == "Y")
                {
                    imgEdit.Visible   = false;
                    imgDelete.Visible = false;
                    if (dv["approve_head_status"].ToString() == "P")
                    {
                        imgEdit.Visible   = true;
                        imgDelete.Visible = true;
                    }
                }
            }
        }
예제 #8
0
        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;
                }
            }
        }
예제 #9
0
        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();
            }
        }
예제 #10
0
        private bool saveData()
        {
            bool             blnResult        = false;
            Budget_open_head budget_open_head = new Budget_open_head();
            cBudget_open     obudget_open     = new cBudget_open();

            try
            {
                #region set Data
                budget_open_head.budget_open_doc  = txtbudget_open_doc.Text;
                budget_open_head.degree_code      = cboDegree.SelectedValue;
                budget_open_head.budget_open_date = cCommon.GetDate(Request.Form[txtbudget_open_date.UniqueID]);
                if (!string.IsNullOrEmpty(Request.Form[txtbudget_open_date_actual.UniqueID]))
                {
                    budget_open_head.budget_open_date_actual = cCommon.GetDate(Request.Form[txtbudget_open_date_actual.UniqueID]);
                }
                budget_open_head.budget_type      = cboBudget_type.SelectedValue;
                budget_open_head.budget_open_year = cboYear.SelectedValue;
                budget_open_head.major_code       = cboMajor.SelectedValue;
                budget_open_head.budget_plan_code = txtbudget_plan_code.Text;

                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();
                budget_open_head.ef_open_doc           = txtef_open_doc.Text;
                if (!string.IsNullOrEmpty(txtopen_code.Text))
                {
                    budget_open_head.open_code = int.Parse(txtopen_code.Text);
                }
                budget_open_head.open_title        = txtopen_title.Text.Trim();
                budget_open_head.open_command_desc = txtopen_command_desc.Text.Trim();
                budget_open_head.open_desc         = txtopen_desc.Text.Trim();

                budget_open_head.open_remark         = txtopen_remark.Text.Trim();
                budget_open_head.approve_head_status = cboApproveStatus.SelectedValue;
                budget_open_head.person_open         = txtperson_code.Text;

                budget_open_head.c_created_by = Session["username"].ToString();
                budget_open_head.c_updated_by = Session["username"].ToString();
                #endregion
                if (ViewState["mode"].ToString().ToLower().Equals("edit"))
                {
                    if (obudget_open.SP_BUDGET_OPEN_HEAD_UPD(budget_open_head))
                    {
                        saveDataDetail();
                        obudget_open.SP_BUDGET_OPEN_TOTAL_UPD(txtbudget_open_doc.Text);
                    }
                }
                else
                {
                    obudget_open.SP_BUDGET_OPEN_HEAD_INS(budget_open_head);
                    ViewState["budget_open_doc"] = budget_open_head.budget_open_doc;
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                obudget_open.Dispose();
            }
            return(blnResult);
        }