Esempio n. 1
0
    public static Boolean UpdateItemValue_New(dbo_ItemValueClass clsItemValue, string userName)
    {
        SqlConnection connection      = SAMDataClass.GetConnection();
        string        insertProcedure = "UpdateItemValue";
        SqlCommand    insertCommand   = new SqlCommand(insertProcedure, connection);

        insertCommand.CommandType = CommandType.StoredProcedure;
        insertCommand.Parameters.AddWithValue("@Mode", "UpdItemValue");
        insertCommand.Parameters.AddWithValue("@Item_Value_ID", clsItemValue.Item_Value_ID);
        insertCommand.Parameters.AddWithValue("@UpdateBY", userName);
        insertCommand.Parameters.AddWithValue("@UpdateParam", clsItemValue.Item_Value_Name);
        try
        {
            connection.Open();
            int count = insertCommand.ExecuteNonQuery();
            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(false);
        }
        finally
        {
            connection.Close();
        }
    }
Esempio n. 2
0
    protected void gdvItemValue_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int      current_index = int.Parse(ViewState["current_index"].ToString());
        GridView gv            = (GridView)gdvItem.Rows[current_index + 1].FindControl("gdvItemValue");
        Label    lblItem_ID    = (Label)gdvItem.Rows[current_index].FindControl("lblItem_ID");

        TextBox txtEditItemValue_Name = (TextBox)gv.Rows[e.RowIndex].FindControl("txtEditItemValue_Name");
        Label   lblItemValue_ID       = (Label)gv.Rows[e.RowIndex].FindControl("lblItemValue_ID");

        if (!string.IsNullOrEmpty(txtEditItemValue_Name.Text))
        {
            dbo_ItemValueClass cycle = new dbo_ItemValueClass()
            {
                Item_ID         = lblItem_ID.Text,
                Item_Value_Name = txtEditItemValue_Name.Text,
                Item_Value_ID   = lblItemValue_ID.Text
            };

            bool   success = false;
            string User_ID = HttpContext.Current.Request.Cookies["User_ID"].Value;
            success = dbo_ItemDataClass.UpdateItemValue_New(cycle, User_ID);

            if (success)
            {
                gv.ShowFooter = false;
                gv.EditIndex  = -1;

                //List<dbo_ItemValueClass> item_value = dbo_ItemDataClass.GetItemValue_New(lblItemValue_ID.Text);
                List <dbo_ItemValueClass> item_value = dbo_ItemDataClass.GetItemValue_New(lblItem_ID.Text);
                gv.DataSource = item_value;
                gv.DataBind();
                //gv.Visible = true;
            }
        }
        else
        {
            System.Threading.Thread.Sleep(500);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
            Show("กรุณากรอกข้อมูลที่จำเป็นให้ครบถ้วน");
        }
        System.Threading.Thread.Sleep(500);
        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
    }