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);
        }
예제 #2
0
        public bool SP_BUDGET_MONEY_DETAIL_INS(Budget_money_detail budget_money_detail)
        {
            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_DETAIL_INS";

                SqlParameter oParambudget_money_detail_id = new SqlParameter("budget_money_detail_id", SqlDbType.BigInt);
                oParambudget_money_detail_id.Direction = ParameterDirection.Output;
                oParambudget_money_detail_id.Value     = budget_money_detail.budget_money_detail_id;
                oCommand.Parameters.Add(oParambudget_money_detail_id);
                //oCommand.Parameters.Add("budget_money_detail_id",  SqlDbType.BigInt, ).Value = budget_money_detail.budget_money_detail_id;
                oCommand.Parameters.Add("budget_money_doc", SqlDbType.VarChar).Value             = budget_money_detail.budget_money_doc;
                oCommand.Parameters.Add("item_detail_id", SqlDbType.BigInt).Value                = budget_money_detail.item_detail_id;
                oCommand.Parameters.Add("budget_money_detail_plan", SqlDbType.Money).Value       = budget_money_detail.budget_money_detail_plan;
                oCommand.Parameters.Add("budget_money_detail_plan2", SqlDbType.Money).Value      = budget_money_detail.budget_money_detail_plan2;
                oCommand.Parameters.Add("budget_money_detail_plan3", SqlDbType.Money).Value      = budget_money_detail.budget_money_detail_plan3;
                oCommand.Parameters.Add("budget_money_detail_contribute", SqlDbType.Money).Value = budget_money_detail.budget_money_detail_contribute;
                oCommand.Parameters.Add("budget_money_detail_use", SqlDbType.Money).Value        = budget_money_detail.budget_money_detail_use;
                oCommand.Parameters.Add("budget_money_detail_comment", SqlDbType.VarChar).Value  = budget_money_detail.budget_money_detail_comment;
                oCommand.Parameters.Add("c_created_by", SqlDbType.VarChar).Value = budget_money_detail.c_created_by;
                oCommand.ExecuteNonQuery();
                budget_money_detail.budget_money_detail_id = long.Parse(oParambudget_money_detail_id.Value.ToString());
                blnResult = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConn.Close();
                oCommand.Dispose();
                oConn.Dispose();
            }
            return(blnResult);
        }