public void GetMyTool(string UserID) //get list of note
        {
            // inistailze the data Users
            JavaScriptSerializer ser = new JavaScriptSerializer();

            ToolListing[] ToolData = null;
            int           HasTool  = 0;
            string        message  = "ok";

            try
            {
                using (SqlConnection connection = new SqlConnection(DBConnection.ConnectionString()))
                {
                    SqlCommand cmd = new SqlCommand("SELECT * FROM Tools WHERE UserID=@UserID");
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = connection;
                    cmd.Parameters.AddWithValue("@UserID", UserID);
                    connection.Open();
                    SqlDataAdapter adpt      = new SqlDataAdapter(cmd);
                    DataTable      dataTable = new DataTable();
                    adpt.Fill(dataTable);

                    ToolData = new ToolListing[dataTable.Rows.Count];
                    GetPicture getPicture = new GetPicture();

                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        ToolData[i]             = new ToolListing();
                        ToolData[i].ToolID      = Convert.ToString(dataTable.Rows[i]["ToolID"]);
                        ToolData[i].ToolName    = Convert.ToString(dataTable.Rows[i]["ToolName"]);
                        ToolData[i].ToolDes     = Convert.ToString(dataTable.Rows[i]["ToolDes"]);
                        ToolData[i].ToolPrice   = Convert.ToString(dataTable.Rows[i]["ToolPrice"]);
                        ToolData[i].DateAdd     = Convert.ToString(dataTable.Rows[i]["DateAdd"]);
                        ToolData[i].PictureLink = getPicture.GetToolPicture(ToolData[i].ToolID);
                    }
                    if (dataTable.Rows.Count > 0)
                    {
                        HasTool = 1;
                    }
                    dataTable.Clear();
                    connection.Close();
                }
            }
            catch (Exception ex)
            {
                HasTool = 0;
                message = ex.Message;
            }
            var jsonData = new
            {
                ToolData = ToolData,
                HasTool  = HasTool,
                message  = message
            };

            HttpContext.Current.Response.Write(ser.Serialize(jsonData));
        }
        public void UpdateTool(string ToolID, string ToolName, string ToolDes, string ToolPrice
                               , string ToolTypeID, string PicPath) //get list of note
        {
            // intilize the data user
            JavaScriptSerializer ser = new JavaScriptSerializer();
            int    IsUpdate          = 1;
            string Message           = "";

            try
            {
                using (SqlConnection connection = new SqlConnection(DBConnection.ConnectionString()))
                {
                    SqlCommand cmd = new SqlCommand("UPDATE Tools SET ToolName=@ToolName, ToolDes=@ToolDes, " +
                                                    "ToolPrice=@ToolPrice, ToolTypeID=@ToolTypeID" +
                                                    " WHERE ToolID=@ToolID");
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = connection;
                    cmd.Parameters.AddWithValue("@ToolName", ToolName);
                    cmd.Parameters.AddWithValue("@ToolDes", ToolDes);
                    cmd.Parameters.AddWithValue("@ToolPrice", ToolPrice);
                    cmd.Parameters.AddWithValue("@ToolTypeID", ToolTypeID);
                    cmd.Parameters.AddWithValue("@ToolID", ToolID);

                    connection.Open();
                    cmd.ExecuteNonQuery();
                    connection.Close();
                }
                GetPicture getPicture = new GetPicture();
                if (getPicture.isToolPicture(ToolID))
                {
                    using (SqlConnection connection = new SqlConnection(DBConnection.ConnectionString()))
                    {
                        SqlCommand cmd = new SqlCommand("UPDATE Pictures SET PicPath=@PicPath" +
                                                        " WHERE ToolID=@ToolID");
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = connection;
                        cmd.Parameters.AddWithValue("@PicPath", PicPath);
                        cmd.Parameters.AddWithValue("@ToolID", ToolID);

                        connection.Open();
                        cmd.ExecuteNonQuery();
                        connection.Close();
                    }
                }
                else
                {
                    using (SqlConnection connection = new SqlConnection(DBConnection.ConnectionString()))
                    {
                        SqlCommand cmd = new SqlCommand("INSERT INTO Pictures (ToolID, PicPath)" +
                                                        " VALUES (@ToolID, @PicPath)");
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = connection;
                        cmd.Parameters.AddWithValue("@PicPath", PicPath);
                        cmd.Parameters.AddWithValue("@ToolID", ToolID);

                        connection.Open();
                        cmd.ExecuteNonQuery();
                        connection.Close();
                    }
                }



                Message = "Tool is Update";
            }
            catch (Exception ex)
            {
                IsUpdate = 0;
                Message  = ex.Message; // "Cannot add yor information"
            }

            var jsonData = new
            {
                IsUpdate = IsUpdate,
                Message  = Message
            };

            HttpContext.Current.Response.Write(ser.Serialize(jsonData));
        }