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