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); }
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); }
public bool SP_BUDGET_MONEY_MAJOR_UPD(Budget_money_major budget_money_major) { 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_MONEY_MAJOR_UPD"; oCommand.Parameters.Add("budget_money_major_id", SqlDbType.BigInt).Value = budget_money_major.budget_money_major_id; oCommand.Parameters.Add("budget_money_detail_id", SqlDbType.BigInt).Value = budget_money_major.budget_money_detail_id; oCommand.Parameters.Add("major_code", SqlDbType.VarChar).Value = budget_money_major.major_code; oCommand.Parameters.Add("budget_money_major_plan", SqlDbType.Money).Value = budget_money_major.budget_money_major_plan; oCommand.Parameters.Add("budget_money_major_plan2", SqlDbType.Money).Value = budget_money_major.budget_money_major_plan2; oCommand.Parameters.Add("budget_money_major_plan3", SqlDbType.Money).Value = budget_money_major.budget_money_major_plan3; oCommand.Parameters.Add("budget_money_major_contribute", SqlDbType.Money).Value = budget_money_major.budget_money_major_contribute; oCommand.Parameters.Add("budget_money_major_use", SqlDbType.Money).Value = budget_money_major.budget_money_major_use; oCommand.Parameters.Add("budget_money_major_comment", SqlDbType.VarChar).Value = budget_money_major.budget_money_major_comment; oCommand.Parameters.Add("c_updated_by", SqlDbType.VarChar).Value = budget_money_major.c_updated_by; oCommand.ExecuteNonQuery(); blnResult = true; } catch (Exception ex) { throw ex; } finally { oConn.Close(); oCommand.Dispose(); oConn.Dispose(); } return(blnResult); }