private bool saveDataDetail()
        {
            bool               blnResult                = false;
            string             strScript                = string.Empty;
            cBudget_open       oBudget_open             = new cBudget_open();
            HiddenField        hddbudget_open_detail_id = null;
            TextBox            txtmaterial_detail       = null;
            AwNumeric          txtopen_detail_amount    = null;
            Budget_open_detail budget_open_detail       = null;

            try
            {
                for (var index = 0; index < GridView1.Rows.Count; index++)
                {
                    hddbudget_open_detail_id = (HiddenField)GridView1.Rows[index].FindControl("hddbudget_open_detail_id");
                    txtmaterial_detail       = (TextBox)GridView1.Rows[index].FindControl("txtmaterial_detail");
                    txtopen_detail_amount    = (AwNumeric)GridView1.Rows[index].FindControl("txtopen_detail_amount");
                    if (!string.IsNullOrEmpty(hddbudget_open_detail_id.Value))
                    {
                        budget_open_detail = new Budget_open_detail
                        {
                            budget_open_doc           = ViewState["budget_open_doc"].ToString(),
                            budget_open_detail_id     = long.Parse(hddbudget_open_detail_id.Value),
                            budget_open_detail_amount = decimal.Parse(txtopen_detail_amount.Value.ToString()),
                            material_detail           = txtmaterial_detail.Text,
                            c_updated_by = Session["username"].ToString()
                        };
                        oBudget_open.SP_BUDGET_OPEN_DETAIL_UPD(budget_open_detail);
                    }
                }
                blnResult = true;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("duplicate key"))
                {
                    MsgBox("ข้อมูลซ้ำโปรดตรวจสอบ");
                }
                else
                {
                    lblError.Text = ex.Message.ToString();
                }
            }
            finally
            {
                oBudget_open.Dispose();
            }
            return(blnResult);
        }
Beispiel #2
0
        public bool SP_BUDGET_OPEN_DETAIL_INS(Budget_open_detail budget_open_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_OPEN_DETAIL_INS";

                SqlParameter oParambudget_open_detail_id = new SqlParameter("budget_open_detail_id", SqlDbType.BigInt);
                oParambudget_open_detail_id.Direction = ParameterDirection.Output;
                oParambudget_open_detail_id.Value     = budget_open_detail.budget_open_detail_id;
                oCommand.Parameters.Add(oParambudget_open_detail_id);
                oCommand.Parameters.Add("budget_open_doc", SqlDbType.VarChar).Value           = budget_open_detail.budget_open_doc;
                oCommand.Parameters.Add("budget_money_major_id", SqlDbType.Int).Value         = budget_open_detail.budget_money_major_id;
                oCommand.Parameters.Add("budget_open_detail_remark", SqlDbType.VarChar).Value = budget_open_detail.budget_open_detail_remark;
                oCommand.Parameters.Add("budget_open_detail_amount", SqlDbType.Money).Value   = budget_open_detail.budget_open_detail_amount;

                oCommand.Parameters.Add("material_id", SqlDbType.Int).Value         = budget_open_detail.material_id;
                oCommand.Parameters.Add("material_detail", SqlDbType.VarChar).Value = budget_open_detail.material_detail;
                oCommand.Parameters.Add("material_name", SqlDbType.VarChar).Value   = budget_open_detail.material_name;

                oCommand.Parameters.Add("c_created_by", SqlDbType.VarChar).Value = budget_open_detail.c_created_by;
                oCommand.ExecuteNonQuery();
                budget_open_detail.budget_open_detail_id = long.Parse(oParambudget_open_detail_id.Value.ToString());
                blnResult = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                oConn.Close();
                oCommand.Dispose();
                oConn.Dispose();
            }
            return(blnResult);
        }
Beispiel #3
0
        private bool saveData()
        {
            bool   blnResult    = false;
            string strUpdatedBy = string.Empty;

            strUpdatedBy = Session["username"].ToString();
            CheckBox           chkSelect;
            HiddenField        hddbudget_money_major_id;
            var                oBudget_open       = new cBudget_open();
            Budget_open_detail budget_open_detail = null;

            try
            {
                foreach (GridViewRow gvRow in GridView1.Rows)
                {
                    chkSelect = (CheckBox)gvRow.FindControl("chkSelect");
                    var select = Request.Form[chkSelect.UniqueID];
                    if (select != null && select == "on")
                    {
                        hddbudget_money_major_id = (HiddenField)gvRow.FindControl("hddbudget_money_major_id");
                        budget_open_detail       = new Budget_open_detail()
                        {
                            budget_open_doc           = ViewState["budget_open_doc"].ToString(),
                            budget_money_major_id     = long.Parse(hddbudget_money_major_id.Value),
                            budget_open_detail_amount = 0,
                            budget_open_detail_remark = string.Empty,
                            c_created_by = strUpdatedBy
                        };
                        oBudget_open.SP_BUDGET_OPEN_DETAIL_INS(budget_open_detail);
                    }
                    blnResult = true;
                }
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
            finally
            {
                oBudget_open.Dispose();
            }
            return(blnResult);
        }