public bool SP_BUDGET_OPEN_HEAD_INS(Budget_open_head budget_open_head) { bool blnResult = false; SqlConnection oConn = new SqlConnection(); SqlCommand oCommand = new SqlCommand(); SqlDataAdapter oAdapter = new SqlDataAdapter(); try { oConn.ConnectionString = _strConn; oConn.Open(); oCommand.Connection = oConn; oCommand.CommandType = CommandType.StoredProcedure; oCommand.CommandText = "sp_BUDGET_OPEN_HEAD_INS"; SqlParameter oParambudget_open_doc = new SqlParameter("budget_open_doc", SqlDbType.VarChar, 10) { Direction = ParameterDirection.Output, Value = budget_open_head.budget_open_doc }; oCommand.Parameters.Add(oParambudget_open_doc); oCommand.Parameters.Add("ef_open_doc", SqlDbType.VarChar).Value = budget_open_head.ef_open_doc; oCommand.Parameters.Add("budget_open_no", SqlDbType.VarChar).Value = budget_open_head.budget_open_no; oCommand.Parameters.Add("budget_open_ap", SqlDbType.VarChar).Value = budget_open_head.budget_open_ap; oCommand.Parameters.Add("budget_open_pr", SqlDbType.VarChar).Value = budget_open_head.budget_open_pr; oCommand.Parameters.Add("budget_open_budget_no", SqlDbType.VarChar).Value = budget_open_head.budget_open_budget_no; oCommand.Parameters.Add("budget_open_date", SqlDbType.DateTime).Value = budget_open_head.budget_open_date; oCommand.Parameters.Add("budget_open_date_actual", SqlDbType.DateTime).Value = budget_open_head.budget_open_date_actual; oCommand.Parameters.Add("budget_open_year", SqlDbType.VarChar).Value = budget_open_head.budget_open_year; oCommand.Parameters.Add("open_code", SqlDbType.VarChar).Value = budget_open_head.open_code; oCommand.Parameters.Add("open_title", SqlDbType.VarChar).Value = budget_open_head.open_title; oCommand.Parameters.Add("open_command_desc", SqlDbType.VarChar).Value = budget_open_head.open_command_desc; oCommand.Parameters.Add("open_desc", SqlDbType.VarChar).Value = budget_open_head.open_desc; oCommand.Parameters.Add("budget_type", SqlDbType.VarChar).Value = budget_open_head.budget_type; oCommand.Parameters.Add("budget_plan_code", SqlDbType.VarChar).Value = budget_open_head.budget_plan_code; oCommand.Parameters.Add("degree_code", SqlDbType.VarChar).Value = budget_open_head.degree_code; oCommand.Parameters.Add("major_code", SqlDbType.VarChar).Value = budget_open_head.major_code; oCommand.Parameters.Add("open_remark", SqlDbType.VarChar).Value = budget_open_head.open_remark; oCommand.Parameters.Add("open_amount", SqlDbType.Money).Value = budget_open_head.open_amount; oCommand.Parameters.Add("person_open", SqlDbType.VarChar).Value = budget_open_head.person_open; oCommand.Parameters.Add("approve_head_status", SqlDbType.VarChar).Value = budget_open_head.approve_head_status; oCommand.Parameters.Add("c_created_by", SqlDbType.VarChar).Value = budget_open_head.c_created_by; oCommand.ExecuteNonQuery(); budget_open_head.budget_open_doc = oParambudget_open_doc.Value.ToString(); blnResult = true; } catch (Exception ex) { throw ex; } finally { oConn.Close(); oCommand.Dispose(); oConn.Dispose(); } return(blnResult); }
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); }