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); }